def test_unregister_missing(self): existing_sec = make_secret() secret.register([existing_sec]) missing_sec = make_secret() res = secret.unregister([missing_sec["uuid"], existing_sec["uuid"]]) self.assertEqual(res, response.success()) self.assertEqual({}, self.connection.secrets)
def test_unregister_existing(self): sec1 = make_secret(password="******") sec2 = make_secret(password="******") secret.register([sec1, sec2]) res = secret.unregister([sec1["uuid"]]) self.assertEqual(res, response.success()) self.assertNotIn(sec1["uuid"], self.connection.secrets) self.assertIn(sec2["uuid"], self.connection.secrets)
def test_unregister_validation(self): res = secret.unregister(["this-is-not-a-uuid"]) self.assertEqual(res, response.error("secretBadRequestErr"))
def test_unregister_libvirt_error(self): def fail(uuid): raise vmfakelib.Error(libvirt.VIR_ERR_INTERNAL_ERROR) self.connection.secretLookupByUUIDString = fail res = secret.unregister([str(uuid.uuid4())]) self.assertEqual(res, response.error("secretUnregisterErr"))