Esempio n. 1
0
 def test_import_keys_calls_save_keys_for_user(self):
     user = factory.make_User()
     handler = SSHKeyHandler(user, {})
     protocol = factory.make_name("protocol")
     auth_id = factory.make_name("auth")
     mock_save_keys = self.patch(KeySource.objects, "save_keys_for_user")
     handler.import_keys({
         "protocol": protocol,
         "auth_id": auth_id,
     })
     self.assertThat(
         mock_save_keys,
         MockCalledOnceWith(user=user, protocol=protocol, auth_id=auth_id))
Esempio n. 2
0
 def test_import_keys_calls_save_keys_for_user_and_create_audit_event(self):
     user = factory.make_User()
     handler = SSHKeyHandler(user, {}, None)
     protocol = factory.make_name("protocol")
     auth_id = factory.make_name("auth")
     mock_save_keys = self.patch(KeySource.objects, "save_keys_for_user")
     handler.import_keys({"protocol": protocol, "auth_id": auth_id})
     self.assertThat(
         mock_save_keys,
         MockCalledOnceWith(user=user, protocol=protocol, auth_id=auth_id),
     )
     event = Event.objects.get(type__level=AUDIT)
     self.assertIsNotNone(event)
     self.assertEqual(event.description, "Imported SSH keys.")