1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
# SPDX-FileCopyrightText: 2018-2024 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
from gvm.errors import RequiredArgument
class GmpCreateRoleTestMixin:
def test_create_role(self):
self.gmp.create_role(name="foo")
self.connection.send.has_been_called_with(
b"<create_role><name>foo</name></create_role>"
)
def test_missing_name(self):
with self.assertRaises(RequiredArgument):
self.gmp.create_role(None)
with self.assertRaises(RequiredArgument):
self.gmp.create_role("")
def test_create_role_with_comment(self):
self.gmp.create_role(name="foo", comment="bar")
self.connection.send.has_been_called_with(
b"<create_role>"
b"<name>foo</name>"
b"<comment>bar</comment>"
b"</create_role>"
)
def test_create_role_with_users(self):
self.gmp.create_role(name="foo", users=[])
self.connection.send.has_been_called_with(
b"<create_role><name>foo</name></create_role>"
)
self.gmp.create_role(name="foo", users=["u1", "u2"])
self.connection.send.has_been_called_with(
b"<create_role>"
b"<name>foo</name>"
b"<users>u1,u2</users>"
b"</create_role>"
)
|