Exemplo n.º 1
0
 def test_password_error(self):
     test_error = ('000', 'Test Response')
     test = password.PasswordError(test_error)
     self.assertEqual(test.__str__(), '000: Test Response',
                      'Response str did not match expected value')
     self.assertEqual(test.get_response(), test_error,
                      'Response returned did not match expected value')
Exemplo n.º 2
0
    def test_password_cmd_error(self):
        test = password.PasswordCommands()
        password_error = password.PasswordError((999, "Generate Exception"))
        with mock.patch(
                'novaagent.common.password.PasswordCommands._decode_password',
                side_effect=password_error):
            message = test.password_cmd('Test Pass')

        self.assertEqual(
            (999, "Generate Exception"), message,
            'Did not receive expected message on change password exception')
Exemplo n.º 3
0
 def test_decode_password_password_exception(self):
     temp_pass = base64.b64encode(b'this is a test')
     test = password.PasswordCommands()
     test._compute_aes_key()
     password_error = password.PasswordError((999, "Generate Exception"))
     with mock.patch(
             'novaagent.common.password.PasswordCommands._decrypt_password',
             side_effect=password_error):
         try:
             test._decode_password(temp_pass)
             assert False, 'A PasswordError exception shouldhave occurred'
         except password.PasswordError:
             pass
         except Exception:
             assert False, 'PasswordError exception was not triggered'