U
    ]f                     @   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edZedZejdd	Zejd
d	Zejdd	ZeegZdd Zdd ZeeejZeeejZeeejZeegZe	eedZe	eedZe	eedZeegZ dddZ!dS )zACME utilities for testing.    N)
challenges)messages)auth_handler)utilzrsa512_key.pems+   evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ+PCt92wr+oA)tokens    17817c66b60ce2e4012dfad92657527as    cafecafecafecafecafecafe0feedbacc                 C   s   t dd t| D S )z*Generate natural combinations for challbs.c                 s   s   | ]\}}|fV  qd S N ).0i_r   r   9/usr/lib/python3/dist-packages/certbot/tests/acme_util.py	<genexpr>   s     zgen_combos.<locals>.<genexpr>)tuple	enumerate)challbsr   r   r   
gen_combos   s    r   c                 C   s<   | | j d |d}|tjkr0|dtj i tjf |S )z$Return ChallengeBody from Challenge.Z_uri)challuristatusZ	validated)typr   STATUS_VALIDupdatedatetimenowZChallengeBody)r   r   kwargsr   r   r   chall_to_challb!   s    
r   zexample.comzexample.orgzesimerkki.example.orgTc                 C   s   t dd tj||D }tjtj|d|d}|rH|dt|i | tj	krv|| t
j
 t
jdd d n|d	| i tjd
tjf |dS )a&  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 r   )r   )r	   r   r   r   r   r   r   J   s   zgen_authzr.<locals>.<genexpr>)r   value)Z
identifierr   combinations   )Zdays)r   Zexpiresr   z%https://trusted.ca/new-authz-resource)r   Zbody)r   sixZmoveszipr   Z
IdentifierZIDENTIFIER_FQDNr   r   r   r   r   Z	timedeltaZAuthorizationResourceZAuthorization)Zauthz_statusZdomainZchallsZstatusesZcombosr   Zauthz_kwargsr   r   r   
gen_authzr?   s0     

 
r!   )T)"__doc__r   ZjosepyZjoser   Zacmer   r   Zcertbotr   Zcertbot.testsr   ZJWKloadZload_vectorZload_rsa_private_keyZKEYZHTTP01ZDNS01ZDNS01_2Z
CHALLENGESr   r   ZSTATUS_PENDINGZHTTP01_PZDNS01_PZ	DNS01_P_2ZCHALLENGES_PZchallb_to_achallZHTTP01_AZDNS01_AZ	DNS01_A_2ZACHALLENGESr!   r   r   r   r   <module>   s4   
