def test_set_password_blowfish_crypt(self): """ UT: nxos module:set_password method - role none """ with self.assertRaises(SaltInvocationError): nxos_module.set_password( "username", "password", encrypted=True, algorithm="blowfish" )
def test_set_password_enc_false_cs_set(self): """UT: nxos module:set_password method - encrypted False, crypt_salt set""" username = "******" password = "******" crypt_salt = "ZcZqm15X" hashed_pass = "******" config_line = ( "username devops password 5" " $5$ZcZqm15X$exHN2m6yrPKpYhGArK3Vml3ZjNbJaJYdzWyf0fp1Up2") with patch("salt.modules.nxos.get_user", autospec=True): with patch("salt.modules.nxos.gen_hash", autospec=True, return_value=hashed_pass): with patch( "salt.modules.nxos.config", autospec=True, return_value="password_set", ) as config: result = nxos_module.set_password(username, password, crypt_salt=crypt_salt) config.assert_called_with(config_line) self.assertEqual("password_set", result)
def test_set_password_role_none(self): """ UT: nxos module:set_password method - role none """ username = "******" password = "******" hashed_pass = "******" config_line = "username devops password 5 test123TMM^& role devops" with patch("salt.modules.nxos.get_user", autospec=True): with patch( "salt.modules.nxos.gen_hash", autospec=True, return_value=hashed_pass ): with patch( "salt.modules.nxos.config", autospec=True, return_value="password_set", ) as config: # Execute the function under test result = nxos_module.set_password( username, password, encrypted=True, role="devops" ) config.assert_called_with(config_line) self.assertEqual("password_set", result)