def test_clear(self): self.connection.secrets = { "uuid1": vmfakecon.Secret(self.connection, "uuid1", "ceph", "ovirt/name1", None), "uuid2": vmfakecon.Secret(self.connection, "uuid2", "ceph", "name2", None), } secret.clear() self.assertNotIn("uuid1", self.connection.secrets) self.assertIn("uuid2", self.connection.secrets)
def test_clear(self): self.connection.secrets = { "uuid1": vmfakecon.Secret(self.connection, "uuid1", "ceph", "ovirt/name1", None), "uuid2": vmfakecon.Secret(self.connection, "uuid2", "ceph", "name2", None), } secret.clear() assert "uuid1" not in self.connection.secrets assert "uuid2" in self.connection.secrets
def test_clear_skip_failed(self): def fail(): raise vmfakecon.Error(libvirt.VIR_ERR_INTERNAL_ERROR) self.connection.secrets = { "uuid1": vmfakecon.Secret(self.connection, "uuid1", "ceph", "ovirt/name1", None), "uuid2": vmfakecon.Secret(self.connection, "uuid2", "ceph", "ovirt/name2", None), } self.connection.secrets["uuid1"].undefine = fail secret.clear() self.assertNotIn("uuid2", self.connection.secrets)
def test_register_clear(self): self.connection.secrets = { "uuid1": vmfakecon.Secret(self.connection, "uuid1", "ceph", "ovirt/name1", None), "uuid2": vmfakecon.Secret(self.connection, "uuid2", "ceph", "name2", None), } sec = make_secret() res = secret.register([sec], clear=True) # Should succeed self.assertEqual(res, response.success()) # Should remove existing ovirt secrets self.assertNotIn("uuid1", self.connection.secrets) # Should keep non-ovirt secrets self.assertIn("uuid2", self.connection.secrets) # Should register new secret virsec = self.connection.secrets[sec["uuid"]] self.assertEqual(sec["password"].value, virsec.value)
def test_register_clear(self): self.connection.secrets = { "uuid1": vmfakecon.Secret(self.connection, "uuid1", "ceph", "ovirt/name1", None), "uuid2": vmfakecon.Secret(self.connection, "uuid2", "ceph", "name2", None), } sec = make_secret() res = secret.register([sec], clear=True) # Should succeed assert res == response.success() # Should remove existing ovirt secrets assert "uuid1" not in self.connection.secrets # Should keep non-ovirt secrets assert "uuid2" in self.connection.secrets # Should register new secret virsec = self.connection.secrets[sec["uuid"]] assert sec["password"].value == virsec.value