404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.116.27.25: ~ $
3

�}:aF!�@s�dZddlZddlZddlmZddlZddlmZmZmZm	Z	m
Z
e
jd�Ze	j
je
jd��ZGdd�dej�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZGdd�dej�Zedkr�ej�dS)zTests for josepy.jws.�N)�mock)�errors�	json_util�jwa�jwk�	test_utilzcert.pemzrsa512_key.pemc@s eZdZdZdd�Zdd�ZdS)�
MediaTypeTestzTests for josepy.jws.MediaType.cCsFddlm}|jd|jd��|jd|jd��|jtj|jd�dS)Nr)�	MediaTypezapplication/app�appzapp;foo)�
josepy.jwsr	�assertEqual�decode�assertRaisesr�DeserializationError)�selfr	�r�/usr/lib/python3.6/jws_test.py�test_decodes
zMediaTypeTest.test_decodecCs4ddlm}|jd|jd��|jd|jd��dS)Nr)r	r
zapplication/appzapplication/app;foo)rr	r�encode)rr	rrr�test_encodeszMediaTypeTest.test_encodeN)�__name__�
__module__�__qualname__�__doc__rrrrrrrsrc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�
HeaderTestzTests for josepy.jws.Header.cCs<ddlm}|dd�|_|dd�|_|d	d�|_|�|_dS)
Nr)�Header�foo)r�bar�a�b)�crit)rr)rr�header1�header2r �empty)rrrrr�setUp"s
zHeaderTest.setUpcCs,ddlm}|j|ddd�|j|j�dS)Nr)rrrr)rr )rr)rrrr!r )rrrrr�test_add_non_empty)szHeaderTest.test_add_non_emptycCs0|j|j|j|j�|j|j|j|j�dS)N)rr!r#)rrrr�test_add_empty.szHeaderTest.test_add_emptycCs|jt|jj|j�dS)N)r�	TypeErrorr!�__add__r")rrrr�test_add_overlapping_error2sz%HeaderTest.test_add_overlapping_errorcCs|jt|jjd�dS)NZxxx)rr'r!r()rrrr�test_add_wrong_type_error5sz$HeaderTest.test_add_wrong_type_errorcCs*ddlm}|jtj|jdddgi�dS)Nr)rr rr)rrrrr�	from_json)rrrrr�test_crit_decode_always_errors8sz)HeaderTest.test_crit_decode_always_errorscCs�ddlm}|ttfd�}|j�}tjjtjjtj�}t	j
|�}|j|d||gi�|j||j|��t	j
d|�|dd<|j
tj|j|�dS)Nr)r)�x5cr-sxxx)rr�CERT�to_partial_json�OpenSSLZcryptoZdump_certificateZ
FILETYPE_ASN1�wrapped�base64Z	b64encoderr+rrr)rr�headerZjobjZ	cert_asn1Zcert_b64rrr�test_x5c_decoding=s
zHeaderTest.test_x5c_decodingcCs:|jd|jj��|jd|jj��|jtj|jj�dS)Nrr)rr!Zfind_keyr"rr�Errorr )rrrr�
test_find_keyIszHeaderTest.test_find_keyN)rrrrr$r%r&r)r*r,r4r6rrrrrsrc@s eZdZdZdd�Zdd�ZdS)�
SignatureTestzTests for josepy.jws.Signature.cCsHddlm}ddlm}|j|d|tjd�d�|jddd	id���dS)
Nr)r)�	Signaturesfoo)�alg)�	signaturer3ZZm9vr9�RS256)rrr8rrr;r+)rrr8rrr�test_from_jsonRszSignatureTest.test_from_jsoncCs&ddlm}|jtj|jddi�dS)Nr)r8r:r)rr8rrrr+)rr8rrr�test_from_json_no_alg_errorZsz)SignatureTest.test_from_json_no_alg_errorN)rrrrr<r=rrrrr7Osr7c@speZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�JWSTestzTests for josepy.jws.JWS.cCsvt|_|jj�|_ddlm}|jd|jtjd�|_	|jd|jtjt
ddg�d�|_|jd|jtjt
dg�d�|_dS)Nr)�JWSsfoo)�payload�keyr9rr9)r@rAr9Zprotect)
�KEYZprivkeyZ
public_key�pubkeyrr?�signrr;�unprotected�	frozenset�	protected�mixed)rr?rrrr$cs

