Esempio n. 1
0
def factory(msgtype, **kwargs):
    for name, obj in inspect.getmembers(sys.modules[__name__]):
        if inspect.isclass(obj) and issubclass(obj, Message):
            try:
                if obj.__name__ == msgtype:
                    return obj(**kwargs)
            except AttributeError:
                pass

    # Fall back to basic OAuth2 messages
    return oauth2.factory(msgtype, **kwargs)
def test_factory_auth_response():
    ar = factory("AuthorizationResponse", client_id="client1", iss="Issuer", code="1234567")
    assert isinstance(ar, AuthorizationResponse)
    assert ar.verify(client_id="client1", iss="Issuer")
Esempio n. 3
0
def test_factory_auth_response():
    ar = factory('AuthorizationResponse', client_id='client1', iss='Issuer',
                 code='1234567')
    assert isinstance(ar, AuthorizationResponse)
    assert ar.verify(client_id='client1', iss='Issuer')
def test_factory():
    dr = factory("ResponseMessage", error="some_error")
    assert isinstance(dr, ResponseMessage)
    assert list(dr.keys()) == ["error"]
Esempio n. 5
0
def test_factory():
    dr = factory('ResponseMessage', error='some_error')
    assert isinstance(dr, ResponseMessage)
    assert list(dr.keys()) == ['error']