Best Python code snippet using autotest_python
test_modify_user.py
Source:test_modify_user.py
...17# along with this program. If not, see <http://www.gnu.org/licenses/>.18from gvm.errors import RequiredArgument19from gvm.protocols.gmpv208 import UserAuthType20class GmpModifyUserTestMixin:21 def test_modify_user(self):22 self.gmp.modify_user(user_id="u1")23 self.connection.send.has_been_called_with('<modify_user user_id="u1"/>')24 self.gmp.modify_user(name="u1")25 self.connection.send.has_been_called_with(26 "<modify_user>" "<name>u1</name>" "</modify_user>"27 )28 def test_modify_user_missing_user_id(self):29 with self.assertRaises(RequiredArgument):30 self.gmp.modify_user(user_id=None)31 with self.assertRaises(RequiredArgument):32 self.gmp.modify_user(user_id="")33 def test_modify_user_missing_name(self):34 with self.assertRaises(RequiredArgument):35 self.gmp.modify_user(name=None)36 with self.assertRaises(RequiredArgument):37 self.gmp.modify_user(name="")38 def test_modify_user_with_new_name(self):39 self.gmp.modify_user(user_id="u1", new_name="foo")40 self.connection.send.has_been_called_with(41 '<modify_user user_id="u1">'42 "<new_name>foo</new_name>"43 "</modify_user>"44 )45 def test_modify_user_with_new_comment(self):46 self.gmp.modify_user(user_id="u1", comment="foo")47 self.connection.send.has_been_called_with(48 '<modify_user user_id="u1">'49 "<comment>foo</comment>"50 "</modify_user>"51 )52 def test_modify_user_with_user_id_and_name(self):53 self.gmp.modify_user(user_id="u1", name="foo")54 self.connection.send.has_been_called_with('<modify_user user_id="u1"/>')55 def test_modify_user_with_role_ids(self):56 self.gmp.modify_user(user_id="u1", role_ids=[])57 self.connection.send.has_been_called_with('<modify_user user_id="u1"/>')58 self.gmp.modify_user(user_id="u1", role_ids=["r1"])59 self.connection.send.has_been_called_with(60 '<modify_user user_id="u1">' '<role id="r1"/>' "</modify_user>"61 )62 self.gmp.modify_user(user_id="u1", role_ids=["r1", "r2"])63 self.connection.send.has_been_called_with(64 '<modify_user user_id="u1">'65 '<role id="r1"/>'66 '<role id="r2"/>'67 "</modify_user>"68 )69 def test_modify_user_with_group_ids(self):70 self.gmp.modify_user(user_id="u1", role_ids=[])71 self.connection.send.has_been_called_with('<modify_user user_id="u1"/>')72 self.gmp.modify_user(user_id="u1", group_ids=["r1"])73 self.connection.send.has_been_called_with(74 '<modify_user user_id="u1">'75 '<groups><group id="r1"/></groups>'76 "</modify_user>"77 )78 self.gmp.modify_user(user_id="u1", group_ids=["r1", "r2"])79 self.connection.send.has_been_called_with(80 '<modify_user user_id="u1">'81 "<groups>"82 '<group id="r1"/>'83 '<group id="r2"/>'84 "</groups>"85 "</modify_user>"86 )87 def test_modify_user_with_password(self):88 self.gmp.modify_user(user_id="u1", password="foo")89 self.connection.send.has_been_called_with(90 '<modify_user user_id="u1">'91 "<password>foo</password>"92 "</modify_user>"93 )94 def test_modify_user_with_auth_source(self):95 self.gmp.modify_user(96 user_id="u1", auth_source=UserAuthType.LDAP_CONNECT97 )98 self.connection.send.has_been_called_with(99 '<modify_user user_id="u1">'100 "<sources><source>ldap_connect</source></sources>"101 "</modify_user>"102 )103 def test_modify_user_with_hosts(self):104 self.gmp.modify_user(user_id="u1", hosts=[])105 self.connection.send.has_been_called_with('<modify_user user_id="u1"/>')106 self.gmp.modify_user(user_id="u1", hosts=["foo"])107 self.connection.send.has_been_called_with(108 '<modify_user user_id="u1">'109 '<hosts allow="0">foo</hosts>'110 "</modify_user>"111 )112 self.gmp.modify_user(user_id="u1", hosts=["foo", "bar"])113 self.connection.send.has_been_called_with(114 '<modify_user user_id="u1">'115 '<hosts allow="0">foo,bar</hosts>'116 "</modify_user>"117 )118 self.gmp.modify_user(119 user_id="u1", hosts=["foo", "bar"], hosts_allow=False120 )121 self.connection.send.has_been_called_with(122 '<modify_user user_id="u1">'123 '<hosts allow="0">foo,bar</hosts>'124 "</modify_user>"125 )126 self.gmp.modify_user(127 user_id="u1", hosts=["foo", "bar"], hosts_allow=True128 )129 self.connection.send.has_been_called_with(130 '<modify_user user_id="u1">'131 '<hosts allow="1">foo,bar</hosts>'132 "</modify_user>"133 )134 def test_modify_user_with_ifaces(self):135 self.gmp.modify_user(user_id="u1", ifaces=[])136 self.connection.send.has_been_called_with('<modify_user user_id="u1"/>')137 self.gmp.modify_user(user_id="u1", ifaces=["foo"])138 self.connection.send.has_been_called_with(139 '<modify_user user_id="u1">'140 '<ifaces allow="0">foo</ifaces>'141 "</modify_user>"142 )143 self.gmp.modify_user(user_id="u1", ifaces=["foo", "bar"])144 self.connection.send.has_been_called_with(145 '<modify_user user_id="u1">'146 '<ifaces allow="0">foo,bar</ifaces>'147 "</modify_user>"148 )149 self.gmp.modify_user(150 user_id="u1", ifaces=["foo", "bar"], ifaces_allow=False151 )152 self.connection.send.has_been_called_with(153 '<modify_user user_id="u1">'154 '<ifaces allow="0">foo,bar</ifaces>'155 "</modify_user>"156 )157 self.gmp.modify_user(158 user_id="u1", ifaces=["foo", "bar"], ifaces_allow=True159 )160 self.connection.send.has_been_called_with(161 '<modify_user user_id="u1">'162 '<ifaces allow="1">foo,bar</ifaces>'163 "</modify_user>"...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!