diff --git a/cli/cmd/configure.go b/cli/cmd/configure.go index 0fcfb1e67..aee022a7f 100644 --- a/cli/cmd/configure.go +++ b/cli/cmd/configure.go @@ -231,16 +231,25 @@ func promptConfigureSetup() error { Transform: func(ans interface{}) interface{} { answer, ok := ans.(string) if ok && strings.Contains(answer, ".lacework.net") { - // if the provided account is the full URL ACCOUNT.lacework.net + // if the provided account is the full URL https://ACCOUNT.lacework.net + // remove the prefix https:// or http:// + rx, err := regexp.Compile(`(http://|https://)`) + if err == nil { + answer = rx.ReplaceAllString(answer, "") + } + + // if the provided account is the full domain ACCOUNT.lacework.net // subtract the account name and inform the user - rx, err := regexp.Compile(`\.lacework\.net.*`) + rx, err = regexp.Compile(`\.lacework\.net.*`) if err == nil { accountSplit := rx.Split(answer, -1) if len(accountSplit) != 0 { - cli.OutputHuman("Passing '.lacework.net' domain not required. Using '%s'\n", accountSplit[0]) + cli.OutputHuman("Passing full 'lacework.net' domain not required. Using '%s'\n", accountSplit[0]) return accountSplit[0] } } + + return answer } return ans diff --git a/integration/configure_unix_test.go b/integration/configure_unix_test.go index 19619a619..aff834430 100644 --- a/integration/configure_unix_test.go +++ b/integration/configure_unix_test.go @@ -194,8 +194,8 @@ func TestConfigureCommandErrors(t *testing.T) { c.ExpectString("Account:") c.SendLine("") c.ExpectString("The account subdomain of URL is required") - c.SendLine("my-account.lacework.net") // if the full URL was provided we transform it and inform the user - c.ExpectString("Passing '.lacework.net' domain not required. Using 'my-account'") + c.SendLine("https://my-account.lacework.net") // if the full URL was provided we transform it and inform the user + c.ExpectString("Passing full 'lacework.net' domain not required. Using 'my-account'") c.ExpectString("Access Key ID:") c.SendLine("") c.ExpectString("The API access key id must have more than 55 characters")