ó
Y[c           @   s¸   d  Z  d d l Z d d l Z d d l m Z m Z d d l m Z d d l	 m
 Z
 d d l m Z d Z e j j e j d ƒ ƒ Z d	 e
 j f d
 „  ƒ  YZ d e f d „  ƒ  YZ d S(   s8   Base test class for DNS authenticators built on Lexicon.iÿÿÿÿN(   t	   HTTPErrort   RequestException(   t   errors(   t   dns_test_common(   t   utils   example.coms   rsa512_key.pemt   BaseLexiconAuthenticatorTestc           B   s   e  Z d  „  Z d „  Z RS(   c         C   sR   |  j  j |  j g ƒ t j j t d t t j ƒ g } |  j | |  j	 j
 ƒ d  S(   Ns   _acme-challenge.(   t   autht   performt   achallt   mockt   callt   add_txt_recordt   DOMAINt   ANYt   assertEqualt   mock_clientt
   mock_calls(   t   selft   expected(    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt   test_perform   s    "c         C   s^   t  |  j _ |  j j |  j g ƒ t j j t d t t j	 ƒ g } |  j
 | |  j j ƒ d  S(   Ns   _acme-challenge.(   t   TrueR   t   _attempt_cleanupt   cleanupR   R	   R
   t   del_txt_recordR   R   R   R   R   (   R   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt   test_cleanup   s    "(   t   __name__t
   __module__R   R   (    (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyR      s   	t   BaseLexiconClientTestc           B   sÁ   e  Z e d  ƒ Z e Z e d ƒ Z e d ƒ Z d Z	 e	 d e
 Z d Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s   No domain founds   400 Client Error: ...s   500 Surprise! Error: ...s   _acme-challenget   .t   barc         C   sH   |  j  j t |  j |  j ƒ |  j j j d d d |  j d |  j ƒ d  S(   Nt   typet   TXTt   namet   content(   t   clientR   R   t   record_namet   record_contentt   provider_mockt   create_recordt   assert_called_with(   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt   test_add_txt_record+   s    	c         C   s`   |  j  d g |  j j _ |  j j t |  j |  j ƒ |  j j	 j
 d d d |  j d |  j ƒ d  S(   Nt    R   R   R    R!   (   t   DOMAIN_NOT_FOUNDR%   t   authenticatet   side_effectR"   R   R   R#   R$   R&   R'   (   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt,   test_add_txt_record_try_twice_to_find_domain2   s
    	c         C   sM   |  j  |  j  |  j  g |  j j _ |  j t j |  j j t	 |  j
 |  j ƒ d  S(   N(   R*   R%   R+   R,   t   assertRaisesR   t   PluginErrorR"   R   R   R#   R$   (   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt'   test_add_txt_record_fail_to_find_domain;   s    	c         C   s>   |  j  |  j j _ |  j t j |  j j t	 |  j
 |  j ƒ d  S(   N(   t   LOGIN_ERRORR%   R+   R,   R.   R   R/   R"   R   R   R#   R$   (   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt(   test_add_txt_record_fail_to_authenticateD   s    	c         C   s>   |  j  |  j j _ |  j t j |  j j t	 |  j
 |  j ƒ d  S(   N(   t   UNKNOWN_LOGIN_ERRORR%   R+   R,   R.   R   R/   R"   R   R   R#   R$   (   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt;   test_add_txt_record_fail_to_authenticate_with_unknown_errorK   s    	c         C   s>   |  j  |  j j _ |  j t j |  j j t	 |  j
 |  j ƒ d  S(   N(   t   GENERIC_ERRORR%   R+   R,   R.   R   R/   R"   R   R   R#   R$   (   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt(   test_add_txt_record_error_finding_domainR   s    	c         C   s>   |  j  |  j j _ |  j t j |  j j t	 |  j
 |  j ƒ d  S(   N(   R5   R%   R&   R,   R.   R   R/   R"   R   R   R#   R$   (   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt'   test_add_txt_record_error_adding_recordY   s    	c         C   sH   |  j  j t |  j |  j ƒ |  j j j d d d |  j d |  j ƒ d  S(   NR   R   R    R!   (   R"   R   R   R#   R$   R%   t   delete_recordR'   (   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt   test_del_txt_record`   s    	c         C   sA   |  j  |  j  |  j  g |  j j _ |  j j t |  j |  j ƒ d  S(   N(	   R*   R%   R+   R,   R"   R   R   R#   R$   (   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt'   test_del_txt_record_fail_to_find_domaing   s    c         C   s2   |  j  |  j j _ |  j j t |  j |  j ƒ d  S(   N(	   R1   R%   R+   R,   R"   R   R   R#   R$   (   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt(   test_del_txt_record_fail_to_authenticaten   s    c         C   s2   |  j  |  j j _ |  j j t |  j |  j ƒ d  S(   N(	   R3   R%   R+   R,   R"   R   R   R#   R$   (   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt;   test_del_txt_record_fail_to_authenticate_with_unknown_errors   s    c         C   s2   |  j  |  j j _ |  j j t |  j |  j ƒ d  S(   N(	   R5   R%   R+   R,   R"   R   R   R#   R$   (   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt(   test_del_txt_record_error_finding_domainx   s    c         C   s2   |  j  |  j j _ |  j j t |  j |  j ƒ d  S(   N(	   R5   R%   R8   R,   R"   R   R   R#   R$   (   R   (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt)   test_del_txt_record_error_deleting_record}   s    (   R   R   t	   ExceptionR*   R   R5   R    R1   R3   t   record_prefixR   R#   R$   R(   R-   R0   R2   R4   R6   R7   R9   R:   R;   R<   R=   R>   (    (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyR   !   s(   														(   t   __doc__t   josepyt   joseR	   t   requests.exceptionsR    R   t   certbotR   t   certbot.pluginsR   t   certbot.testsR   t	   test_utilR   t   JWKRSAt   loadt   load_vectort   KEYt   BaseAuthenticatorTestR   t   objectR   (    (    (    sK   /usr/lib/python2.7/dist-packages/certbot/plugins/dns_test_common_lexicon.pyt   <module>   s   