Пример #1
0
def test_get_provider_base():
    class SomeAuthProvider(AuthProvider):
        pass

    class NestedAuthProvider(SomeAuthProvider):
        pass

    class SomeIdentityProvider(IdentityProvider):
        pass

    assert get_provider_base(SomeAuthProvider) is AuthProvider
    assert get_provider_base(NestedAuthProvider) is AuthProvider
    assert get_provider_base(SomeIdentityProvider) is IdentityProvider
Пример #2
0
def test_get_provider_base():
    class SomeAuthProvider(AuthProvider):
        pass

    class NestedAuthProvider(SomeAuthProvider):
        pass

    class SomeIdentityProvider(IdentityProvider):
        pass

    assert get_provider_base(SomeAuthProvider) is AuthProvider
    assert get_provider_base(NestedAuthProvider) is AuthProvider
    assert get_provider_base(SomeIdentityProvider) is IdentityProvider
Пример #3
0
    def register_provider(self, cls, type_):
        """Registers a new provider type.

        This can be used to register a new provider type in the
        application without having to go through the entry point
        system.

        :param cls: The provider. Must be a subclass of either
                    :class:`.AuthProvider` or
                    :class:`.IdentityProvider`.
        :param type_: The type name of the provider used to reference
                      it in the configuration.
        """
        registry = self.provider_registry[get_provider_base(cls)]
        assert type_ not in registry, 'Provider is already registered: ' + cls.__name__
        registry[type_] = cls
Пример #4
0
    def register_provider(self, cls, type_):
        """Registers a new provider type.

        This can be used to register a new provider type in the
        application without having to go through the entry point
        system.

        :param cls: The provider. Must be a subclass of either
                    :class:`.AuthProvider` or
                    :class:`.IdentityProvider`.
        :param type_: The type name of the provider used to reference
                      it in the configuration.
        """
        registry = self.provider_registry[get_provider_base(cls)]
        assert type_ not in registry, 'Provider is already registered: ' + cls.__name__
        registry[type_] = cls