Пример #1
0
    def test_authorize_for_sdos_not_in_rights(self, mock_access_rights: mock.MagicMock):
        mock_access_rights.return_value = 'test'
        request = mock.MagicMock()
        request.authorization = {'username': '******'}
        with app.app_context():
            result = mm.authorize_for_sdos(request, 'test', 'other')

        self.assertEqual(result, 'module`s organization is not in users rights')
Пример #2
0
    def test_authorize_for_sdos(self, mock_access_rights: mock.MagicMock):
        mock_access_rights.return_value = 'test'
        request = mock.MagicMock()
        request.authorization = {'username': '******'}
        with app.app_context():
            result = mm.authorize_for_sdos(request, 'test', 'test')

        self.assertTrue(result)
Пример #3
0
    def test_authorize_for_vendors_root(self, mock_access_rights: mock.MagicMock):
        mock_access_rights.return_value = '/'
        request = mock.MagicMock()
        request.authorization = {'username': '******'}
        with app.app_context():
            result = mm.authorize_for_vendors(request, {})

        self.assertEqual(result, True)
Пример #4
0
    def test_vendors_data_no_value(self, mock_redis_get: mock.MagicMock):
        """Redis get() method patched to return None.
        Then empty OrderedDict is returned from vendors_data() method
        """
        # Patch mock to return None while getting value from Redis
        mock_redis_get.return_value = None
        with app.app_context():
            result = search_bp.vendors_data()

        self.assertEqual(len(result), 0)
        self.assertIsInstance(result, collections.OrderedDict)
Пример #5
0
    def test_search_module_missing_data(self):
        """Test if responded with code 400 if the input arguments are missing.
        """
        name = ''
        revision = ''
        organization = ''

        with app.app_context():
            with self.assertRaises(NotFound) as http_error:
                search_bp.search_module(name, revision, organization)

        self.assertEqual(http_error.exception.code, 404)
        self.assertEqual(http_error.exception.description, 'Module {}@{}/{} not found'.format(name, revision, organization))
        self.assertEqual(http_error.exception.name, 'Not Found')
Пример #6
0
    def test_authorize_for_vendors_missing_rights(self, mock_access_rights: mock.MagicMock):
        mock_access_rights.return_value = 'test'
        request = mock.MagicMock()
        request.authorization = {'username': '******'}
        body = {
            'platforms': {
                'platform': [{
                    'name': 'other',
                    'vendor': 'other',
                    'software-version': 'other',
                    'software-flavor': 'other'
                }]
            }
        }
        with app.app_context():
            result = mm.authorize_for_vendors(request, body)

        self.assertEqual(result, 'vendor')