コード例 #1
0
ファイル: test_init.py プロジェクト: simhnna/openlp
    def test_requires_auth_disabled(self):
        """
        Test the requires_auth wrapper with disabled security
        :return:
        """
        # GIVEN: A disabled security
        Settings().setValue('api/authentication enabled', False)

        # WHEN: I call the function
        wrapped_function = requires_auth(func)
        value = wrapped_function()

        # THEN: the result will be as expected
        assert value == 'called'
コード例 #2
0
ファイル: test_init.py プロジェクト: simhnna/openlp
    def test_requires_auth_enabled(self):
        """
        Test the requires_auth wrapper with enabled security
        :return:
        """
        # GIVEN: A disabled security
        Settings().setValue('api/authentication enabled', True)

        # WHEN: I call the function
        wrapped_function = requires_auth(func)
        req = MagicMock()
        value = wrapped_function(req)

        # THEN: the result will be as expected
        assert str(value) == str(authenticate())
コード例 #3
0
ファイル: test_init.py プロジェクト: simhnna/openlp
    def test_requires_auth_enabled_auth_error(self):
        """
        Test the requires_auth wrapper with enabled security and authorization taken place and and error
        :return:
        """
        # GIVEN: A enabled security
        Settings().setValue('api/authentication enabled', True)

        # WHEN: I call the function with the wrong password
        wrapped_function = requires_auth(func)
        req = MagicMock()
        req.authorization = ['Basic', 'cccccccc']
        value = wrapped_function(req)

        # THEN: the result will be as expected - try again
        assert str(value) == str(authenticate())
コード例 #4
0
    def test_requires_auth_missing_credentials(self):
        """
        Test the requires_auth wrapper with enabled security and authorization taken place and and error
        :return:
        """
        # GIVEN: An enabled security and a known user
        Settings().setValue('api/authentication enabled', True)
        Settings().setValue('api/user id', 'superfly')
        Settings().setValue('api/password', 'lamas')

        # WHEN: I call the function with no password
        wrapped_function = requires_auth(func)
        value = wrapped_function(0)

        # THEN: the result will be as expected (unauthorized)
        assert str(value) == str(authenticate())
コード例 #5
0
ファイル: test_init.py プロジェクト: simhnna/openlp
    def test_requires_auth_enabled_auth(self):
        """
        Test the requires_auth wrapper with enabled security and authorization taken place and and error
        :return:
        """
        # GIVEN: An enabled security and a known user
        Settings().setValue('api/authentication enabled', True)
        Settings().setValue('api/user id', 'superfly')
        Settings().setValue('api/password', 'lamas')

        # WHEN: I call the function with the wrong password
        wrapped_function = requires_auth(func)
        req = MagicMock()
        req.authorization = ['Basic', self.password]
        value = wrapped_function(req)

        # THEN: the result will be as expected - try again
        assert str(value) == 'called'