def test_c2(): cc = ClaimsClient(client_id="client_1") cc.client_secret = "hemlig" cc.userclaims_endpoint = "https://example.com/claims" request = UserClaimsRequest method = "POST" request_args = {"sub": "norah", "claims_names": ["gender", "birthdate"]} cc.request_info(request, method=method, request_args=request_args)
class TestClaimsClient(object): @pytest.fixture(autouse=True) def create_claims_client(self): self.cc = ClaimsClient(client_id="client_1") self.cc.client_secret = "hemlig" self.cc.userclaims_endpoint = "https://example.com/claims" def test_construct_UserClaimsRequest(self): req = self.cc.construct_UserClaimsRequest( request_args={ "sub": "norah", "claims_names": ["gender", "birthdate"] }) assert isinstance(req, UserClaimsRequest) assert _eq(req.keys(), ['client_secret', 'claims_names', 'sub', 'client_id']) assert req["sub"] == "norah" assert req["client_id"] == "client_1" def test_request_info(self): request_args = { "sub": "norah", "claims_names": ["gender", "birthdate"] } uri, body, headers, ucr = self.cc.request_info( UserClaimsRequest, method="POST", request_args=request_args) assert uri == "https://example.com/claims" assert query_string_compare( body, "claims_names=gender+birthdate&sub=norah&client_id=client_1&client_secret=hemlig" )
class TestClaimsClient(object): @pytest.fixture(autouse=True) def create_claims_client(self): self.cc = ClaimsClient(client_id="client_1") self.cc.client_secret = "hemlig" self.cc.userclaims_endpoint = "https://example.com/claims" def test_construct_UserClaimsRequest(self): req = self.cc.construct_UserClaimsRequest(request_args={"sub": "norah", "claims_names": [ "gender", "birthdate"]}) assert isinstance(req, UserClaimsRequest) assert _eq(req.keys(), ['client_secret', 'claims_names', 'sub', 'client_id']) assert req["sub"] == "norah" assert req["client_id"] == "client_1" def test_request_info(self): request_args = {"sub": "norah", "claims_names": ["gender", "birthdate"]} uri, body, headers, ucr = self.cc.request_info(UserClaimsRequest, method="POST", request_args=request_args) assert uri == "https://example.com/claims" assert query_string_compare(body, "claims_names=gender+birthdate&sub=norah&client_id=client_1&client_secret=hemlig")