a U¸mgdã@srddlZddlmmZddlZddlmZddl m Z ej dd„ƒZ ej dd„ƒZ dd „Zd d „Zd d „ZdS)éN)Ú TestClient)ÚappcCs0ttƒ}|WdƒS1s"0YdS)N)rr)Úclient©rúN/home/cmiss/Jenkins/workspace/12-Labours-API/tests/test_api/test_access_api.pyrs rcCs"ddddœ}|jd|d}| ¡S)Núdummy_email@gmail.comÚdummy_machine_idÚdummy_expiration_time©ÚemailÚmachineZ expirationú /access/token©Újson)Úpostr)rÚ dummy_dataÚresponserrrÚtoken s ýrcCsDi}|jd|d}| ¡}|j}d}||k}|s˜t d|fd||f¡dt ¡vsZt |¡rdt |¡ndt |¡t |¡dœ}dd |i}t t  |¡ƒ‚d}}}|d } d }| |k} | st d| fd | |f¡t | ¡t |¡d œ} dd| i} t t  | ¡ƒ‚d} } }ddddœ} |jd| d}| ¡}|j}d}||k}|s¶t d|fd||f¡dt ¡vsxt |¡r‚t |¡ndt |¡t |¡dœ}dd |i}t t  |¡ƒ‚d}}}d} | |v} | s8t d| fd| |f¡t | ¡dt ¡vs t |¡rt |¡nddœ}dd|i}t t  |¡ƒ‚d} } dS)Nr ri©ú==©z3%(py2)s {%(py2)s = %(py0)s.status_code } == %(py5)sr©Úpy0Úpy2Úpy5úassert %(py7)sÚpy7Zdetailz.Missing one or more fields in the request body©z%(py1)s == %(py4)s©Úpy1Úpy4úassert %(py6)sÚpy6rrr r éÈÚ access_token©Úin©z%(py1)s in %(py3)sÚresult©rZpy3úassert %(py5)sr) rrÚ status_codeÚ @pytest_arÚ_call_reprcompareÚ @py_builtinsÚlocalsÚ_should_repr_global_nameÚ _safereprÚAssertionErrorÚ_format_explanation)rZ missing_datarr(Ú @py_assert1Ú @py_assert4Ú @py_assert3Ú @py_format6Ú @py_format8Ú @py_assert0Ú @py_assert2Ú @py_format5Ú @py_format7rÚ @py_format4rrrÚtest_create_accesssŠlýr>c Cs,|jddd|d›id}| ¡}|j}d}||k}|s¢t d|fd||f¡d t ¡vsdt |¡rnt |¡nd t |¡t |¡d œ}d d |i}t t  |¡ƒ‚d}}}d } | |v} | s t d| fd| |f¡t | ¡dt ¡vsòt |¡rüt |¡nddœ} dd| i}t t  |¡ƒ‚d} } dS)Nz/access/oneoffÚ AuthorizationúBearer r$©Úheadersr#rrrrrrZ one_off_tokenr%r'r(r)r*r) Úgetrr+r,r-r.r/r0r1r2r3) rrrr(r4r5r6r7r8r9r:r=rrrÚtest_create_one_off_access*sþŠrDc Cs|jddd|d›id}| ¡}|j}d}||k}|s¢t d|fd||f¡d t ¡vsdt |¡rnt |¡nd t |¡t |¡d œ}d d |i}t t  |¡ƒ‚d}}}|d } d}| |k} | st d| fd| |f¡t | ¡t |¡dœ} dd| i} t t  | ¡ƒ‚d} } }dS)Nz/access/revoker?r@r$rAr#rrrrrrÚmessagez)Unable to remove default access authorityrrr!r") Údeleterr+r,r-r.r/r0r1r2r3) rrrr(r4r5r6r7r8r9r:r;r<rrrÚtest_revoke_access4sþŠrG)Úbuiltinsr.Ú_pytest.assertion.rewriteÚ assertionÚrewriter,ÚpytestZfastapi.testclientrZapp.mainrÚfixturerrr>rDrGrrrrÚs"