Skip to content

Commit 391d215

Browse files
authored
Merge 1.6.1 to main
2 parents 6ad08c3 + 4a5166e commit 391d215

File tree

8 files changed

+1640
-834
lines changed

8 files changed

+1640
-834
lines changed

.github/workflows/tests.yml

Lines changed: 208 additions & 208 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# v1.6.1
2+
3+
## Fixes
4+
5+
### CLI
6+
7+
- `auth`: When using `oauth` pass empty list for `scopes` if no scopes are provided, rather than default scope `openid`
8+
- `auth`: Output env and config file errors when both are encountered rather than just config file errors.
9+
10+
## Chores
11+
12+
- `store-types`: Update embedded `store-type` definitions to latest.
13+
114
# v1.6.0
215

316
## Features

cmd/root.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@ func getServerConfigFromEnv() (*auth_providers.Server, error) {
210210
}
211211

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

215218
}
216219

@@ -617,7 +620,15 @@ func initClient(saveConfig bool) (*api.Client, error) {
617620
Err(envCfgErr).
618621
Msg("unable to authenticate to Keyfactor Command")
619622
log.Debug().Msg("return: initClient()")
620-
return nil, cfgErr
623+
624+
//combine envCfgErr and cfgErr and return
625+
outErr := fmt.Errorf(
626+
"Environment Authentication Error:\r\n%s\r\n\r\nConfiguration File Authentication Error:\r\n%s",
627+
envCfgErr,
628+
cfgErr,
629+
)
630+
631+
return nil, outErr
621632
}
622633

623634
// initGenClient initializes the SDK Command API client

cmd/storeTypes_test.go

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"strings"
2323
"testing"
2424

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

187188
// iterate over the store types and verify that each has a name shortname and storetype
188-
for sType := range storeTypes {
189-
t.Log("Creating store type: " + sType)
190-
storeType := storeTypes[sType].(map[string]interface{})
191-
assert.NotNil(t, storeType["Name"], "Expected store type to have a name")
192-
assert.NotNil(t, storeType["ShortName"], "Expected store type to have short name")
193-
194-
// verify short name is a string
195-
_, ok := storeType["ShortName"].(string)
196-
assert.True(t, ok, "Expected short name to be a string")
197-
// verify name is a string
198-
_, ok = storeType["Name"].(string)
199-
assert.True(t, ok, "Expected name to be a string")
200-
201-
// Attempt to create the store type
202-
shortName := storeType["ShortName"].(string)
203-
createStoreTypeTest(t, shortName, false)
204-
}
189+
//for sType := range storeTypes {
190+
// t.Log("Creating store type: " + sType)
191+
// storeType := storeTypes[sType].(map[string]interface{})
192+
// assert.NotNil(t, storeType["Name"], "Expected store type to have a name")
193+
// assert.NotNil(t, storeType["ShortName"], "Expected store type to have short name")
194+
//
195+
// // verify short name is a string
196+
// _, ok := storeType["ShortName"].(string)
197+
// assert.True(t, ok, "Expected short name to be a string")
198+
// // verify name is a string
199+
// _, ok = storeType["Name"].(string)
200+
// assert.True(t, ok, "Expected name to be a string")
201+
//
202+
// // Attempt to create the store type
203+
// shortName := storeType["ShortName"].(string)
204+
// createStoreTypeTest(t, shortName, false)
205+
//}
205206
createAllStoreTypes(t, storeTypes)
206207
}
207208

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

293295
func createAllStoreTypes(t *testing.T, storeTypes map[string]interface{}) {
294-
t.Run(
295-
fmt.Sprintf("ONLINE Create ALL StoreTypes"), func(t *testing.T) {
296-
testCmd := RootCmd
297-
// check if I'm running inside a GitHub Action
298-
testArgs := []string{"store-types", "create", "--all"}
299-
testCreateStoreType(t, testCmd, testArgs, storeTypes)
300-
301-
},
302-
)
296+
//t.Run(
297+
// fmt.Sprintf("ONLINE Create ALL StoreTypes"), func(t *testing.T) {
298+
// testCmd := RootCmd
299+
// // check if I'm running inside a GitHub Action
300+
// testArgs := []string{"store-types", "create", "--all"}
301+
// testCreateStoreType(t, testCmd, testArgs, storeTypes)
302+
//
303+
// },
304+
//)
303305
t.Run(
304306
fmt.Sprintf("OFFLINE Create ALL StoreTypes"), func(t *testing.T) {
305307
testCmd := RootCmd
306-
// check if I'm running inside a GitHub Action
307308
testArgs := []string{"store-types", "create", "--all", "--offline"}
308-
testCreateStoreType(t, testCmd, testArgs, storeTypes)
309+
310+
var emStoreTypes []interface{}
311+
if err := json.Unmarshal(EmbeddedStoreTypesJSON, &emStoreTypes); err != nil {
312+
log.Error().Err(err).Msg("Unable to unmarshal embedded store type definitions")
313+
t.FailNow()
314+
}
315+
offlineStoreTypes, stErr := formatStoreTypes(&emStoreTypes)
316+
if stErr != nil {
317+
log.Error().Err(stErr).Msg("Unable to format store types")
318+
t.FailNow()
319+
}
320+
321+
testCreateStoreType(t, testCmd, testArgs, offlineStoreTypes)
309322
},
310323
)
311324
}

0 commit comments

Comments
 (0)