Пример #1
0
    def test_access_resolution_controlled_forbidden(self):
        """Test assumptions for access resolution for requested controlled Forbidden.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(False, [7], True)
        host = "localhost"
        with self.assertRaises(aiohttp.web_exceptions.HTTPForbidden):
            access_resolution(request, token, host, [], ["6"], [])
Пример #2
0
    def test_access_resolution_controlled_unauthorized(self):
        """Test assumptions for access resolution for requested controlled Unauthorized.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(False, [], False)
        host = "localhost"
        with self.assertRaises(aiohttp.web_exceptions.HTTPUnauthorized):
            access_resolution(request, token, host, [], ["5"], [])
Пример #3
0
    def test_access_resolution_controlled_never_reached2(self):
        """Test assumptions for access resolution for requested controlled forbidden.

        By default permissions cannot be None, at worst empty set, thus this might never be reached.
        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(False, None, True)
        host = "localhost"
        with self.assertRaises(aiohttp.web_exceptions.HTTPForbidden):
            access_resolution(request, token, host, [], [], ["8"])
Пример #4
0
    def test_access_resolution_controlled_no_perms_bonafide(self):
        """Test assumptions for access resolution for requested controlled and registered, returning registered only.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(True, [], True)
        host = "localhost"
        result = access_resolution(request, token, host, [], ["4"], ["7"])
        self.assertEqual(result, (["REGISTERED"], ["4"]))
Пример #5
0
    def test_access_resolution_controlled_no_perms_public(self):
        """Test assumptions for access resolution for requested controlled and public, returning public only.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(False, [], False)
        host = "localhost"
        result = access_resolution(request, token, host, ["1"], [], ["5"])
        self.assertEqual(result, (["PUBLIC"], ["1"]))
Пример #6
0
    def test_access_resolution_controlled_some(self):
        """Test assumptions for access resolution for requested controlled some datasets.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(False, ["5"], True)
        host = "localhost"
        result = access_resolution(request, token, host, [], [], ["5", "6"])
        self.assertEqual(result, (["CONTROLLED"], ["5"]))
Пример #7
0
    def test_access_resolution_controlled_no_perms(self):
        """Test assumptions for access resolution for requested controlled Forbidden.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(False, ["7"], True)
        host = "localhost"
        result = access_resolution(request, token, host, ["2"], ["6"], [])
        self.assertEqual(result, (["PUBLIC"], ["2"]))
Пример #8
0
    def test_access_resolution_controlled_no_perms_public(self):
        """Test assumptions for access resolution for requested controlled and public, returning public only.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(False, [], False)
        host = 'localhost'
        result = access_resolution(request, token, host, [1], [], [5])
        assert result == (['PUBLIC'], [1])
Пример #9
0
    def test_access_resolution_controlled_no_perms_bonafide(self):
        """Test assumptions for access resolution for requested controlled and registered, returning registered only.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(True, [], True)
        host = 'localhost'
        result = access_resolution(request, token, host, [], [4], [7])
        assert result == (['REGISTERED'], [4])
Пример #10
0
    def test_access_resolution_controlled_some(self):
        """Test assumptions for access resolution for requested controlled some datasets.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(False, [5], True)
        host = 'localhost'
        result = access_resolution(request, token, host, [], [], [5, 6])
        assert result == (['CONTROLLED'], [5])
Пример #11
0
    def test_access_resolution_controlled_no_perms(self):
        """Test assumptions for access resolution for requested controlled Forbidden.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(False, [7], True)
        host = 'localhost'
        result = access_resolution(request, token, host, [2], [6], [])
        assert result == (['PUBLIC'], [2])
Пример #12
0
    def test_access_resolution_controlled_no_registered(self):
        """Test assumptions for access resolution for token and no bona_fide.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(False, [5, 6], True)
        host = 'localhost'
        result = access_resolution(request, token, host, [1, 2], [3, 4],
                                   [5, 6])
        assert result == (['PUBLIC', 'CONTROLLED'], [1, 2, 5, 6])
Пример #13
0
    def test_access_resolution_registered(self):
        """Test assumptions for access resolution for token with just bona_fide.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(True, [], True)
        host = 'localhost'
        result = access_resolution(request, token, host, [1, 2], [3, 4],
                                   [5, 6])
        assert result == (['PUBLIC', 'REGISTERED'], [1, 2, 3, 4])
Пример #14
0
    def test_access_resolution_no_controlled(self):
        """Test assumptions for access resolution for token but no controlled datasets.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(False, [], True)
        host = 'localhost'
        result = access_resolution(request, token, host, [1, 2], [3, 4],
                                   [5, 6])
        assert result == (['PUBLIC'], [1, 2])
Пример #15
0
    def test_access_resolution_controlled_registered(self):
        """Test assumptions for access resolution for token and bona_fide.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(True, ["5", "6"], True)
        host = "localhost"
        result = access_resolution(request, token, host, ["1", "2"],
                                   ["3", "4"], ["5", "6"])
        self.assertListEqual(result[0], ["PUBLIC", "REGISTERED", "CONTROLLED"])
        intermediate_list = result[1]
        intermediate_list.sort()
        self.assertListEqual(["1", "2", "3", "4", "5", "6"], intermediate_list)
Пример #16
0
    def test_access_resolution_no_controlled(self):
        """Test assumptions for access resolution for token but no controlled datasets.

        It is based on the result of fetch_datasets_access function.
        """
        request = PARAMS
        token = mock_token(False, [], True)
        host = "localhost"
        result = access_resolution(request, token, host, ["1", "2"],
                                   ["3", "4"], ["5", "6"])
        self.assertListEqual(result[0], ["PUBLIC"])
        intermediate_list = result[1]
        intermediate_list.sort()
        self.assertListEqual(["1", "2"], intermediate_list)