404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@52.15.209.178: ~ $
3

�}:aV7�@s�dZddlZddlZddlmZddlmZmZmZmZej	d�Z
ejd�ZGdd�dej
�ZGd	d
�d
ej
�ZGdd�dej
�ZGd
d�dej
�ZGdd�dej
�Zedkr�ej�dS)zTests for josepy.json_util.�N)�mock)�errors�
interfaces�	test_util�utilzcert.pemzcsr.pemc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�	FieldTestz!Tests for josepy.json_util.Field.cCsVddlm}xDtjddgddgddg�D]&\}}}|j|d||d�j|�d�q(WdS)Nr)�FieldTF�foo)�default�	omitempty)�josepy.json_utilr�	itertools�product�assertIsZomit)�selfrr
r�value�r�$/usr/lib/python3.6/json_util_test.py�test_no_omit_booleans
 zFieldTest.test_no_omit_booleancCsztj�}dd�}dd�}ddlm}|d�}|j|�}|jd|j|��|j|�}|jd|j|��|jd	|j|��dS)
NcSsdS)N�dr)�unused_valuerrr�decodersz+FieldTest.test_descriptors.<locals>.decodercSsdS)N�er)rrrr�encodersz+FieldTest.test_descriptors.<locals>.encoderr)rr	rr)	r�	MagicMockrrr�assertEqual�encoder�decode)r�
mock_valuerrr�fieldrrr�test_descriptorss

zFieldTest.test_descriptorscCsLGdd�dtj�}|�}ddlm}|j|j|�|�|jd|j|��dS)Nc@s eZdZdd�Zedd��ZdS)z<FieldTest.test_default_encoder_is_partial.<locals>.MockFieldcSsdS)Nr	r)rrrr�to_partial_json.szLFieldTest.test_default_encoder_is_partial.<locals>.MockField.to_partial_jsoncSsdS)Nr)�cls�jobjrrr�	from_json1szFFieldTest.test_default_encoder_is_partial.<locals>.MockField.from_jsonN)�__name__�
__module__�__qualname__r!�classmethodr$rrrr�	MockField,sr)r)rr	)rZJSONDeSerializablerrr�default_encoderZassertNotEqual)rr)Z
mock_fieldrrrr�test_default_encoder_is_partial+s
z)FieldTest.test_default_encoder_is_partialcCs*tj�}ddlm}|j|j|�|�dS)Nr)r)rrrrrr*)rrrrrr� test_default_encoder_passthrough;sz*FieldTest.test_default_encoder_passthroughcCs(ddlm}|jd|jdddg��dS)Nr)r���)r-r.r/)rrr�default_decoder)rrrrr�"test_default_decoder_list_to_tuple@sz,FieldTest.test_default_decoder_list_to_tuplecCs@ddlm}|jddi�}|j|tj�|j|tjdd��dS)Nr)r�xr.)r2)rrr0�assertIsInstancerZ
frozendictr)rr�objrrr�'test_default_decoder_dict_to_frozendictDsz1FieldTest.test_default_decoder_dict_to_frozendictcCs*tj�}ddlm}|j|j|�|�dS)Nr)r)rrrrrr0)rrrrrr� test_default_decoder_passthroughJsz*FieldTest.test_default_decoder_passthroughN)r%r&r'�__doc__rr r+r,r1r5r6rrrrrsrc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�JSONObjectWithFieldsMetaTestz4Tests for josepy.json_util.JSONObjectWithFieldsMeta.cs~ddlm}ddlm}|d��_|d��_G�fdd�dt|d�}Gd	d
�d
|�}G�fdd�d|�}|�_|�_|�_dS)
Nr)r)�JSONObjectWithFieldsMetaZBazZBaz2cseZdZdZ�jZdS)z-JSONObjectWithFieldsMetaTest.setUp.<locals>.A�barN)r:)r%r&r'�	__slots__r�bazr)rrr�A[sr=)�	metaclassc@seZdZdS)z-JSONObjectWithFieldsMetaTest.setUp.<locals>.BN)r%r&r'rrrr�B_sr?cseZdZ�jZdS)z-JSONObjectWithFieldsMetaTest.setUp.<locals>.CN)r%r&r'�field2r<r)rrr�CbsrA)	rrr9rr@�object�a_cls�b_cls�c_cls)rrr9r=r?rAr)rr�setUpSs

