diff --git a/plugins/localstack/api_key_test.go b/plugins/localstack/api_key_test.go deleted file mode 100644 index 9882a28ac..000000000 --- a/plugins/localstack/api_key_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package localstack - -import ( - "testing" - - "github.com/1Password/shell-plugins/sdk" - "github.com/1Password/shell-plugins/sdk/plugintest" - "github.com/1Password/shell-plugins/sdk/schema/fieldname" -) - -func TestAPIKeyProvisioner(t *testing.T) { - plugintest.TestProvisioner(t, APIKey().DefaultProvisioner, map[string]plugintest.ProvisionCase{ - "default": { - ItemFields: map[sdk.FieldName]string{ - fieldname.APIKey: "SzCEXAMPLE", - }, - ExpectedOutput: sdk.ProvisionOutput{ - Environment: map[string]string{ - "LOCALSTACK_API_KEY": "SzCEXAMPLE", - }, - }, - }, - }) -} - -func TestAPIKeyImporter(t *testing.T) { - plugintest.TestImporter(t, APIKey().Importer, map[string]plugintest.ImportCase{ - "environment": { - Environment: map[string]string{ - "LOCALSTACK_API_KEY": "SzCEXAMPLE", - }, - ExpectedCandidates: []sdk.ImportCandidate{ - { - Fields: map[sdk.FieldName]string{ - fieldname.APIKey: "SzCEXAMPLE", - }, - }, - }, - }, - }) -} diff --git a/plugins/localstack/api_key.go b/plugins/localstack/auth_token.go similarity index 68% rename from plugins/localstack/api_key.go rename to plugins/localstack/auth_token.go index 5b168a054..671c45342 100644 --- a/plugins/localstack/api_key.go +++ b/plugins/localstack/auth_token.go @@ -9,23 +9,25 @@ import ( "github.com/1Password/shell-plugins/sdk/schema/fieldname" ) -func APIKey() schema.CredentialType { +func AuthToken() schema.CredentialType { return schema.CredentialType{ - Name: credname.APIKey, - DocsURL: sdk.URL("https://docs.localstack.cloud/getting-started/api-key/"), - ManagementURL: sdk.URL("https://app.localstack.cloud/account/apikeys"), + Name: credname.AuthToken, + DocsURL: sdk.URL("https://docs.localstack.cloud/getting-started/auth-token/"), + ManagementURL: sdk.URL("https://app.localstack.cloud/workspace/auth-token"), Fields: []schema.CredentialField{ { - Name: fieldname.APIKey, - MarkdownDescription: "API Key used to authenticate to LocalStack.", + Name: fieldname.AuthToken, + MarkdownDescription: "Auth token used to authenticate to LocalStack.", Secret: true, Composition: &schema.ValueComposition{ - Length: 10, + Length: 39, Charset: schema.Charset{ Uppercase: true, Lowercase: true, Digits: true, + Specific: []rune{'-'}, }, + Prefix: "ls-", }, }, }, @@ -36,5 +38,5 @@ func APIKey() schema.CredentialType { } var defaultEnvVarMapping = map[string]sdk.FieldName{ - "LOCALSTACK_API_KEY": fieldname.APIKey, + "LOCALSTACK_AUTH_TOKEN": fieldname.AuthToken, } diff --git a/plugins/localstack/auth_token_test.go b/plugins/localstack/auth_token_test.go new file mode 100644 index 000000000..c2ebcc57e --- /dev/null +++ b/plugins/localstack/auth_token_test.go @@ -0,0 +1,41 @@ +package localstack + +import ( + "testing" + + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/plugintest" + "github.com/1Password/shell-plugins/sdk/schema/fieldname" +) + +func TestAuthTokenProvisioner(t *testing.T) { + plugintest.TestProvisioner(t, AuthToken().DefaultProvisioner, map[string]plugintest.ProvisionCase{ + "default": { + ItemFields: map[sdk.FieldName]string{ + fieldname.AuthToken: "ls-02b523ae-52f2-4905-b46a-0a7d7c2947aa", + }, + ExpectedOutput: sdk.ProvisionOutput{ + Environment: map[string]string{ + "LOCALSTACK_AUTH_TOKEN": "ls-02b523ae-52f2-4905-b46a-0a7d7c2947aa", + }, + }, + }, + }) +} + +func TestAuthTokenImporter(t *testing.T) { + plugintest.TestImporter(t, AuthToken().Importer, map[string]plugintest.ImportCase{ + "environment": { + Environment: map[string]string{ + "LOCALSTACK_AUTH_TOKEN": "ls-02b523ae-52f2-4905-b46a-0a7d7c2947aa", + }, + ExpectedCandidates: []sdk.ImportCandidate{ + { + Fields: map[sdk.FieldName]string{ + fieldname.AuthToken: "ls-02b523ae-52f2-4905-b46a-0a7d7c2947aa", + }, + }, + }, + }, + }) +} diff --git a/plugins/localstack/localstack.go b/plugins/localstack/localstack.go index 07337a253..b9b1f490a 100644 --- a/plugins/localstack/localstack.go +++ b/plugins/localstack/localstack.go @@ -15,10 +15,11 @@ func LocalStackCLI() schema.Executable { NeedsAuth: needsauth.IfAll( needsauth.NotForHelpOrVersion(), needsauth.NotWithoutArgs(), + needsauth.NotWhenContainsArgs("auth"), ), Uses: []schema.CredentialUsage{ { - Name: credname.APIKey, + Name: credname.AuthToken, }, }, } diff --git a/plugins/localstack/plugin.go b/plugins/localstack/plugin.go index d588dff29..69cd454c3 100644 --- a/plugins/localstack/plugin.go +++ b/plugins/localstack/plugin.go @@ -13,7 +13,7 @@ func New() schema.Plugin { Homepage: sdk.URL("https://localstack.cloud"), }, Credentials: []schema.CredentialType{ - APIKey(), + AuthToken(), }, Executables: []schema.Executable{ LocalStackCLI(),