Skip to content

Commit

Permalink
fix: support 'AUTHTYPE' as alias for 'AUTH_TYPE' config property (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
padamstx authored Aug 13, 2021
1 parent 4820ca2 commit 6795484
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions v5/core/authenticator_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ func GetAuthenticatorFromEnvironment(credentialKey string) (authenticator Authen

// Determine the authentication type if not specified explicitly.
authType := properties[PROPNAME_AUTH_TYPE]

// Support alternate "AUTHTYPE" property.
if authType == "" {
authType = properties["AUTHTYPE"]
}

// Determine a default auth type if one wasn't specified.
if authType == "" {
// If the APIKEY property is specified, then we'll guess IAM... otherwise CR Auth.
if properties[PROPNAME_APIKEY] != "" {
Expand Down
4 changes: 2 additions & 2 deletions v5/core/config_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestGetServicePropertiesFromCredentialFile(t *testing.T) {
assert.Equal(t, "https://service2/api", props[PROPNAME_SVC_URL])
assert.Equal(t, "false", props[PROPNAME_SVC_DISABLE_SSL])
assert.Equal(t, "false", props[PROPNAME_SVC_ENABLE_GZIP])
assert.Equal(t, strings.ToUpper(AUTHTYPE_BASIC), strings.ToUpper(props[PROPNAME_AUTH_TYPE]))
assert.Equal(t, strings.ToUpper(AUTHTYPE_BASIC), strings.ToUpper(props["AUTHTYPE"]))
assert.Equal(t, "my-user", props[PROPNAME_USERNAME])
assert.Equal(t, "my-password", props[PROPNAME_PASSWORD])

Expand All @@ -85,7 +85,7 @@ func TestGetServicePropertiesFromCredentialFile(t *testing.T) {
assert.Equal(t, "https://service3/api", props[PROPNAME_SVC_URL])
assert.Equal(t, "false", props[PROPNAME_SVC_DISABLE_SSL])
assert.Equal(t, "notabool", props[PROPNAME_SVC_ENABLE_GZIP])
assert.Equal(t, strings.ToUpper(AUTHTYPE_CP4D), strings.ToUpper(props[PROPNAME_AUTH_TYPE]))
assert.Equal(t, strings.ToUpper(AUTHTYPE_CP4D), strings.ToUpper(props["AUTHTYPE"]))
assert.Equal(t, "my-cp4d-user", props[PROPNAME_USERNAME])
assert.Equal(t, "my-cp4d-password", props[PROPNAME_PASSWORD])
assert.Equal(t, "https://cp4dhost/cp4d/api", props[PROPNAME_AUTH_URL])
Expand Down
4 changes: 2 additions & 2 deletions v5/resources/my-credentials.env
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ SERVICE_1_AUTH_URL=https://iamhost/iam/api
SERVICE_1_AUTH_DISABLE_SSL=true

# Service2 configured with Basic Auth
SERVICE2_AUTH_TYPE=BasiC
SERVICE2_AUTHTYPE=BasiC
SERVICE2_USERNAME=my-user
SERVICE2_PASSWORD=my-password

# Service3 configured with CP4D
SERVICE3_AUTH_TYPE=CP4d
SERVICE3_AUTHTYPE=CP4d
SERVICE3_AUTH_URL=https://cp4dhost/cp4d/api
SERVICE3_USERNAME=my-cp4d-user
SERVICE3_PASSWORD=my-cp4d-password
Expand Down

0 comments on commit 6795484

Please sign in to comment.