def test_unregister_unexpected_error(self): def fail(uuid): raise Unexpected self.connection.secretLookupByUUIDString = fail with pytest.raises(Unexpected): secret.unregister([str(uuid.uuid4())])
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_libvirt_error(self): def fail(uuid): raise vmfakecon.Error(libvirt.VIR_ERR_INTERNAL_ERROR) self.connection.secretLookupByUUIDString = fail res = secret.unregister([str(uuid.uuid4())]) self.assertEqual(res, response.error("secretUnregisterErr"))
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"]]) assert res == response.success() assert {} == 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_existing(self): sec1 = make_secret(password="******") sec2 = make_secret(password="******") secret.register([sec1, sec2]) res = secret.unregister([sec1["uuid"]]) assert res == response.success() assert sec1["uuid"] not in self.connection.secrets assert sec2["uuid"] in self.connection.secrets
def test_unregister_validation(self): res = secret.unregister(["this-is-not-a-uuid"]) self.assertEqual(res, response.error("secretBadRequestErr"))