ó
ÁĢô_c           @   s  d  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 e j j e j d   Z e j d  Z e j d d	  Z e j d d
  Z e j d d  Z e e g Z d   Z d   Z e e e j  Z e e e j  Z e e e j  Z e e g Z e	 j e e d  Z e	 j e e d  Z e	 j e e d  Z e e g Z  e! d  Z" d S(   s   ACME utilities for testing.iĸĸĸĸN(   t
   challenges(   t   messages(   t   auth_handler(   t   utils   rsa512_key.pemt   tokens+   evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ+PCt92wr+oAt    17817c66b60ce2e4012dfad92657527at    cafecafecafecafecafecafe0feedbacc         C   s   t  d   t |   D  S(   s*   Generate natural combinations for challbs.c         s   s   |  ] \ } } | f Vq d  S(   N(    (   t   .0t   it   _(    (    s;   /usr/lib/python2.7/site-packages/certbot/tests/acme_util.pys	   <genexpr>   s    (   t   tuplet	   enumerate(   t   challbs(    (    s;   /usr/lib/python2.7/site-packages/certbot/tests/acme_util.pyt
   gen_combos   s    c         C   s^   i |  d 6|  j  d d 6| d 6} | t j k rQ | j i t j j   d 6 n  t j |   S(   s$   Return ChallengeBody from Challenge.t   challt   _urit   urit   statust	   validated(   t   typR   t   STATUS_VALIDt   updatet   datetimet   nowt   ChallengeBody(   R   R   t   kwargs(    (    s;   /usr/lib/python2.7/site-packages/certbot/tests/acme_util.pyt   chall_to_challb   s    
 s   example.coms   example.orgs   esimerkki.example.orgc         C   sę   t  d   t j j | |  D  } i t j d t j d |  d 6| d 6} | rq | j i t |  d 6 n  |  t j	 k r· | j i |  d 6t
 j
 j   t
 j d d	  d
 6 n | j i |  d 6 t j d d d t j |    S(   s&  Generate an authorization resource.

    :param authz_status: Status object
    :type authz_status: :class:`acme.messages.Status`
    :param list challs: Challenge objects
    :param list statuses: status of each challenge object
    :param bool combos: Whether or not to add combinations

    c         s   s$   |  ] \ } } t  | |  Vq d  S(   N(   R   (   R   R   R   (    (    s;   /usr/lib/python2.7/site-packages/certbot/tests/acme_util.pys	   <genexpr>G   s   R   t   valuet
   identifierR    t   combinationsR   t   daysi   t   expiresR   s%   https://trusted.ca/new-authz-resourcet   body(   R
   t   sixt   movest   zipR   t
   Identifiert   IDENTIFIER_FQDNR   R   R   R   R   t	   timedeltat   AuthorizationResourcet   Authorization(   t   authz_statust   domaint   challst   statusest   combosR   t   authz_kwargs(    (    s;   /usr/lib/python2.7/site-packages/certbot/tests/acme_util.pyt
   gen_authzr<   s$    
	
	'		(#   t   __doc__R   t   josepyt   joseR!   t   acmeR    R   t   certbot._internalR   t   certbot.testsR   t   JWKt   loadt   load_vectort   load_rsa_private_keyt   KEYt   HTTP01t   DNS01t   DNS01_2t
   CHALLENGESR   R   t   STATUS_PENDINGt   HTTP01_Pt   DNS01_Pt	   DNS01_P_2t   CHALLENGES_Pt   challb_to_achallt   HTTP01_At   DNS01_At	   DNS01_A_2t   ACHALLENGESt   TrueR/   (    (    (    s;   /usr/lib/python2.7/site-packages/certbot/tests/acme_util.pyt   <module>   s2   				