Esempio n. 1
0
    def test_unregister_unexpected_error(self):
        def fail(uuid):
            raise Unexpected

        self.connection.secretLookupByUUIDString = fail
        with pytest.raises(Unexpected):
            secret.unregister([str(uuid.uuid4())])
Esempio n. 2
0
 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)
Esempio n. 3
0
    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"))
Esempio n. 4
0
 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
Esempio n. 5
0
 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)
Esempio n. 6
0
 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
Esempio n. 7
0
 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"))
Esempio n. 8
0
 def test_unregister_validation(self):
     res = secret.unregister(["this-is-not-a-uuid"])
     self.assertEqual(res, response.error("secretBadRequestErr"))