Hub, plugins and tools inputs validation

Fixes: https://pagure.io/koji/issue/3319
This commit is contained in:
Jana Cupova 2022-04-04 08:38:29 +02:00
parent a371c76128
commit 9bfefe782e
75 changed files with 3031 additions and 1695 deletions

View file

@ -0,0 +1,33 @@
import unittest
import koji
import kojihub
import mock
class TestBuildImageIndirection(unittest.TestCase):
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.exports = kojihub.RootExports()
self.context.session.assertPerm = mock.MagicMock()
self.context.session.hasPerm = mock.MagicMock()
def tearDown(self):
mock.patch.stopall()
def test_priority_without_admin(self):
priority = -10
self.context.session.assertPerm.side_effect = None
self.context.session.hasPerm.return_value = False
with self.assertRaises(koji.ActionNotAllowed) as cm:
self.exports.buildImageIndirection(priority=priority)
self.assertEqual("only admins may create high-priority tasks", str(cm.exception))
def test_opts_without_expected_keys(self):
priority = 10
opts = {}
self.context.session.assertPerm.side_effect = None
with self.assertRaises(koji.ActionNotAllowed) as cm:
self.exports.buildImageIndirection(opts=opts, priority=priority)
self.assertEqual("Non-scratch builds must provide url for the indirection template",
str(cm.exception))