z
JWSTest.setUpcCsF|j|jjjj|j�|j|jjjj|j�|j|jjjj|j�dS)N)rrEr:�combinedrrCrGrH)rrrr�test_pubkey_jwkqszJWSTest.test_pubkey_jwkcCs|j|jj�d�dS)NT)�assertIsrE�verify)rrrr�test_sign_unprotectedvszJWSTest.test_sign_unprotectedcCs|j|jj�d�dS)NT)rKrGrL)rrrr�test_sign_protectedyszJWSTest.test_sign_protectedcCs|j|jj�d�dS)NT)rKrHrL)rrrr�test_sign_mixed|szJWSTest.test_sign_mixedcCsX|jj�}|jd|�ddlm}|j|�}|j|j|�|jdht|jj	j
���dS)NsreyJhbGciOiAiUlMyNTYifQ.Zm9v.OHdxFVj73l5LpxbFp1AmYX4yJM0Pyb_893n1zQjpim_eLS5J1F61lkvrCrCDErTEJnBGOGesJ72M7b6Ve1cAJAr)r?r9)rHZ
to_compactrrr?�from_compactZassertNotEqual�setr:rIZnot_omitted)rZcompactr?rHrrr�test_compact_lost_unprotecteds

z%JWSTest.test_compact_lost_unprotectedcCs"ddlm}|jtj|jd�dS)Nr)r?�.)rr?rrrrP)rr?rrr�$test_from_compact_missing_components�sz,JWSTest.test_from_compact_missing_componentscCs||jjdd�}|jjdd�}|jd|�|jd|�|dj�|d<ddlm}|j|j|�|j�|j|j|�|j�dS)NT)�flatrGr3r)r?)	rGr/rEZassertNotIn�to_jsonrr?rr+)rZprotected_jobjZunprotected_jobjr?rrr�test_json_omitempty�szJWSTest.test_json_omitemptycCs�tj|jjj�tjd�|jjjtj|jjjjd��d�}|j�}|dj�|d<|j	|jj
dd�|�ddlm}|j	|j|j
|��dS)	Nsfoozutf-8)r:r@r3rGr3T)rUr)r?)r�encode_b64joserHr:r3rGr�copyrVrr/rr?r+)r�jobj_to�	jobj_fromr?rrr�test_json_flat�s
zJWSTest.test_json_flatcCsn|jjftjd�d�}|j�}|ddj�g|d<|j|jjdd�|�ddlm	}|j|j|j
|��dS)Nsfoo)�
signaturesr@r]rF)rU)r?)rHr:rrXrYrVrr/rr?r+)rrZr[r?rrr�test_json_not_flat�szJWSTest.test_json_not_flatcCs(ddlm}|jtj|jfdd��dS)Nr)r?r)r]r:)rr?rrrr+)rr?rrr�test_from_json_mixed_flat�sz!JWSTest.test_from_json_mixed_flatcCs$ddlm}t|j|jj���dS)Nr)r?)rr?�hashr+rHrV)rr?rrr�test_from_json_hashable�szJWSTest.test_from_json_hashableN)rrrrr$rJrMrNrOrRrTrWr\r^r_rarrrrr>`s

r>c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�CLITestcCstjd�|_dS)Nzrsa512_key.pem)rZvector_path�key_path)rrrrr$�sz
CLITest.setUpcCsXddlm}tjd��8}d|j_tjd��|jd|jdg��WdQRXWdQRXdS)	Nr)�CLIz	sys.stdinz&{"payload": "foo", "signature": "xxx"}z
sys.stdout�rL���)rrdr�patch�read�return_valuer�run)rrd�sinrrr�test_unverified�s
zCLITest.test_unverifiedcCs�ddlm}tjd��j}d|j_tjd��L}|jdd|jdd	d
dg�|jj	ddd|j_|j
d|jd
g��WdQRXWdQRXdS)Nr)rdz	sys.stdinrz
sys.stdoutrDz-kz-ar;z-prrerL)rrdrrgrhrirjrc�write�
mock_callsr)rrdrk�soutrrr�	test_json�s
zCLITest.test_jsoncCs�ddlm}tjd��p}d|j_tjd��R}|jddd|jg�|jj	dd	d|j_|j
d|jdd
ddd|jg��WdQRXWdQRXdS)
Nr)rdz	sys.stdinrz
sys.stdoutz	--compactrDz-krerLz--ktyZRSA)rrdrrgrhrirjrcrmrnr)rrdrkrorrr�test_compact�s
zCLITest.test_compactN)rrrr$rlrprqrrrrrb�srb�__main__)rr2Zunittestrr0ZjosepyrrrrrZload_comparable_certr.ZJWKRSA�loadZload_vectorrBZTestCaserrr7r>rbr�mainrrrr�<module>s
0c$

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 1.95 KB 0644
__init__.cpython-36.pyc File 1.95 KB 0644
b64.cpython-36.opt-1.pyc File 1.56 KB 0644
b64.cpython-36.pyc File 1.56 KB 0644
b64_test.cpython-36.opt-1.pyc File 3.47 KB 0644
b64_test.cpython-36.pyc File 3.47 KB 0644
errors.cpython-36.opt-1.pyc File 1.55 KB 0644
errors.cpython-36.pyc File 1.55 KB 0644
errors_test.cpython-36.opt-1.pyc File 854 B 0644
errors_test.cpython-36.pyc File 854 B 0644
interfaces.cpython-36.opt-1.pyc File 7.93 KB 0644
interfaces.cpython-36.pyc File 7.93 KB 0644
interfaces_test.cpython-36.opt-1.pyc File 5.38 KB 0644
interfaces_test.cpython-36.pyc File 5.38 KB 0644
json_util.cpython-36.opt-1.pyc File 14.93 KB 0644
json_util.cpython-36.pyc File 14.93 KB 0644
json_util_test.cpython-36.opt-1.pyc File 17.19 KB 0644
json_util_test.cpython-36.pyc File 17.19 KB 0644
jwa.cpython-36.opt-1.pyc File 7.73 KB 0644
jwa.cpython-36.pyc File 7.73 KB 0644
jwa_test.cpython-36.opt-1.pyc File 9.67 KB 0644
jwa_test.cpython-36.pyc File 9.67 KB 0644
jwk.cpython-36.opt-1.pyc File 11.66 KB 0644
jwk.cpython-36.pyc File 11.66 KB 0644
jwk_test.cpython-36.opt-1.pyc File 12.73 KB 0644
jwk_test.cpython-36.pyc File 12.73 KB 0644
jws.cpython-36.opt-1.pyc File 12.1 KB 0644
jws.cpython-36.pyc File 12.49 KB 0644
jws_test.cpython-36.opt-1.pyc File 9.4 KB 0644
jws_test.cpython-36.pyc File 9.4 KB 0644
magic_typing.cpython-36.opt-1.pyc File 775 B 0644
magic_typing.cpython-36.pyc File 775 B 0644
magic_typing_test.cpython-36.opt-1.pyc File 1.07 KB 0644
magic_typing_test.cpython-36.pyc File 1.07 KB 0644
test_util.cpython-36.opt-1.pyc File 2.77 KB 0644
test_util.cpython-36.pyc File 2.77 KB 0644
util.cpython-36.opt-1.pyc File 9.76 KB 0644
util.cpython-36.pyc File 9.84 KB 0644
util_test.cpython-36.opt-1.pyc File 11.62 KB 0644
util_test.cpython-36.pyc File 11.62 KB 0644