3
pYWb                 @   sv   d dl mZ d dlZd dljjZd dlZd dl	m
Z
mZ d dl	mZmZ d dlmZ d dlmZ G dd dejZdS )	    )unicode_literalsN)WebApplicationClientMobileApplicationClient)LegacyApplicationClientBackendApplicationClient)Request)OAuth2c               @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )OAuth2AuthTestc             C   s>   dddd| _ d| _t| jt| jt| jt| jg| _d S )NBearerZasdfoiw37850234lkjsdfsdfZ3600)
token_typeaccess_token
expires_infoo)tokenZ	client_idr   r   r   r   clients)self r   H/Users/singingwolfboy/clones/requests-oauthlib/tests/test_oauth2_auth.pysetUp   s    
zOAuth2AuthTest.setUpc             C   s^   d}|d | j d  }xB| jD ]8}d|_t|| j d}td||dj }| j|j| qW d S )Nz$https://example.com/resource?foo=barz&access_token=r   query)clientr   GET)auth)r   r   default_token_placementr   r   prepareassertEqualurl)r   r   Znew_urlr   r   rr   r   r   test_add_token_to_url   s    z$OAuth2AuthTest.test_add_token_to_urlc             C   sT   d| j d  }x@| jD ]6}t|| j d}tdd|dj }| j|jd | qW d S )NzBearer r   )r   r   r   zhttps://i.b)r   Authorization)r   r   r   r   r   r   headers)r   r   r   r   r   r   r   r   test_add_token_to_headers#   s
    z(OAuth2AuthTest.test_add_token_to_headersc             C   s`   d}|d | j d  }xD| jD ]:}d|_t|| j d}tdd||dj }| j|j| qW d S )	Nzfoo=barz&access_token=r   body)r   r   r   zhttps://i.b)datar   )r   r   r   r   r   r   r   r"   )r   r"   Znew_bodyr   r   r   r   r   r   test_add_token_to_body*   s    z%OAuth2AuthTest.test_add_token_to_bodyc             C   s:   x4| j D ]*}t|d}tdd|d}| jt|j qW d S )N)r   r   zhttps://i.b)r   )r   r   r   assertRaises
ValueErrorr   )r   r   r   r   r   r   r   test_add_nonexisting_token3   s    
z)OAuth2AuthTest.test_add_nonexisting_tokenN)__name__
__module____qualname__r   r   r!   r$   r'   r   r   r   r   r	   
   s
   		r	   )
__future__r   builtins@py_builtins_pytest.assertion.rewrite	assertionrewrite
@pytest_arunittestZoauthlib.oauth2r   r   r   r   requestsr   requests_oauthlibr   TestCaser	   r   r   r   r   <module>   s     