z"JSONObjectWithFieldsMetaTest.setUpcCs0|jd|ji|jj�|jd|ji|jj�dS)Nr<)rrrC�_fieldsrD)rrrr�test_fieldsisz(JSONObjectWithFieldsMetaTest.test_fieldscCs|jd|ji|jj�dS)Nr<)rr@rErG)rrrr�test_fields_inheritancensz4JSONObjectWithFieldsMetaTest.test_fields_inheritancecCs$|jd|jj�|jd|jj�dS)Nr:r<)r:r<)r<)rrCr;rD)rrrr�
test_slotsrsz'JSONObjectWithFieldsMetaTest.test_slotscCs$|jd|jj�|jf|jj�dS)Nr:)r:)rrCZ_orig_slotsrD)rrrr�test_orig_slotsvsz,JSONObjectWithFieldsMetaTest.test_orig_slotsN)	r%r&r'r7rFrHrIrJrKrrrrr8Psr8c@speZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�JSONObjectWithFieldsTestz0Tests for josepy.json_util.JSONObjectWithFields.csFddlm}ddlm�G�fdd�d|�}||_|dddd�|_dS)	Nr)�JSONObjectWithFields)rcsPeZdZ�dddd�dd�d�Z�d�Z�d�Zejd	d
��Zejdd
��ZdS)
z@JSONObjectWithFieldsTest.setUp.<locals>.MockJSONObjectWithFieldsr2TcSs|dS)Nr.r)r2rrr�<lambda>�szIJSONObjectWithFieldsTest.setUp.<locals>.MockJSONObjectWithFields.<lambda>cSs|dS)Nr.r)r2rrrrN�s)rrr�y�ZcSs|dkrtj��|S)Ni�)r�SerializationError)rrrrrO�szBJSONObjectWithFieldsTest.setUp.<locals>.MockJSONObjectWithFields.ycSs|dkrtj��|S)Ni�)r�DeserializationError)rrrrrO�sN)r%r&r'r2rO�zrrr)rrr�MockJSONObjectWithFields�srTr.r/)r2rOrS)rrMrrTr)rrMrTr)rrrF�s
zJSONObjectWithFieldsTest.setUpcCs|j|j|jddd��dS)Nr.r/)rOrS)rrrT)rrrr�test_init_defaults�sz+JSONObjectWithFieldsTest.test_init_defaultscCs"|jd|jdddd�jd��dS)N�
�r)r2rOrSr2)rrTr)rrrr�test_encode�s
z$JSONObjectWithFieldsTest.test_encodecCs|jtj|jjd�dS)Nr	)�assertRaisesr�Errorrr)rrrr�test_encode_wrong_field�sz0JSONObjectWithFieldsTest.test_encode_wrong_fieldcCs |jtj|jddd�jd�dS)Ni�)rOrSrO)rYrrQrTr)rrrr�+test_encode_serialization_error_passthrough�szDJSONObjectWithFieldsTest.test_encode_serialization_error_passthroughcCs|j|jj�ddd��dS)Nr.r/)rOrP)rr�fields_to_partial_json)rrrr�'test_fields_to_partial_json_omits_empty�sz@JSONObjectWithFieldsTest.test_fields_to_partial_json_omits_emptycCs&|jdddd�|jjddd���dS)Nr.r/)r2rOrS)rOrP)rrT�fields_from_json)rrrr�-test_fields_from_json_fills_default_for_empty�s
zFJSONObjectWithFieldsTest.test_fields_from_json_fills_default_for_emptycCsh|jtj|jjddi�|jtj|jjddi�|jtj|jjddd��|jtj|jjddd��dS)NrOrrP)r2rO)r2rP)rYrrRrTr_)rrrr�&test_fields_from_json_fails_on_missing�sz?JSONObjectWithFieldsTest.test_fields_from_json_fails_on_missingcCs(|j|jdddd�j�dddd��dS)Nr-r.r/)r2rOrS)r2rOrP)rrTr!)rrrr�#test_fields_to_partial_json_encoder�sz<JSONObjectWithFieldsTest.test_fields_to_partial_json_encodercCs(|jdddd�|jjdddd���dS)Nr.r/)r2rOrS�)r2rOrP)rrTr_)rrrr�test_fields_from_json_decoder�s
z6JSONObjectWithFieldsTest.test_fields_from_json_decodercCs |jtj|jdddd�j�dS)Nr-i�r/)r2rOrS)rYrrQrTr!)rrrr�-test_fields_to_partial_json_error_passthrough�szFJSONObjectWithFieldsTest.test_fields_to_partial_json_error_passthroughcCs |jtj|jjdddd��dS)Nrci�r/)r2rOrP)rYrrRrTr$)rrrr�'test_fields_from_json_error_passthrough�sz@JSONObjectWithFieldsTest.test_fields_from_json_error_passthroughN)r%r&r'r7rFrUrXr[r\r^r`rarbrdrerfrrrrrL|srLc@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�DeEncodersTestcCsd|_d|_dS)Na�MIIB3jCCAYigAwIBAgICBTkwDQYJKoZIhvcNAQELBQAwdzELMAkGA1UEBhMCVVMxETAPBgNVBAgMCE1pY2hpZ2FuMRIwEAYDVQQHDAlBbm4gQXJib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x�eA)rrjr3�strr)rrj�encodedrrr�test_encode_b64jose�sz"DeEncodersTest.test_encode_b64josecCs0ddlm}|d�}|j|t�|jd|�dS)Nr)�decode_b64joserlrk)rrpr3�bytesr)rrp�decodedrrr�test_decode_b64jose�sz"DeEncodersTest.test_decode_b64josecCs ddlm}|jtj|d�dS)Nr)rpr2)rrprYrrR)rrprrr�!test_decode_b64jose_padding_error�sz0DeEncodersTest.test_decode_b64jose_padding_errorcCsLddlm}|jd|ddd��|jtj|ddd�|jtj|ddd�dS)	Nr)rpsfoo�Zm9vr/)�sizer.rc)rrprrYrrR)rrprrr�test_decode_b64jose_sizesz'DeEncodersTest.test_decode_b64jose_sizecCsRddlm}|jd|dddd��|jd|dddd��|jtj|dd	dd�dS)
Nr)rpsfoorur/T)rv�minimumr.rc)rrprrYrrR)rrprrr� test_decode_b64jose_minimum_sizes

z/DeEncodersTest.test_decode_b64jose_minimum_sizecCs0ddlm}|d�}|jd|�|j|t�dS)Nr)�encode_hex16sfoo�666f6f)rrzrr3rm)rrzrnrrr�test_encode_hex16sz DeEncodersTest.test_encode_hex16cCs0ddlm}|d�}|jd|�|j|t�dS)Nr)�decode_hex16r{sfoo)rr}rr3rq)rr}rrrrr�test_decode_hex16sz DeEncodersTest.test_decode_hex16cCsRddlm}|jd|dddd��|jd|dddd��|jtj|dd	dd�dS)
Nr)r}sfoor{r/T)rvrxr.rc)rr}rrYrrR)rr}rrr�test_decode_hex16_minimum_sizes

z-DeEncodersTest.test_decode_hex16_minimum_sizecCs ddlm}|jtj|d�dS)Nr)r}r2)rr}rYrrR)rr}rrr�test_decode_hex16_odd_length%sz+DeEncodersTest.test_decode_hex16_odd_lengthcCs"ddlm}|j|j|t��dS)Nr)�encode_cert)rr�rrh�CERT)rr�rrr�test_encode_cert)szDeEncodersTest.test_encode_certcCsDddlm}||j�}|j|tj�|j|t�|jt	j
|d�dS)Nr)�decode_cert�)rr�rhr3r�ComparableX509rr�rYrrR)rr�Zcertrrr�test_decode_cert-s

zDeEncodersTest.test_decode_certcCs"ddlm}|j|j|t��dS)Nr)�
encode_csr)rr�rri�CSR)rr�rrr�test_encode_csr4szDeEncodersTest.test_encode_csrcCsDddlm}||j�}|j|tj�|j|t�|jt	j
|d�dS)Nr)�
decode_csrr�)rr�rir3rr�rr�rYrrR)rr�Zcsrrrr�test_decode_csr8s

zDeEncodersTest.test_decode_csrN)r%r&r'rFrorsrtrwryr|r~rr�r�r�r�r�rrrrrg�srgc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TypedJSONObjectWithFieldsTestcCsHddlm}Gdd�d|�}|jGdd�d|��}||_|dd�|_dS)	Nr)�TypedJSONObjectWithFieldsc@seZdZiZdZdS)zPTypedJSONObjectWithFieldsTest.setUp.<locals>.MockParentTypedJSONObjectWithFields�typeN)r%r&r'ZTYPESZtype_field_namerrrr�#MockParentTypedJSONObjectWithFieldsHsr�c@s(eZdZdZdZedd��Zdd�ZdS)	zJTypedJSONObjectWithFieldsTest.setUp.<locals>.MockTypedJSONObjectWithFields�testr	cSsd|diS)Nr	r)r"r#rrrr_Rsz[TypedJSONObjectWithFieldsTest.setUp.<locals>.MockTypedJSONObjectWithFields.fields_from_jsoncSs
d|jiS)Nr	)r	)rrrrr]VszaTypedJSONObjectWithFieldsTest.setUp.<locals>.MockTypedJSONObjectWithFields.fields_to_partial_jsonN)r	)r%r&r'�typr;r(r_r]rrrr�MockTypedJSONObjectWithFieldsLsr�r:)r	)rr��register�
parent_cls�msg)rr�r�r�rrrrFBsz#TypedJSONObjectWithFieldsTest.setUpcCs|j|jj�ddd��dS)Nr�r:)r�r	)rr�r!)rrrr�test_to_partial_json\sz2TypedJSONObjectWithFieldsTest.test_to_partial_jsoncCs.x(gfddgD]}|jtj|jj|�qWdS)NrWZasd)rYrrRr�r$)rrrrr�test_from_json_non_dict_failsbsz;TypedJSONObjectWithFieldsTest.test_from_json_non_dict_failscCs|jtj|jji�dS)N)rYrrRr�r$)rrrr�!test_from_json_dict_no_type_failsgsz?TypedJSONObjectWithFieldsTest.test_from_json_dict_no_type_failscCs|jtj|jjddi�dS)Nr�r:)rYrZUnrecognizedTypeErrorr�r$)rrrr�!test_from_json_unknown_type_failsksz?TypedJSONObjectWithFieldsTest.test_from_json_unknown_type_failscCs"|jddi|jjddd���dS)Nr	r:r�)r�r	)rr�r$)rrrr�test_from_json_returns_objosz8TypedJSONObjectWithFieldsTest.test_from_json_returns_objN)	r%r&r'rFr�r�r�r�r�rrrrr�@sr��__main__)r7r
ZunittestrZjosepyrrrrZload_comparable_certr�Zload_comparable_csrr�ZTestCaserr8rLrgr�r%�mainrrrr�<module>s

D,]g4

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