예제 #1
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
예제 #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)
예제 #3
0
    def test_register_unexpected_error(self):
        def fail(xml):
            raise Unexpected

        self.connection.secretDefineXML = fail
        with pytest.raises(Unexpected):
            secret.register([make_secret()])
예제 #4
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)
예제 #5
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
예제 #6
0
 def test_register_change_usage_id(self):
     sec = make_secret(usage_id="ovirt/provider_uuid/secert_uuid")
     secret.register([sec])
     # Change usage id
     sec["usageID"] = "ovirt/domain_uuid/secret_uuid"
     res = secret.register([sec])
     self.assertEqual(res, response.success())
     virsec = self.connection.secrets[sec["uuid"]]
     self.assertEqual("ovirt/domain_uuid/secret_uuid", virsec.usage_id)
예제 #7
0
 def test_register_replace(self):
     # Register 2 secrets
     sec1 = make_secret(password="******")
     sec2 = make_secret(password="******")
     secret.register([sec1, sec2])
     # Replace existing secret value
     sec2["password"] = make_password("sec2 new password")
     res = secret.register([sec2])
     self.assertEqual(res, response.success())
     virsec1 = self.connection.secrets[sec1["uuid"]]
     self.assertEqual("sec1 password", virsec1.value)
     virsec2 = self.connection.secrets[sec2["uuid"]]
     self.assertEqual("sec2 new password", virsec2.value)
예제 #8
0
    def test_register_libvirt_error(self):
        def fail(xml):
            raise vmfakecon.Error(libvirt.VIR_ERR_INTERNAL_ERROR)

        self.connection.secretDefineXML = fail
        res = secret.register([make_secret()])
        self.assertEqual(res, response.error("secretRegisterErr"))
예제 #9
0
 def test_register_new(self):
     sec1 = make_secret(password="******")
     sec2 = make_secret(password="******")
     res = secret.register([sec1, sec2])
     self.assertEqual(res, response.success())
     virsec1 = self.connection.secrets[sec1["uuid"]]
     self.assertEqual("sec1 password", virsec1.value)
     virsec2 = self.connection.secrets[sec2["uuid"]]
     self.assertEqual("sec2 password", virsec2.value)
예제 #10
0
 def test_register_new(self):
     sec1 = make_secret(password="******")
     sec2 = make_secret(password="******")
     res = secret.register([sec1, sec2])
     assert res == response.success()
     virsec1 = self.connection.secrets[sec1["uuid"]]
     assert b"sec1 password" == virsec1.value
     virsec2 = self.connection.secrets[sec2["uuid"]]
     assert b"sec2 password" == virsec2.value
예제 #11
0
 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)
예제 #12
0
 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
예제 #13
0
파일: vmsecret_test.py 프로젝트: EdDev/vdsm
 def test_register_libvirt_error(self):
     def fail(xml):
         raise vmfakecon.Error(libvirt.VIR_ERR_INTERNAL_ERROR)
     self.connection.secretDefineXML = fail
     res = secret.register([make_secret()])
     self.assertEqual(res, response.error("secretRegisterErr"))
예제 #14
0
 def test_register_validation(self):
     res = secret.register([{"invalid": "secret"}])
     self.assertEqual(res, response.error("secretBadRequestErr"))
예제 #15
0
 def test_register_validation(self):
     res = secret.register([{"invalid": "secret"}])
     assert res == response.error("secretBadRequestErr")