github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/backend/httpstate/crypto_test.go (about) 1 package httpstate 2 3 import ( 4 "testing" 5 6 "github.com/pulumi/pulumi/sdk/v3/go/common/resource/config" 7 "github.com/pulumi/pulumi/sdk/v3/go/common/workspace" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestChangeProjectStackSecretDetails(t *testing.T) { 12 t.Parallel() 13 14 tests := []struct { 15 TestName string 16 ProjectStack workspace.ProjectStack 17 Expected bool 18 }{ 19 { 20 TestName: "Expects to save stack when existing secrets manager is cloud", 21 ProjectStack: workspace.ProjectStack{ 22 Config: make(config.Map), 23 SecretsProvider: "awskms://alias/TestProvider?region=us-west-2", 24 EncryptedKey: "AQICAHhAA+FYp21DcGwS7xUizcOsoZihxKtWVCjZpgsK7owkfQF3sftIrKkJOJ0VYq69rHxvAAAAfjB8Bgkqhk", 25 }, 26 Expected: true, 27 }, 28 { 29 TestName: "Expects to save stack when existing secrets manager is passphrase", 30 ProjectStack: workspace.ProjectStack{ 31 Config: make(config.Map), 32 EncryptionSalt: "v1:/AQICAHhAA+FYp21DcGwS7xUizcOsoZihxKtWVCjZpgsK7owkfQF3sftIrKkJOJ0VYq69rHxvAAAAfjB8Bgkqhk", 33 }, 34 Expected: true, 35 }, 36 { 37 TestName: "Does not expect to save stack when existing secrets manager is service", 38 ProjectStack: workspace.ProjectStack{ 39 Config: make(config.Map), 40 }, 41 Expected: false, 42 }, 43 } 44 45 //nolint:paralleltest // false positive because range var isn't used directly in t.Run(name) arg 46 for _, test := range tests { 47 test := test 48 t.Run(test.TestName, func(t *testing.T) { 49 requiresProjectSave := changeProjectStackSecretDetails(&test.ProjectStack) 50 assert.Equal(t, test.Expected, requiresProjectSave) 51 }) 52 } 53 }