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

v1.6.1 #241

Open
wants to merge 6 commits into
base: release-1.6
Choose a base branch
from
Open
Show file tree
Hide file tree
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
416 changes: 208 additions & 208 deletions .github/workflows/tests.yml

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# v1.6.1

## Fixes

### CLI

- `auth`: When using `oauth` pass empty list for `scopes` if no scopes are provided, rather than default scope `openid`
- `auth`: Output env and config file errors when both are encountered rather than just config file errors.

## Chores

- `store-types`: Update embedded `store-type` definitions to latest.

# v1.6.0

## Features
Expand Down
15 changes: 13 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ func getServerConfigFromEnv() (*auth_providers.Server, error) {
}

log.Error().Msg("unable to authenticate with provided credentials")
return nil, fmt.Errorf("incomplete environment variable configuration")
return nil, fmt.Errorf(
"incomplete environment variable configuration, " +
"please provide basic auth credentials or oAuth credentials",
)

}

Expand Down Expand Up @@ -617,7 +620,15 @@ func initClient(saveConfig bool) (*api.Client, error) {
Err(envCfgErr).
Msg("unable to authenticate to Keyfactor Command")
log.Debug().Msg("return: initClient()")
return nil, cfgErr

//combine envCfgErr and cfgErr and return
outErr := fmt.Errorf(
"Environment Authentication Error:\r\n%s\r\n\r\nConfiguration File Authentication Error:\r\n%s",
envCfgErr,
cfgErr,
)

return nil, outErr
}

// initGenClient initializes the SDK Command API client
Expand Down
69 changes: 41 additions & 28 deletions cmd/storeTypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"strings"
"testing"

"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -185,23 +186,23 @@ func Test_StoreTypesCreateFromTemplatesCmd(t *testing.T) {
assert.True(t, len(storeTypes) >= 0, "Expected non-empty list of store types")

// iterate over the store types and verify that each has a name shortname and storetype
for sType := range storeTypes {
t.Log("Creating store type: " + sType)
storeType := storeTypes[sType].(map[string]interface{})
assert.NotNil(t, storeType["Name"], "Expected store type to have a name")
assert.NotNil(t, storeType["ShortName"], "Expected store type to have short name")

// verify short name is a string
_, ok := storeType["ShortName"].(string)
assert.True(t, ok, "Expected short name to be a string")
// verify name is a string
_, ok = storeType["Name"].(string)
assert.True(t, ok, "Expected name to be a string")

// Attempt to create the store type
shortName := storeType["ShortName"].(string)
createStoreTypeTest(t, shortName, false)
}
//for sType := range storeTypes {
// t.Log("Creating store type: " + sType)
// storeType := storeTypes[sType].(map[string]interface{})
// assert.NotNil(t, storeType["Name"], "Expected store type to have a name")
// assert.NotNil(t, storeType["ShortName"], "Expected store type to have short name")
//
// // verify short name is a string
// _, ok := storeType["ShortName"].(string)
// assert.True(t, ok, "Expected short name to be a string")
// // verify name is a string
// _, ok = storeType["Name"].(string)
// assert.True(t, ok, "Expected name to be a string")
//
// // Attempt to create the store type
// shortName := storeType["ShortName"].(string)
// createStoreTypeTest(t, shortName, false)
//}
createAllStoreTypes(t, storeTypes)
}

Expand All @@ -225,6 +226,7 @@ func testCreateStoreType(
allowFail := false
// Attempt to get the AWS store type because it comes with the product
testCmd.SetArgs(testArgs)
t.Log(fmt.Sprintf("Test args: %s", testArgs))
output := captureOutput(
func() {
err := testCmd.Execute()
Expand Down Expand Up @@ -291,21 +293,32 @@ func testCreateStoreType(
}

func createAllStoreTypes(t *testing.T, storeTypes map[string]interface{}) {
t.Run(
fmt.Sprintf("ONLINE Create ALL StoreTypes"), func(t *testing.T) {
testCmd := RootCmd
// check if I'm running inside a GitHub Action
testArgs := []string{"store-types", "create", "--all"}
testCreateStoreType(t, testCmd, testArgs, storeTypes)

},
)
//t.Run(
// fmt.Sprintf("ONLINE Create ALL StoreTypes"), func(t *testing.T) {
// testCmd := RootCmd
// // check if I'm running inside a GitHub Action
// testArgs := []string{"store-types", "create", "--all"}
// testCreateStoreType(t, testCmd, testArgs, storeTypes)
//
// },
//)
t.Run(
fmt.Sprintf("OFFLINE Create ALL StoreTypes"), func(t *testing.T) {
testCmd := RootCmd
// check if I'm running inside a GitHub Action
testArgs := []string{"store-types", "create", "--all", "--offline"}
testCreateStoreType(t, testCmd, testArgs, storeTypes)

var emStoreTypes []interface{}
if err := json.Unmarshal(EmbeddedStoreTypesJSON, &emStoreTypes); err != nil {
log.Error().Err(err).Msg("Unable to unmarshal embedded store type definitions")
t.FailNow()
}
offlineStoreTypes, stErr := formatStoreTypes(&emStoreTypes)
if stErr != nil {
log.Error().Err(stErr).Msg("Unable to format store types")
t.FailNow()
}

testCreateStoreType(t, testCmd, testArgs, offlineStoreTypes)
},
)
}
Expand Down
Loading
Loading