a Փ?gd@srddlZddlmmZddlZddlmZddl m Z ej ddZ ej ddZ dd Zd d Zd d ZdS)N) TestClient)appcCs0tt}|WdS1s"0YdS)N)rr)clientrN/home/cmiss/Jenkins/workspace/12-Labours-API/tests/test_api/test_access_api.pyrs rcCs"dddd}|jd|d}|S)Ndummy_email@gmail.comdummy_machine_iddummy_expiration_timeemailmachineZ expiration /access/tokenjson)postr)r dummy_dataresponserrrtoken s rcCsDi}|jd|d}|}|j}d}||k}|std|fd||fdtvsZt|rdt|ndt|t|d}dd |i}t t |d}}}|d } d }| |k} | std| fd | |ft| t|d } dd| i} t t | d} } }dddd} |jd| d}|}|j}d}||k}|std|fd||fdtvsxt|rt|ndt|t|d}dd |i}t t |d}}}d} | |v} | s8td| fd| |ft| dtvs t|rt|ndd}dd|i}t t |d} } dS)Nr ri==z3%(py2)s {%(py2)s = %(py0)s.status_code } == %(py5)srpy0py2py5assert %(py7)spy7Zdetailz.Missing one or more fields in the request bodyz%(py1)s == %(py4)spy1py4assert %(py6)spy6rrr r access_tokeninz%(py1)s in %(py3)sresultrZpy3assert %(py5)sr) rr status_code @pytest_ar_call_reprcompare @py_builtinslocals_should_repr_global_name _safereprAssertionError_format_explanation)rZ missing_datarr( @py_assert1 @py_assert4 @py_assert3 @py_format6 @py_format8 @py_assert0 @py_assert2 @py_format5 @py_format7r @py_format4rrrtest_create_accessslr>c Cs,|jddd|did}|}|j}d}||k}|std|fd||fd tvsdt|rnt|nd t|t|d }d d |i}t t |d}}}d } | |v} | s td| fd| |ft| dtvst|rt|ndd} dd| i}t t |d} } dS)Nz/access/oneoff AuthorizationBearer r$headersr#rrrrrrZ one_off_tokenr%r'r(r)r*r) getrr+r,r-r.r/r0r1r2r3) rrrr(r4r5r6r7r8r9r:r=rrrtest_create_one_off_access*srDc Cs|jddd|did}|}|j}d}||k}|std|fd||fd tvsdt|rnt|nd t|t|d }d d |i}t t |d}}}|d } d}| |k} | std| fd| |ft| t|d} dd| i} t t | d} } }dS)Nz/access/revoker?r@r$rAr#rrrrrrmessagez)Unable to remove default access authorityrrr!r") deleterr+r,r-r.r/r0r1r2r3) rrrr(r4r5r6r7r8r9r:r;r<rrrtest_revoke_access4srG)builtinsr._pytest.assertion.rewrite assertionrewriter,pytestZfastapi.testclientrZapp.mainrfixturerrr>rDrGrrrrs"