Пример #1
0
    def test_construct_accesstoken_request(self):
        # Client 1 starts
        client_1 = RP(config=CONF)
        _state = client_1.client_get("service_context").state.create_state(
            ISSUER)
        auth_request = AuthorizationRequest(
            redirect_uri='https://example.com/cli/authz_cb', state=_state)
        client_1.client_get("service_context").state.store_item(
            auth_request, 'auth_request', _state)

        # Client 2 carries on
        client_2 = RP(config=CONF)
        _state_dump = client_1.client_get("service_context").dump()
        client_2.client_get("service_context").load(_state_dump)

        auth_response = AuthorizationResponse(code='access_code')
        client_2.client_get("service_context").state.store_item(
            auth_response, 'auth_response', _state)

        # Bind access code to state
        req_args = {}
        msg = client_2.client_get("service", 'accesstoken').construct(
            request_args=req_args, state=_state)
        assert isinstance(msg, AccessTokenRequest)
        assert msg.to_dict() == {
            'client_id': 'client_1',
            'code': 'access_code',
            'client_secret': 'abcdefghijklmnop',
            'grant_type': 'authorization_code',
            'redirect_uri': 'https://example.com/cli/authz_cb',
            'state': _state
        }
Пример #2
0
    def test_do_userinfo_request_init(self):
        # Client 1 starts
        client_1 = RP(config=CONF)
        _state = client_1.client_get("service_context").state.create_state(
            ISSUER)

        auth_request = AuthorizationRequest(
            redirect_uri='https://example.com/cli/authz_cb', state='state')

        # Client 2 carries on
        client_2 = RP(config=CONF)
        _state_dump = client_1.client_get("service_context").dump()
        client_2.client_get("service_context").load(_state_dump)

        auth_response = AuthorizationResponse(code='access_code')
        client_2.client_get("service_context").state.store_item(
            auth_response, 'auth_response', _state)

        token_response = AccessTokenResponse(refresh_token="refresh_with_me",
                                             access_token="access")
        client_2.client_get("service_context").state.store_item(
            token_response, 'token_response', _state)

        # Back to Client 1
        _state_dump = client_2.client_get("service_context").dump()
        client_1.client_get("service_context").load(_state_dump)

        _srv = client_1.client_get("service", 'userinfo')
        _srv.endpoint = "https://example.com/userinfo"
        _info = _srv.get_request_parameters(state=_state)
        assert _info
        assert _info['headers'] == {'Authorization': 'Bearer access'}
        assert _info['url'] == 'https://example.com/userinfo'
Пример #3
0
    def create_client(self):
        try:
            shutil.rmtree('db')
        except FileNotFoundError:
            pass

        self.redirect_uri = "http://example.com/redirect"
        conf = {
            'issuer': 'https://op.example.com',
            'redirect_uris': ['https://example.com/cli/authz_cb'],
            'client_id': 'client_1',
            'client_secret': 'abcdefghijklmnop',
            'db_conf': {
                'keyjar': {
                    'handler':
                    'oidcmsg.storage.abfile.LabeledAbstractFileSystem',
                    'fdir': 'db/keyjar',
                    'key_conv': 'oidcmsg.storage.converter.QPKey',
                    'value_conv': 'cryptojwt.serialize.item.KeyIssuer',
                    'label': 'keyjar'
                },
                'default': {
                    'handler': 'oidcmsg.storage.abfile.AbstractFileSystem',
                    'fdir': 'db',
                    'key_conv': 'oidcmsg.storage.converter.QPKey',
                    'value_conv': 'oidcmsg.storage.converter.JSON'
                }
            }
        }
        self.client = RP(config=conf)
 def create_client(self):
     self.redirect_uri = "http://example.com/redirect"
     conf = {
         'redirect_uris': ['https://example.com/cli/authz_cb'],
         'client_id': 'client_1',
         'client_secret': 'abcdefghijklmnop',
     }
     self.client = RP(config=conf)
 def create_client(self):
     self.redirect_uri = "http://example.com/redirect"
     conf = {
         'redirect_uris': ['https://example.com/cli/authz_cb'],
         'client_id': 'client_1',
         'client_secret': 'abcdefghijklmnop',
     }
     self.client = RP(DB(), config=conf)
     self.client.state_db.set('ABCDE', State(iss='issuer').to_json())
Пример #6
0
def test_load_registration_response():
    conf = {
        'redirect_uris': ['https://example.com/cli/authz_cb'],
        'client_id': 'client_1',
        'client_secret': 'abcdefghijklmnop',
        'registration_response': {
            'issuer': 'https://example.com'
        }
    }
    client = RP(config=conf)

    # test static
    load_registration_response(client)
    assert True