def test_dynamic_setup(self): user_id = 'acct:[email protected]' _link = Link(rel="http://openid.net/specs/connect/1.0/issuer", href="https://server.example.com") webfinger_response = JRD(subject=user_id, links=[_link]) self.mock_op.register_get_response( '/.well-known/webfinger', webfinger_response.to_json(), 200, {'content-type': "application/json"}) resp = { "authorization_endpoint": "https://server.example.com/connect/authorize", "issuer": "https://server.example.com", "subject_types_supported": ['public'], "token_endpoint": "https://server.example.com/connect/token", "token_endpoint_auth_methods_supported": ["client_secret_basic", "private_key_jwt"], "userinfo_endpoint": "https://server.example.com/connect/user", "check_id_endpoint": "https://server.example.com/connect/check_id", "refresh_session_endpoint": "https://server.example.com/connect/refresh_session", "end_session_endpoint": "https://server.example.com/connect/end_session", "jwks_uri": "https://server.example.com/jwk.json", "registration_endpoint": "https://server.example.com/connect/register", "scopes_supported": ["openid", "profile", "email", "address", "phone"], "response_types_supported": ["code", "code id_token", "token id_token"], "acrs_supported": ["1", "2", "http://id.incommon.org/assurance/bronze"], "user_id_types_supported": ["public", "pairwise"], "userinfo_algs_supported": ["HS256", "RS256", "A128CBC", "A128KW", "RSA1_5"], "id_token_signing_alg_values_supported": ["HS256", "RS256", "A128CBC", "A128KW", "RSA1_5"], "request_object_algs_supported": ["HS256", "RS256", "A128CBC", "A128KW", "RSA1_5"] } pcr = ProviderConfigurationResponse(**resp) self.mock_op.register_get_response( '/.well-known/openid-configuration', pcr.to_json(), 200, {'content-type': "application/json"}) self.mock_op.register_post_response( '/connect/register', registration_callback, 200, {'content-type': "application/json"}) auth_query = self.rph.begin(user_id=user_id) assert auth_query
def test_jrd(): jrd = JRD(subject="acct:[email protected]", aliases=["http://www.example.com/~bob/"], properties={"http://example.com/ns/role/": "employee"}, links=[ Link(rel="http://webfinger.net/rel/avatar", type="image/jpeg", href="http://www.example.com/~bob/bob.jpg"), Link(rel="http://webfinger.net/rel/profile-page", href="http://www.example.com/~bob/") ]) assert set(jrd.keys()) == {'subject', 'aliases', 'properties', 'links'}
def test_jrd2(): ex0 = { "subject": "acct:[email protected]", "aliases": ["http://www.example.com/~bob/"], "properties": { "http://example.com/ns/role/": "employee" }, "links": [{ "rel": "http://webfinger.net/rel/avatar", "type": "image/jpeg", "href": "http://www.example.com/~bob/bob.jpg" }, { "rel": "http://webfinger.net/rel/profile-page", "href": "http://www.example.com/~bob/" }, { "rel": "blog", "type": "text/html", "href": "http://blogs.example.com/bob/", "titles": { "en-us": "The Magical World of Bob", "fr": "Le monde magique de Bob" } }, { "rel": "vcard", "href": "https://www.example.com/~bob/bob.vcf" }] } jrd0 = JRD().from_json(json.dumps(ex0)) for link in jrd0["links"]: if link["rel"] == "blog": assert link["href"] == "http://blogs.example.com/bob/" break
def do_response(self, response_args=None, request=None, **kwargs): """ **Placeholder for the time being** :param response_args: :param request: :param kwargs: request arguments :return: Response information """ links = [Link(href=h, rel=OIC_ISSUER) for h in kwargs["hrefs"]] _response = JRD(subject=kwargs["subject"], links=links) info = { "response": _response.to_json(), "http_headers": [("Content-type", "application/json")], } return info
def do_response(self, response_args=None, request=None, **kwargs): """ **Placeholder for the time being** :param endpoint_context: :py:class:`oidcendpoint.endpoint_context.EndpointContext` instance :param kwargs: request arguments :return: Response information """ links = [Link(href=h, rel=OIC_ISSUER) for h in kwargs['hrefs']] _response = JRD(subject=kwargs['subject'], links=links) info = { 'response': _response.to_json(), 'http_headers': [('Content-type', 'application/json')] } return info
def test_extra_member_response(): ex = { "subject": "acct:[email protected]", "aliases": ["http://www.example.com/~bob/"], "properties": { "http://example.com/ns/role/": "employee" }, 'dummy': 'foo', "links": [{ "rel": "http://webfinger.net/rel/avatar", "type": "image/jpeg", "href": "http://www.example.com/~bob/bob.jpg" }] } _resp = JRD().from_json(json.dumps(ex)) assert _resp['dummy'] == 'foo'