Esempio n. 1
0
    def test_get_refs(self, docker_client):
        ref = SecretReference("a", "a_name", "a_file", "0", "0", "292")

        s = SecretSpec(docker_client, spec={})
        s.set_ref("abcd", ref)

        assert s.get_refs("abcd") == [ref]
Esempio n. 2
0
    def test_update_refs(self, docker_client):
        # The fake service "qwerty" has Secrets "c" and "d". Let's use "c".
        s = SecretSpec(docker_client, spec=None)

        # Secret "e" renews "c".
        e = SecretCollectionDefs.get("e")
        assert e is not None
        s.update_refs(e)
        refs = set([x.get("SecretID") for x in s.get_refs("qwerty")])
        assert refs == set(["e", "d"])

        # The fake service "qwerty" has Secrets "c" and "d". Let's use "c".
        s = SecretSpec(docker_client, spec=None)

        # Secret "a" doesn't renew "c".
        a = SecretCollectionDefs.get("a")
        assert a is not None
        s.update_refs(a)
        refs = set([x.get("SecretID") for x in s.get_refs("qwerty")])
        assert refs == set(["c", "d"])
    def test_update_services(self, installer, docker_client):
        # This should also depend on TestSecretSpec tests but I
        # can't get such dependencies to work.
        spec = SecretSpec(docker_client)

        with patch.object(Service, "update") as mock_update:
            installer.update_services(spec)

            calls = []
            for service_id in spec.services:
                calls.append(call(secrets=spec.get_refs(service_id)))

            mock_update.assert_has_calls(calls)
Esempio n. 4
0
    def test_from_swarm(self, docker_client):
        s = SecretSpec(docker_client, spec=None)
        assert "qwerty" in s.services

        secret_ids = set([x.get("SecretID") for x in s.get_refs("qwerty")])
        assert secret_ids == set(["c", "d"])