Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding acceptance tests for password less passphrase secret providers #7019

Merged
merged 1 commit into from
May 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion tests/integration/integration_nodejs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/pulumi/pulumi/pkg/v3/resource/deploy/providers"
"github.com/pulumi/pulumi/pkg/v3/secrets/cloud"
"github.com/pulumi/pulumi/pkg/v3/secrets/passphrase"
"github.com/pulumi/pulumi/pkg/v3/testing/integration"
"github.com/pulumi/pulumi/sdk/v3/go/common/apitype"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
Expand Down Expand Up @@ -580,6 +581,58 @@ func TestStackReferenceSecretsNodejs(t *testing.T) {
})
}

func TestPasswordlessPassphraseSecretsProvider(t *testing.T) {
testOptions := integration.ProgramTestOptions{
Dir: "cloud_secrets_provider",
Dependencies: []string{"@pulumi/pulumi"},
SecretsProvider: fmt.Sprintf("passphrase"),
Env: []string{"PULUMI_CONFIG_PASSPHRASE=\"\""},
NoParallel: true,
Secrets: map[string]string{
"mysecret": "THISISASECRET",
},
CloudURL: "file://~",
}

workingTestOptions := testOptions.With(integration.ProgramTestOptions{
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
os.Setenv("PULUMI_CONFIG_PASSPHRASE", "")
secretsProvider := stackInfo.Deployment.SecretsProviders
assert.NotNil(t, secretsProvider)
assert.Equal(t, secretsProvider.Type, "passphrase")

_, err := passphrase.NewPassphaseSecretsManagerFromState(secretsProvider.State)
assert.NoError(t, err)

out, ok := stackInfo.Outputs["out"].(map[string]interface{})
assert.True(t, ok)

_, ok = out["ciphertext"]
assert.True(t, ok)
os.Unsetenv("PULUMI_CONFIG_PASSPHRASE")
},
})

brokenTestOptions := testOptions.With(integration.ProgramTestOptions{
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
secretsProvider := stackInfo.Deployment.SecretsProviders
assert.NotNil(t, secretsProvider)
assert.Equal(t, secretsProvider.Type, "passphrase")

_, err := passphrase.NewPassphaseSecretsManagerFromState(secretsProvider.State)
assert.Error(t, err)
},
})

t.Run("works-when-passphrase-set", func(t *testing.T) {
integration.ProgramTest(t, &workingTestOptions)
})

t.Run("error-when-passphrase-not-set", func(t *testing.T) {
integration.ProgramTest(t, &brokenTestOptions)
})
}

func TestCloudSecretProvider(t *testing.T) {
awsKmsKeyAlias := os.Getenv("PULUMI_TEST_KMS_KEY_ALIAS")
if awsKmsKeyAlias == "" {
Expand Down Expand Up @@ -633,7 +686,9 @@ func TestCloudSecretProvider(t *testing.T) {
})

// Run with default Pulumi service backend
t.Run("service", func(t *testing.T) { integration.ProgramTest(t, &testOptions) })
t.Run("service", func(t *testing.T) {
integration.ProgramTest(t, &testOptions)
})

// Check Azure secrets provider
t.Run("azure", func(t *testing.T) { integration.ProgramTest(t, &azureTestOptions) })
Expand Down