
Y[c           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m	 Z	 d d l m
 Z d d l m Z d d l m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d
 l m Z d e j f d     YZ d e j f d     YZ d e j f d     YZ d e j f d     YZ d e j f d     YZ d e j f d     YZ d   Z e d  Z  e! d k re j"   n  d S(   s   Tests for certbot.auth_handler.iN(   t
   challenges(   t   client(   t   messages(   t   Dict(   t   achallenges(   t   errors(   t
   interfaces(   t   util(   t	   acme_utilt   ChallengeFactoryTestc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   sf   d d l  m } | d  d  t j d d  g   |  _ t j t j	 d t j
 t j	 g d t  |  _ d  S(   Ni(   t   AuthHandlert   keyt   mock_keyt   testi   (   t   certbot.auth_handlerR
   t   Nonet   mockt   Mockt   handlerR   t
   gen_authzrR   t   STATUS_PENDINGt
   CHALLENGESt   Falset   authzr(   t   selfR
   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   setUp   s
    $c         C   sW   |  j  j |  j t d t t j    } |  j g  | D] } | j ^ q7 t j  d  S(   Ni    (	   R   t   _challenge_factoryR   t   ranget   lenR   R   t   assertEqualt   chall(   R   t   achallst   achall(    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_all%   s    	!c         C   sK   |  j  j |  j d g  } |  j g  | D] } | j ^ q( t j g  d  S(   Ni   (   R   R   R   R   R   R   t   TLSSNI01(   R   R   R    (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_one_tls_sni,   s    c         C   s\   t  j t j d t j d d d d  g t j g  } |  j t j |  j	 j
 | d g  d  S(   NR   R   t   typt   unrecognizedi    (   R   R   R   R   R   R   t   assertRaisesR   t   ErrorR   R   (   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_unrecognized2   s    	(   t   __name__t
   __module__R   R!   R#   R(   (    (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR	      s   	
		t   HandleAuthorizationsTestc           B   s@  e  Z d  Z d   Z d   Z d   Z d   Z d   Z e j	 d  d    Z
 e j	 d  d    Z d	   Z d
   Z d   Z e j	 d  d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e j	 d  d    Z e j	 d  e j	 d  d     Z d   Z RS(   sm   handle_authorizations test.

    This tests everything except for all functions under _poll_challenges.

    c         C   s  d d l  m } t j   |  _ t j j |  j t j	  t j j t j d t
  t j  t j d d  |  _ t j g |  j j _ t |  j j _ t j d t j d d   |  _ t j d	 t j  |  _ d
 |  j _ | |  j |  j |  j g   |  _ t j t j  d  S(   Ni(   R
   t   debug_challengest   namet   ApacheConfiguratorR   t	   file_patht   PEMt   speci   (    R   R
   R   R   t   mock_displayt   zopet	   componentt   provideUtilityR   t   IDisplayR   t   IConfigt	   MagicMockt	   mock_authR    R"   t   get_chall_preft   return_valuet   gen_auth_respt   performt   side_effectR   t   Keyt   mock_accountt   acme_clientt   Clientt   mock_nett   acme_versionR   t   loggingt   disablet   CRITICAL(   R   R
   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR   C   s    		!c         C   s   t  j t  j  d  S(   N(   RE   RF   t   NOTSET(   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   tearDown[   s    c         C   s?  t  d d d t j d |  } t j d | g  } t j d  % } |  j | _ |  j j	 |  } Wd  QX|  j
 |  j j j d  |  j
 | j d  | j d d } |  j
 t t j |   d g  |  j
 t | j    d  |  j
 |  j j j d  |  j
 |  j j j d d d j d	  |  j
 t |  d  d  S(
   Nt   domaint   0t   challst   combost   authorizationss1   certbot.auth_handler.AuthHandler._poll_challengesi   i    s
   tls-sni-01(   t   gen_dom_authzrR   R   R   R8   t   patcht   _validate_allR>   R   t   handle_authorizationsR   RC   t   answer_challenget
   call_countt	   call_argst   listt   sixt   iterkeysR   t   valuesR9   t   cleanupR$   (   R   RM   R   t
   mock_ordert	   mock_pollt   chall_update(    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   _test_name1_tls_sni_01_1_common^   s    ""c         C   s   |  j  d t  d  S(   NRM   (   R^   t   True(   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_name1_tls_sni_01_1_acme_1t   s    c         C   s    d |  j  _ |  j d t  d  S(   Ni   RM   (   RC   RD   R^   R   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_name1_tls_sni_01_1_acme_2w   s    s1   certbot.auth_handler.AuthHandler._poll_challengesc         C   si  |  j  | _ |  j j j j t j  |  j j j j t j  t	 d d d t
 j d t  } t j d | g  } |  j j |  } |  j |  j j j d  |  j | j d  | j d d } |  j t t j |   d g  |  j t | j    d  |  j |  j j j d  x5 |  j j j d d D] } |  j | j d k  q/W|  j t |  d  d  S(   NRJ   RK   RL   RM   RN   i   i   i    s
   tls-sni-01s   http-01s   dns-01(   s
   tls-sni-01s   http-01s   dns-01(   RQ   R>   R9   R:   R;   t   appendR    t   HTTP01t   DNS01RO   R   R   R   R   R8   R   RR   R   RC   RS   RT   RU   RV   RW   RX   R   RY   RZ   t
   assertTrueR$   (   R   R\   R   R[   R]   R    (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt.   test_name1_tls_sni_01_1_http_01_1_dns_1_acme_1{   s    "c         C   s  d |  j  _ |  j | _ |  j j j j t j	  |  j j j j t j
  t d d d t j d t  } t j d | g  } |  j j |  } |  j |  j  j j d  |  j | j d  | j d d } |  j t t j |   d g  |  j t | j    d  |  j |  j j j d  |  j j j d d } |  j t |  d  |  j | d j d	  |  j t |  d  d  S(
   Ni   RJ   RK   RL   RM   RN   i   i    s
   tls-sni-01(   RC   RD   RQ   R>   R9   R:   R;   Rb   R    Rc   Rd   RO   R   R   R   R   R8   R   RR   R   RS   RT   RU   RV   RW   RX   R   RY   RZ   R$   (   R   R\   R   R[   R]   t   cleaned_up_achalls(    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt.   test_name1_tls_sni_01_1_http_01_1_dns_1_acme_2   s"    "c         C   s  t  j t d t j d | |  j j _ t d d d t j  t d d d t j  t d d d t j  g } t j	 d |  } t j
 d  % } |  j | _ |  j j |  } Wd  QX|  j |  j j j d	  |  j | j d
  | j d d
 } |  j t t t j |    d	  |  j d t t j |   k  |  j t | d  d
  |  j d
 t t j |   k  |  j t | d
  d
  |  j d t t j |   k  |  j t | d  d
  |  j |  j j j d
  |  j t |  d	  d  S(   NRL   RM   RJ   RK   t   1t   2RN   s1   certbot.auth_handler.AuthHandler._poll_challengesi   i   i    i   (   t	   functoolst   partialRO   R   R   RC   t   request_domain_challengesR>   R   R8   RP   RQ   R   RR   R   RS   RT   RU   R   RV   RW   RX   Re   R9   RZ   (   R   RM   t   authzrsR[   R\   R   R]   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   _test_name3_tls_sni_01_3_common   s*    !%"""c         C   s   |  j  d t  d  S(   NRM   (   Ro   R_   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt%   test_name3_tls_sni_01_3_common_acme_1   s    c         C   s    d |  j  _ |  j d t  d  S(   Ni   RM   (   RC   RD   Ro   R   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt%   test_name3_tls_sni_01_3_common_acme_2   s    c         C   s   t  j j t j d t  t j  t d d d t	 j
  g } t j d |  } |  j | _ |  j j |  |  j |  j j j d  |  j |  j j j d  d  S(   NR,   RJ   RK   RL   RN   i   (   R3   R4   R5   R   R   R_   R   R7   RO   R   R   R8   RQ   R>   R   RR   R   RC   RS   RT   R2   t   notification(   R   R\   Rn   R[   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_debug_challenges   s    	c         C   s_   t  d d d t j  g } t j d |  } t j |  j j _	 |  j
 t j |  j j |  d  S(   NRJ   RK   RL   RN   (   RO   R   R   R   R8   R   t   AuthorizationErrorR9   R=   R>   R&   R   RR   (   R   Rn   R[   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_perform_failure   s
    c         C   s2   t  j d g   } |  j t j |  j j |  d  S(   NRN   (   R   R8   R&   R   Rt   R   RR   (   R   R[   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_no_domains   s    c         C   s   t  d d d t j d |  g } t j d |  } |  j j j j t	 j
  |  j j j t	 j
 j t	 j j f  t j d  # } |  j | _ |  j j |  Wd  QX|  j |  j j j d  |  j |  j j j d d d j d	  d  S(
   NRJ   RK   RL   RM   RN   s1   certbot.auth_handler.AuthHandler._poll_challengesi   i    s   http-01(   RO   R   R   R   R8   R9   R:   R;   Rb   R    Rc   R   t   pref_challst   extendR$   Rd   RP   RQ   R>   RR   R   RZ   RT   RU   (   R   RM   Rn   R[   R\   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt'   _test_preferred_challenge_choice_common   s    !c         C   s   |  j  d t  d  S(   NRM   (   Ry   R_   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt-   test_preferred_challenge_choice_common_acme_1   s    c         C   s    d |  j  _ |  j d t  d  S(   Ni   RM   (   RC   RD   Ry   R   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt-   test_preferred_challenge_choice_common_acme_2  s    c         C   sl   t  d d d t j d |  g } t j d |  } |  j j j t j	 j
  |  j t j |  j j |  d  S(   NRJ   RK   RL   RM   RN   (   RO   R   R   R   R8   R   Rw   Rb   R    Rc   R$   R&   R   Rt   RR   (   R   RM   Rn   R[   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt/   _test_preferred_challenges_not_supported_common  s
    !c         C   s   |  j  d t  d  S(   NRM   (   R|   R_   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt.   test_preferred_challenges_not_supported_acme_1  s    c         C   s    d |  j  _ |  j d t  d  S(   Ni   RM   (   RC   RD   R|   R   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt.   test_preferred_challenges_not_supported_acme_2  s    c         C   sP   t  d d d t j g  g } t j d |  } |  j t j |  j j	 |  d  S(   NRJ   RK   RL   RN   (
   RO   R   Rd   R   R8   R&   R   Rt   R   RR   (   R   Rn   R[   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt%   test_dns_only_challenge_not_supported  s    c         C   s   t  j |  j j _ t d d d t j d t  } t	 j
 d | g  } |  j t  j |  j j |  |  j |  j j j d  |  j |  j j j d d d j d  d  S(	   NRJ   RK   RL   RM   RN   i   i    s
   tls-sni-01(   R   Rt   R9   R=   R>   RO   R   R   R_   R   R8   R&   R   RR   R   RZ   RT   RU   R$   (   R   R   R[   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_perform_error  s    s)   certbot.auth_handler.AuthHandler._respondc         C   s   t  d d d t j  g } t j d |  } t j | _ |  j t j |  j	 j
 |  |  j |  j j j d  |  j |  j j j d d d j d  d  S(   NRJ   RK   RL   RN   i   i    s
   tls-sni-01(   RO   R   R   R   R8   R   Rt   R>   R&   R   RR   R   R9   RZ   RT   RU   R$   (   R   t   mock_respondRn   R[   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_respond_error%  s    s7   certbot.auth_handler.AuthHandler.verify_authzr_completec         C   s   t  d d d t j  g } t j d |  } t j | _ |  j | _ |  j	 t j |  j
 j |  |  j |  j j j d  |  j |  j j j d d d j d  d  S(   NRJ   RK   RL   RN   i   i    s
   tls-sni-01(   RO   R   R   R   R8   R   Rt   R>   RQ   R&   R   RR   R   R9   RZ   RT   RU   R$   (   R   t   mock_verifyR\   Rn   R[   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_incomplete_authzr_error1  s    c   	      C   s   x t  |  D] \ } } | j } t j t j | j j j g  | j j	 D] } | j
 ^ qG t j g t | j j	  | j j  } t |  | | j  | | <q Wd  S(   N(   t	   enumerateR   R   R   R   t   STATUS_VALIDt   bodyt
   identifiert   valueR    R   R   t   combinationst   typeR   (	   R   t   aauthzrst   unused_1t   unused_2t   it   aauthzrt   azrt   challbt   updated_azr(    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyRQ   ?  s    	(   R)   R*   t   __doc__R   RI   R^   R`   Ra   R   RP   Rf   Rh   Ro   Rp   Rq   Rs   Ru   Rv   Ry   Rz   R{   R|   R}   R~   R   R   R   R   RQ   (    (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR+   <   s4   																			t   PollChallengesTestc           B   s   e  Z d  Z d   Z e j d  d    Z e j d  d    Z e j d  e j	   d     Z
 e j d  d    Z d   Z d   Z d	   Z d
   Z RS(   s   Test poll challenges.c      	   C   s  d d l  m } d d l  m } m } t j   |  _ | d  |  j t j d d  g   |  _	 d d d g |  _
 | t j t j |  j
 d	 t j t j g t j g d
 t  g   | t j t j |  j
 d t j t j g d t  g   | t j t j |  j
 d
 t j t j g d t  g   g |  _ i  |  _ xe t |  j  D]T \ } } g  | j j j D]+ } | | t j d d  |  j
 |  ^ q]|  j | <qAWd  S(   Ni(   t   challb_to_achall(   R
   t   AnnotatedAuthzrR   R   RK   Ri   Rj   i    i   i   i   t	   dummy_key(   R   R   R
   R   R   R8   RC   R   R   R   t   domsR   R   R   R   Rc   R"   R   R   R   R]   R   R   R   R    (   R   R   R
   R   R   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR   O  s(    $			(	s   certbot.auth_handler.timec         C   sb   |  j  |  j j _ |  j j |  j |  j t  x- |  j D]" } |  j	 | j
 j j t j  q8 Wd  S(   N(   t   _mock_poll_solve_one_validRC   t   pollR>   R   t   _poll_challengesR   R]   R   R   R   R   t   statusR   R   (   R   t   unused_mock_timeR   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_poll_challengesm  s    c         C   sb   |  j  |  j j _ |  j j |  j |  j t  x- |  j D]" } |  j	 | j
 j j t j  q8 Wd  S(   N(   t   _mock_poll_solve_one_invalidRC   R   R>   R   R   R   R]   R_   R   R   R   R   R   R   (   R   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt(   test_poll_challenges_failure_best_effortu  s    c         C   s>   |  j  |  j j _ |  j t j |  j j |  j	 |  j
 t  d  S(   N(   R   RC   R   R>   R&   R   Rt   R   R   R   R]   R   (   R   R   t   unused_mock_zope(    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_poll_challenges_failure}  s    c         C   sx   d d l  m } |  j |  j j _ |  j d j | t j	 d |  j
 d   |  j t j |  j j |  j |  j t  d  S(   Ni(   R   i    R   (   R   R   R   RC   R   R>   R]   Rb   R   t   DNS01_PR   R&   R   Rt   R   R   R   R   (   R   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt$   test_unable_to_find_challenge_status  s    c         C   s#   |  j  t j |  j j |  j  d  S(   N(   R&   R   Rt   R   t   verify_authzr_completeR   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_verify_authzr_failure  s    c         C   s   |  j  | t j  S(   N(   t   _mock_poll_solve_one_challR   R   (   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR     s    c         C   s   |  j  | t j  S(   N(   R   R   t   STATUS_INVALID(   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR     s    c            s   | j  j } xL | j  j D]>     j  k r t    f d   | j  j D  } Pq q Wt  f d   | D  r  } n | j  j } t j d | j d t j d | j  j	 d | d | j  j
 d |   } | d	 f S(
   s   Dummy method that solves one chall at a time to desired_status.

        When all are solved.. it changes authzr.status to desired_status

        c         3   s6   |  ], } |   k r | n t  j   j   Vq d  S(   N(   R   t   chall_to_challbR   (   t   .0t   challb_temp(   R   t   desired_status(    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pys	   <genexpr>  s   c         3   s   |  ] } | j    k Vq d  S(   N(   R   (   R   t   test_challb(   R   (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pys	   <genexpr>  s   t   uriR   R   R    R   R   t   response(   R   R    R   t   tuplet   allR   t   AuthorizationResourceR   t   AuthorizationR   R   (   R   R   R   t   new_challbst   status_t
   new_authzr(    (   R   R   sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR     s&    				(   R)   R*   R   R   R   RP   R   R   t	   test_utilt   patch_get_utilityR   R   R   R   R   R   (    (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR   K  s   	
			t   ChallbToAchallTestc           B   s    e  Z d  Z d   Z d   Z RS(   s0   Tests for certbot.auth_handler.challb_to_achall.c         C   s    d d l  m } | | d d  S(   Ni(   R   t   account_keyRJ   (   R   R   (   R   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   _call  s    c      	   C   s;   |  j  |  j t j  t j d t j d d d d   d  S(   NR   R   RJ   (   R   R   R   t   HTTP01_PR   t"   KeyAuthorizationAnnotatedChallenge(   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_it  s
    	(   R)   R*   R   R   R   (    (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR     s   	t   GenChallengePathTestc           B   sA   e  Z d  Z d   Z d   Z e d    Z d   Z d   Z RS(   s   Tests for certbot.auth_handler.gen_challenge_path.

    .. todo:: Add more tests for dumb_path... depending on what we want to do.

    c         C   s   t  j t  j  d  S(   N(   RE   RF   t   FATAL(   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR     s    c         C   s   t  j t  j  d  S(   N(   RE   RF   RH   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyRI     s    c         C   s    d d l  m } | | | |  S(   Ni(   t   gen_challenge_path(   R   R   (   t   clst   challbst   preferencesR   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR     s    c         C   s   t  j t  j f } t j t j g } d d f } |  j |  j | | |  d  |  j |  j | | d   |  j |  j | d d d  | |  d  |  j |  j | d d d  | d   d S(	   s2   Given TLSSNI01 and HTTP01 with appropriate combos.i    i   Ni(   i    (   i   (   i    (   i   (
   R   t
   TLSSNI01_PR   R    R"   Rc   R   R   Re   R   (   R   R   t   prefsRM   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_common_case  s    ,c         C   sf   t  j t  j f } t j g } d } |  j t j |  j | | |  |  j t j |  j | | d   d  S(   Ni    i   (   i    i   (   (   i    i   (
   R   R   R   R    R"   R&   R   Rt   R   R   (   R   R   R   RM   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_not_supported  s    (	   R)   R*   R   R   RI   t   classmethodR   R   R   (    (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR     s   			t   ReportFailedChallsTestc           B   sA   e  Z d  Z d   Z e j   d    Z e j   d    Z RS(   s5   Tests for certbot.auth_handler._report_failed_challs.c         C   s   i t  j d 6d d 6t j d 6t j j d d d d 6} |  j | d j d  k	  t	 j
 d t j |   d d	 d
 d  |  _ t  j | d <t	 j
 d t j |   d d	 d
 d  |  _ t j d d d d  | d <t	 j
 d t j |   d d d
 d  |  _ d  S(   NR   R   R   t   tlst   detailt   errorR   RJ   s   example.comR   R   R$   t   dnssecs   foo.bar(   R   Rc   R   R   R'   t	   with_codeRe   t   descriptionR   R   R   t   ChallengeBodyt   http01R"   t   tls_sni_samet   tls_sni_diff(   R   t   kwargs(    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR     s(    

			c         C   st   d d l  m } | j |  j |  j g  |   j j } |  j t |  d k  |  j d | d d d k  d  S(   Ni(   t   auth_handleri   s.   Domain: example.com
Type:   tls
Detail: detaili    (	   t   certbotR   t   _report_failed_challsR   R   t   add_messaget   call_args_listRe   R   (   R   t	   mock_zopeR   t	   call_list(    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   test_same_error_and_domain  s
    c         C   sI   d d l  m } | j |  j |  j g  |  j |   j j d k  d  S(   Ni(   R   i   (   R   R   R   R   R   Re   R   RT   (   R   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt!   test_different_errors_and_domains'  s    (   R)   R*   R   R   R   R   R   R   (    (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR     s   		c         C   s*   g  |  D] } d | j  j | j f ^ q S(   s(   Generate a dummy authorization response.s   %s%s(   t	   __class__R)   RJ   (   t
   chall_listR   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyR<   /  s    c         C   s,   t  j t j |  | t j g t |  |  S(   s!   Generates new authzr for domains.(   R   R   R   R   R   (   RJ   RL   RM   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyRO   5  s    t   __main__(#   R   Rk   RE   t   unittestR   RW   t   zope.componentR3   t   acmeR    R   RA   R   t   acme.magic_typingR   R   R   R   R   R   t   certbot.testsR   R   t   TestCaseR	   R+   R   R   R   R   R<   R_   RO   R)   t   main(    (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/auth_handler_test.pyt   <module>   s6   $ u+4	