diff --git a/cmd/storeTypes_test.go b/cmd/storeTypes_test.go index 7a41cdf..dd368bb 100644 --- a/cmd/storeTypes_test.go +++ b/cmd/storeTypes_test.go @@ -242,6 +242,14 @@ func deleteStoreTypeTest(t *testing.T, shortName string, allowFail bool) { testCmd.SetArgs([]string{"store-types", "delete", "--name", shortName}) deleteStoreOutput := captureOutput( func() { + undeleteables := []string{"F5-CA-REST", "F5-WS-REST", "F5-SL-REST"} + for _, v := range undeleteables { + if v == shortName { + t.Skip("Not processing un-deletable store-type: ", shortName) + return + } + } + err := testCmd.Execute() if !allowFail { assert.NoError(t, err) @@ -266,10 +274,24 @@ func deleteStoreTypeTest(t *testing.T, shortName string, allowFail bool) { ) } +func checkIsUnDeleteable(shortName string) bool { + undeleteables := []string{"F5-CA-REST", "F5-WS-REST", "F5-SL-REST"} + for _, v := range undeleteables { + if v == shortName { + return true + } + } + return false +} + func createStoreTypeTest(t *testing.T, shortName string) { t.Run( fmt.Sprintf("CreateStore %s", shortName), func(t *testing.T) { testCmd := RootCmd + if checkIsUnDeleteable(shortName) { + t.Skip("Not processing un-deletable store-type: ", shortName) + return + } deleteStoreTypeTest(t, shortName, true) testCmd.SetArgs([]string{"store-types", "create", "--name", shortName}) createStoreOutput := captureOutput( @@ -278,6 +300,19 @@ func createStoreTypeTest(t *testing.T, shortName string) { assert.NoError(t, err) }, ) + exceptions := []string{ + "F5-CA-REST: Certificate Store Type with either short name 'F5-CA-REST' or name 'F5 CA Profiles REST' already exists.", + "F5-WS-REST: Certificate Store Type with either short name 'F5-WS-REST' or name 'F5 WS Profiles REST' already exists.", + "F5-SL-REST: Certificate Store Type with either short name 'F5-SL-REST' or name 'F5 SSL Profiles REST' already exists.", + } + + // check if any of the exceptions are in the output + for _, exception := range exceptions { + if strings.Contains(createStoreOutput, exception) { + t.Skip("Not processing un-deletable store-type: ", exception) + return + } + } if strings.Contains(createStoreOutput, "already exists") { assert.Fail(t, fmt.Sprintf("Store type %s already exists", shortName)) diff --git a/go.mod b/go.mod index b9d90e3..c88e773 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/Keyfactor/keyfactor-go-client/v2 v2.2.10-rc.1 github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 github.com/creack/pty v1.1.21 + github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/google/go-cmp v0.6.0 github.com/google/uuid v1.6.0 github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02 diff --git a/go.sum b/go.sum index 2348788..3a00952 100644 --- a/go.sum +++ b/go.sum @@ -30,6 +30,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 h1:zN2lZNZRflqFyxVaTIU61KNKQ9C0055u9CAfpmqUvo4= +github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3/go.mod h1:nPpo7qLxd6XL3hWJG/O60sR8ZKfMCiIoNap5GvD12KU= github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=