def test_json_resp_type_token(self): ar = AuthorizationRequest(response_type=["token"], client_id="s6BhdRkqt3", redirect_uri="https://client.example.com/cb", state="xyz") ue_obj = json.loads(ar.serialize(method="json")) expected_ue_obj = { "state": "xyz", "redirect_uri": "https://client.example.com/cb", "response_type": "token", "client_id": "s6BhdRkqt3" } assert ue_obj == expected_ue_obj
def test_json_multiple_params(self): ar = AuthorizationRequest( response_type=["code"], client_id="foobar", redirect_uri="http://foobar.example.com/oaclient", state="cold") ue_obj = json.loads(ar.serialize(method="json")) expected_ue_obj = { "response_type": "code", "state": "cold", "redirect_uri": "http://foobar.example.com/oaclient", "client_id": "foobar" } assert ue_obj == expected_ue_obj
def test_json_serizalize_deserialize_multiple_params(self): argv = { "scope": ["openid"], "state": "id-b0be8bb64118c3ec5f70093a1174b039", "redirect_uri": "http://localhost:8087authz", "response_type": ["code"], "client_id": "a1b2c3" } arq = AuthorizationRequest(**argv) jstr = arq.serialize(method="json") jarq = AuthorizationRequest().deserialize(jstr, "json") assert jarq["scope"] == ["openid"] assert jarq["response_type"] == ["code"] assert jarq["redirect_uri"] == "http://localhost:8087authz" assert jarq["state"] == "id-b0be8bb64118c3ec5f70093a1174b039" assert jarq["client_id"] == "a1b2c3"
def test_json_serialize_deserialize(self): ar = AuthorizationRequest(response_type=["code"], client_id="foobar") jtxt = ar.serialize(method="json") ar2 = AuthorizationRequest().deserialize(jtxt, "json") assert ar == ar2
def test_req_json_serialize(self): ar = AuthorizationRequest(response_type=["code"], client_id="foobar") js_obj = json.loads(ar.serialize(method="json")) expected_js_obj = {"response_type": "code", "client_id": "foobar"} assert js_obj == expected_js_obj