Esempio n. 1
0
 def test_get_from_secret(self):
     env_var = get_from_secret(key_name="foo",
                               secret_key_name="secret_key",
                               secret_ref_name="secret_ref")
     assert env_var.name == "foo"
     assert isinstance(env_var.value_from, k8s_schemas.V1EnvVarSource)
     assert env_var.value_from.secret_key_ref.name == "secret_ref"
     assert env_var.value_from.secret_key_ref.key == "secret_key"
Esempio n. 2
0
 def test_get_items_from_secret(self):
     # None
     assert get_items_from_secret(None) == []
     # Secret without items
     secret = V1K8sResourceType(name="test",
                                schema=V1K8sResourceSchema(name="test"),
                                is_requested=True)
     assert get_items_from_secret(secret) == []
     secret = V1K8sResourceType(
         name="test",
         schema=V1K8sResourceSchema(name="test", items=[]),
         is_requested=True,
     )
     assert get_items_from_secret(secret) == []
     # Secret with items
     secret = V1K8sResourceType(
         name="test",
         schema=V1K8sResourceSchema(name="test", items=["item1", "item2"]),
         is_requested=True,
     )
     assert get_items_from_secret(secret) == [
         get_from_secret("item1", "item1", secret.schema.name),
         get_from_secret("item2", "item2", secret.schema.name),
     ]