Esempio n. 1
0
 def config(self, request):
     config = mock.create_autospec(Configuration([]), spec_set=True)
     config.environment = request.param.get("env")
     config.usage_reporting_cluster_name = 'cluster_name'
     config.usage_reporting_operator = 'operator_sdrn'
     config.usage_reporting_team = request.param.get("team")
     yield config
 def config(self, secrets_mode):
     generic_enabled, strongbox_enabled, _, _ = secrets_mode
     config = mock.create_autospec(Configuration([]), spec_set=True)
     config.secrets_init_container_image = SECRET_IMAGE if generic_enabled else None
     config.secrets_service_account_name = "secretsmanager" if generic_enabled else None
     config.strongbox_init_container_image = STRONGBOX_IMAGE if strongbox_enabled else None
     yield config
Esempio n. 3
0
 def generic_init_secrets(self):
     config = mock.create_autospec(Configuration([]), spec_set=True)
     config.secret_init_containers = {
         "default": "default-image",
         "some-provider": "some-secret-container-image"
     }
     return GenericInitSecrets(config)
Esempio n. 4
0
    def test_legacy_strongbox_secrets(self, deployment, app_spec):
        config = mock.create_autospec(Configuration([]), spec_set=True)
        config.strongbox_init_container_image = STRONGBOX_IMAGE

        app_spec = app_spec._replace(
            strongbox=StrongboxSpec(enabled=True,
                                    iam_role="iam_role",
                                    aws_region="eu-west-1",
                                    groups=["group1", "group2"]))

        generic_init_secrets = mock.create_autospec(GenericInitSecrets(config),
                                                    spec_set=True,
                                                    instance=True)
        generic_init_secrets.supports.side_effect = lambda _type: _type == 'strongbox'

        secrets = Secrets(
            config,
            mock.create_autospec(KubernetesSecrets(),
                                 spec_set=True,
                                 instance=True), generic_init_secrets)

        expected_spec = SecretsSpec(
            type="strongbox",
            parameters={
                "AWS_REGION": "eu-west-1",
                "SECRET_GROUPS": "group1,group2"
            },
            annotations={"iam.amazonaws.com/role": "iam_role"})

        secrets.apply(deployment, app_spec)

        generic_init_secrets.apply.assert_called_once_with(
            deployment, app_spec, expected_spec)
Esempio n. 5
0
    def test_app_spec_secrets(self, deployment, app_spec):
        config = mock.create_autospec(Configuration([]), spec_set=True)
        app_spec = app_spec._replace(secrets=APP_SPEC_SECRETS)
        generic_init_secrets = mock.create_autospec(GenericInitSecrets(config),
                                                    spec_set=True,
                                                    instance=True)
        secrets = Secrets(
            config,
            mock.create_autospec(KubernetesSecrets(),
                                 spec_set=True,
                                 instance=True), generic_init_secrets)
        expected_spec = APP_SPEC_SECRETS[0]

        secrets.apply(deployment, app_spec)

        generic_init_secrets.apply.assert_called_once_with(
            deployment, app_spec, expected_spec)
Esempio n. 6
0
    def test_default_secrets(self, deployment, app_spec):
        config = mock.create_autospec(Configuration([]), spec_set=True)
        config.secret_init_containers = {"default": DEFAULT_IMAGE}

        generic_init_secrets = mock.create_autospec(GenericInitSecrets(config),
                                                    spec_set=True,
                                                    instance=True)
        generic_init_secrets.supports.side_effect = lambda _type: _type == 'default'

        secrets = Secrets(
            config,
            mock.create_autospec(KubernetesSecrets(),
                                 spec_set=True,
                                 instance=True), generic_init_secrets)

        expected_spec = SecretsSpec(type="default",
                                    parameters={},
                                    annotations={})

        secrets.apply(deployment, app_spec)

        generic_init_secrets.apply.assert_called_once_with(
            deployment, app_spec, expected_spec)
Esempio n. 7
0
 def config(self):
     config = mock.create_autospec(Configuration([]), spec_set=True)
     config.datadog_container_image = CONTAINER_IMAGE
     return config
Esempio n. 8
0
 def factory(self):
     config = mock.create_autospec(Configuration([]), spec_set=True)
     return SpecFactory(Factory(), {}, config)
 def strongbox_secrets(self):
     config = mock.create_autospec(Configuration([]), spec_set=True)
     return StrongboxSecrets(config)
 def generic_init_secrets(self, use_in_memory_emptydirs):
     config = mock.create_autospec(Configuration([]), spec_set=True)
     config.use_in_memory_emptydirs = use_in_memory_emptydirs
     return GenericInitSecrets(config)
Esempio n. 11
0
 def config(self):
     config = create_autospec(Configuration([]), spec_set=True)
     config.datadog_container_image = None
     return config
Esempio n. 12
0
 def strongbox_secrets(self):
     config = mock.create_autospec(Configuration([]), spec_set=True)
     config.secret_init_containers = {}
     config.strongbox_init_container_image = "some-strongbox-image"
     return GenericInitSecrets(config)
Esempio n. 13
0
 def generic_init_secrets(self, use_in_memory_emptydirs):
     config = mock.create_autospec(Configuration([]), spec_set=True)
     config.secret_init_containers = {}
     config.use_in_memory_emptydirs = use_in_memory_emptydirs
     config.secrets_init_container_image = "some-image"
     return GenericInitSecrets(config)
Esempio n. 14
0
 def config(self):
     config = mock.create_autospec(Configuration([]), spec_set=True)
     config.usage_reporting_endpoint = "http://example.com/usage"
     return config
Esempio n. 15
0
 def config(self):
     config = mock.create_autospec(Configuration([]), spec_set=True)
     config.datadog_container_image = CONTAINER_IMAGE
     config.datadog_container_memory = "2Gi"
     config.datadog_global_tags = {"tag": "test"}
     return config