Add limits on name values

Fixes: https://pagure.io/koji/issue/2117
This commit is contained in:
Jana Cupova 2021-08-25 15:03:08 +02:00 committed by Jana Cupova
parent 95717ba28d
commit 74ac826a87
25 changed files with 761 additions and 49 deletions

View file

@ -0,0 +1,30 @@
import unittest
import mock
import koji
import kojihub
class TestAddVolume(unittest.TestCase):
def setUp(self):
self.verify_name_internal = mock.patch('kojihub.verify_name_internal').start()
self.context = mock.patch('kojihub.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
self.context.session.assertPerm = mock.MagicMock()
self.context.session.assertLogin = mock.MagicMock()
def test_add_volume_wrong_format(self):
volume_name = 'volume-name+'
# name is longer as expected
self.verify_name_internal.side_effect = koji.GenericError
with self.assertRaises(koji.GenericError):
kojihub.add_volume(volume_name)
# not except regex rules
self.verify_name_internal.side_effect = koji.GenericError
with self.assertRaises(koji.GenericError):
kojihub.add_volume(volume_name)