diff --git a/go.sum b/go.sum index 5ea05df06..1d862246a 100644 --- a/go.sum +++ b/go.sum @@ -11,8 +11,6 @@ github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPp github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/auth0/go-auth0 v0.16.0 h1:ei3Ks5EXau96UQfz3Dak13+SyRw1cOMBGgEP+BCocXs= -github.com/auth0/go-auth0 v0.16.0/go.mod h1:k2iXR4WU9si22nKZO70NNf/rGf3vT4EzCzonPwhN13A= github.com/auth0/go-auth0 v0.17.0 h1:nlDkW6Qc3xpeuv5iVUBRMeg4RDZ7d7oeBBPQbZ708us= github.com/auth0/go-auth0 v0.17.0/go.mod h1:KiuxR7q2pTm9a1snjFi7y3KmPS+Bt1kgiJ8oSBvVkXo= github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0 h1:0NmehRCgyk5rljDQLKUO+cRJCnduDyn11+zGZIc9Z48= diff --git a/internal/display/actions.go b/internal/display/actions.go index 04dc4f672..ee3e7c303 100644 --- a/internal/display/actions.go +++ b/internal/display/actions.go @@ -55,8 +55,7 @@ func (r *Renderer) ActionList(actions []*management.Action) { r.Heading(resource) if len(actions) == 0 { - r.EmptyState(resource) - r.Infof("Use 'auth0 actions create' to add one") + r.EmptyState(resource, "Use 'auth0 actions create' to add one") return } diff --git a/internal/display/apis.go b/internal/display/apis.go index 014d3b661..6b00c5921 100644 --- a/internal/display/apis.go +++ b/internal/display/apis.go @@ -73,8 +73,7 @@ func (r *Renderer) APIList(apis []*management.ResourceServer) { r.Heading(fmt.Sprintf("%s (%d)", resource, len(apis))) if len(apis) == 0 { - r.EmptyState(resource) - r.Infof("Use 'auth0 apis create' to add one") + r.EmptyState(resource, "Use 'auth0 apis create' to add one") return } @@ -161,7 +160,7 @@ func (r *Renderer) ScopesList(api string, scopes []management.ResourceServerScop r.Heading(fmt.Sprintf("%s of %s", resource, ansi.Bold(api))) if len(scopes) == 0 { - r.EmptyState(resource) + r.EmptyState(resource, "") return } diff --git a/internal/display/apps.go b/internal/display/apps.go index eef7dc8a5..30e926253 100644 --- a/internal/display/apps.go +++ b/internal/display/apps.go @@ -109,8 +109,7 @@ func (r *Renderer) ApplicationList(clients []*management.Client, revealSecrets b r.Heading(fmt.Sprintf("%s (%v)", resource, len(clients))) if len(clients) == 0 { - r.EmptyState(resource) - r.Infof("Use 'auth0 apps create' to add one") + r.EmptyState(resource, "Use 'auth0 apps create' to add one") return } diff --git a/internal/display/custom_domain.go b/internal/display/custom_domain.go index 201717f25..936623bc8 100644 --- a/internal/display/custom_domain.go +++ b/internal/display/custom_domain.go @@ -53,8 +53,7 @@ func (r *Renderer) CustomDomainList(customDomains []*management.CustomDomain) { r.Heading(resource) if len(customDomains) == 0 { - r.EmptyState(resource) - r.Infof("Use 'auth0 domains create' to add one") + r.EmptyState(resource, "Use 'auth0 domains create' to add one") return } diff --git a/internal/display/display.go b/internal/display/display.go index 991832a7c..afce4d393 100644 --- a/internal/display/display.go +++ b/internal/display/display.go @@ -74,8 +74,12 @@ func (r *Renderer) Heading(text ...string) { fmt.Fprintf(r.MessageWriter, "\n%s %s\n", ansi.Faint("==="), heading) } -func (r *Renderer) EmptyState(resource string) { - fmt.Fprintf(r.MessageWriter, "No %s available.\n\n", resource) +func (r *Renderer) EmptyState(resource string, hint string) { + if r.Format == OutputFormatJSON { + r.JSONResult([]interface{}{}) + return + } + r.Warnf("No %s available. %s\n", resource, hint) } func (r *Renderer) JSONResult(data interface{}) { diff --git a/internal/display/log_streams.go b/internal/display/log_streams.go index a4a8ee8ad..bea402236 100644 --- a/internal/display/log_streams.go +++ b/internal/display/log_streams.go @@ -46,8 +46,7 @@ func (r *Renderer) LogStreamList(logs []*management.LogStream) { r.Heading(resource) if len(logs) == 0 { - r.EmptyState(resource) - r.Infof("Use 'auth0 logs streams create' to add one") + r.EmptyState(resource, "Use 'auth0 logs streams create' to add one") return } diff --git a/internal/display/logs.go b/internal/display/logs.go index b65b398a7..6089b3f9c 100644 --- a/internal/display/logs.go +++ b/internal/display/logs.go @@ -149,12 +149,15 @@ func (r *Renderer) LogList(logs []*management.Log, silent, hasFilter bool) { if len(logs) == 0 { if hasFilter { - r.Output("No logs available matching filter criteria.\n\n") + if r.Format == OutputFormatJSON { + r.JSONResult([]interface{}{}) + return + } + r.Warnf("No logs available matching filter criteria.\n") } else { - r.EmptyState(resource) + r.EmptyState(resource, "To generate logs, run a test command like 'auth0 test login' or 'auth0 test token'") } - r.Infof("To generate logs, run a test command like 'auth0 test login' or 'auth0 test token'") return } diff --git a/internal/display/members.go b/internal/display/members.go index 1e0b8b514..b232ef401 100644 --- a/internal/display/members.go +++ b/internal/display/members.go @@ -31,10 +31,15 @@ func (v *membersView) Object() interface{} { } func (r *Renderer) MembersList(members []management.OrganizationMember) { - resource := "members" + resource := "organization members" r.Heading(resource) + if len(members) == 0 { + r.EmptyState(resource, "") + return + } + var res []View for _, m := range members { res = append(res, makeMembersView(&m)) diff --git a/internal/display/organizations.go b/internal/display/organizations.go index f7e677489..64f230321 100644 --- a/internal/display/organizations.go +++ b/internal/display/organizations.go @@ -49,8 +49,7 @@ func (r *Renderer) OrganizationList(organizations []*management.Organization) { r.Heading(resource) if len(organizations) == 0 { - r.EmptyState(resource) - r.Infof("Use 'auth0 orgs create' to add one") + r.EmptyState(resource, "Use 'auth0 orgs create' to add one") return } diff --git a/internal/display/role_permissions.go b/internal/display/role_permissions.go index 8118ba458..d07be6682 100644 --- a/internal/display/role_permissions.go +++ b/internal/display/role_permissions.go @@ -43,8 +43,7 @@ func (r *Renderer) RolePermissionList(perms []*management.Permission) { r.Heading(resource) if len(perms) == 0 { - r.EmptyState(resource) - r.Infof("Use 'auth0 roles permissions add' to add one") + r.EmptyState(resource, "Use 'auth0 roles permissions add' to add one") return } diff --git a/internal/display/roles.go b/internal/display/roles.go index b1b087f2b..7aba28266 100644 --- a/internal/display/roles.go +++ b/internal/display/roles.go @@ -45,8 +45,7 @@ func (r *Renderer) RoleList(roles []*management.Role) { r.Heading(fmt.Sprintf("%s (%d)", resource, len(roles))) if len(roles) == 0 { - r.EmptyState(resource) - r.Infof("Use 'auth0 roles create' to add one") + r.EmptyState(resource, "Use 'auth0 roles create' to add one") return } @@ -59,12 +58,11 @@ func (r *Renderer) RoleList(roles []*management.Role) { } func (r *Renderer) UserRoleList(roles []*management.Role) { - resource := "roles assigned to user" + resource := "user roles" r.Heading(fmt.Sprintf("%s (%d)", resource, len(roles))) if len(roles) == 0 { - r.Output("No roles assigned to user.\n\n") - r.Infof("Use 'auth0 users roles assign' to assign roles to a user.") + r.EmptyState(resource, "Use 'auth0 users roles assign' to assign roles to a user") return } diff --git a/internal/display/rules.go b/internal/display/rules.go index 5e051877d..83bb9a3c4 100644 --- a/internal/display/rules.go +++ b/internal/display/rules.go @@ -48,8 +48,7 @@ func (r *Renderer) RulesList(rules []*management.Rule) { r.Heading(resource) if len(rules) == 0 { - r.EmptyState(resource) - r.Infof("Use 'auth0 rules create' to add one") + r.EmptyState(resource, "Use 'auth0 rules create' to add one") return } diff --git a/internal/display/tenants.go b/internal/display/tenants.go index fbf999a30..e6faa165f 100644 --- a/internal/display/tenants.go +++ b/internal/display/tenants.go @@ -21,8 +21,7 @@ func (r *Renderer) TenantList(data []string) { r.Heading() if len(data) == 0 { - r.EmptyState("tenants") - r.Infof("Use 'auth0 login' to add one") + r.EmptyState("tenants", "Use 'auth0 login' to add one") return } diff --git a/internal/display/user_blocks.go b/internal/display/user_blocks.go index c2275b664..691bfe316 100644 --- a/internal/display/user_blocks.go +++ b/internal/display/user_blocks.go @@ -35,7 +35,7 @@ func (r *Renderer) UserBlocksList(userBlocks []*management.UserBlock) { r.Heading(resource) if len(userBlocks) == 0 { - r.EmptyState(resource) + r.EmptyState(resource, "") return } diff --git a/internal/display/users.go b/internal/display/users.go index 5dea506b2..c8849ff45 100644 --- a/internal/display/users.go +++ b/internal/display/users.go @@ -61,8 +61,7 @@ func (r *Renderer) UserSearch(users []*management.User) { r.Heading(resource) if len(users) == 0 { - r.EmptyState(resource) - r.Infof("Use 'auth0 users create' to add one") + r.EmptyState(resource, "Use 'auth0 users create' to add one") return } diff --git a/test/integration/actions-test-cases.yaml b/test/integration/actions-test-cases.yaml index 04806ee76..ccfcd5544 100644 --- a/test/integration/actions-test-cases.yaml +++ b/test/integration/actions-test-cases.yaml @@ -10,7 +10,13 @@ tests: contains: - Use 'auth0 actions create' to add one - 002 - it successfully creates an action: + 002 - it successfully lists all actions with no data (json): + command: auth0 actions list --json + exit-code: 0 + stdout: + exactly: "[]" + + 003 - it successfully creates an action: command: auth0 actions create -n "integration-test-action1" -t "post-login" -c "function() {}" -d "lodash=4.0.0" -s "SECRET=value" exit-code: 0 stdout: @@ -24,7 +30,7 @@ tests: - "CREATED 0 seconds ago" - "CODE function() {}" - 003 - it successfully lists all actions with data: + 004 - it successfully lists all actions with data: command: auth0 actions list exit-code: 0 stdout: @@ -35,7 +41,7 @@ tests: - STATUS - DEPLOYED - 004 - it successfully creates an action and outputs in json: + 005 - it successfully creates an action and outputs in json: command: auth0 actions create -n "integration-test-action2" -t "post-login" -c "function() {}" -d "lodash=4.0.0" -s "SECRET=value" --json exit-code: 0 stdout: @@ -50,7 +56,7 @@ tests: secrets.0.value: "value" status: "pending" - 005 - given a test action, it successfully gets the action's details: + 006 - given a test action, it successfully gets the action's details: command: auth0 actions show $(./test/integration/scripts/get-action-id.sh) exit-code: 0 stdout: @@ -64,7 +70,7 @@ tests: - "CREATED" - "CODE function() {}" - 006 - given a test action, it successfully gets the action's details and outputs in json: + 007 - given a test action, it successfully gets the action's details and outputs in json: command: auth0 actions show $(./test/integration/scripts/get-action-id.sh) --json exit-code: 0 stdout: @@ -77,7 +83,7 @@ tests: dependencies.0.version: "4.0.0" secrets.0.name: "SECRET" - 007 - given a test action, it successfully updates the action's details: + 008 - given a test action, it successfully updates the action's details: command: auth0 actions update $(./test/integration/scripts/get-action-id.sh) -n "integration-test-action-updated" -c "function() {console.log()}" -d "uuid=9.0.0" -s "SECRET2=newValue" exit-code: 0 stdout: @@ -91,7 +97,7 @@ tests: - "CREATED" - "CODE function() {console.log()}" - 008 - given a test action, it successfully updates the action's details and outputs in json: + 009 - given a test action, it successfully updates the action's details and outputs in json: command: auth0 actions update $(./test/integration/scripts/get-action-id.sh) -n "integration-test-action-updated-again" -c "function() {console.log()}" -d "uuid=9.0.0" -s "SECRET3=newValue" --json exit-code: 0 stdout: @@ -105,13 +111,13 @@ tests: secrets.0.name: "SECRET3" secrets.0.value: "newValue" - 009 - given a test action, it successfully opens the settings page: + 010 - given a test action, it successfully opens the settings page: command: auth0 actions open $(./test/integration/scripts/get-action-id.sh) --no-input exit-code: 0 stderr: contains: - "Open the following URL in a browser" - 010 - given a test action, it successfully deletes the action: + 011 - given a test action, it successfully deletes the action: command: auth0 actions delete $(./test/integration/scripts/get-action-id.sh) --force exit-code: 0 diff --git a/test/integration/custom-domains-test-cases.yaml b/test/integration/custom-domains-test-cases.yaml index 61880a2b9..2118aa158 100644 --- a/test/integration/custom-domains-test-cases.yaml +++ b/test/integration/custom-domains-test-cases.yaml @@ -3,10 +3,21 @@ config: retries: 1 tests: - 001 - list domains: + 001 - list domains with no results: command: auth0 domains list exit-code: 0 - 002 - create domain with minimal flags: + stderr: + contains: + - No custom domains available. + - Use 'auth0 domains create' to add one + + 002 - list domains with no results (json): + command: auth0 domains list --json + exit-code: 0 + stdout: + exactly: "[]" + + 003 - create domain with minimal flags: command: auth0 domains create --domain "custom-domain.com" --no-input exit-code: 0 stdout: @@ -15,13 +26,15 @@ tests: - "DOMAIN custom-domain.com" - "STATUS pending_verification" - "PROVISIONING TYPE auth0_managed_certs" - 003 - unsuccessfully create domain with same name: + + 004 - unsuccessfully create domain with same name: command: auth0 domains create --domain "custom-domain.com" --no-input exit-code: 1 stderr: contains: - "An unexpected error occurred while attempting to create the custom domain 'custom-domain.com': 409 Conflict: The specified custom domain already exists" - 004 - show domain: + + 005 - show domain: command: auth0 domains show $(./test/integration/scripts/get-custom-domain-id.sh) --no-input exit-code: 0 stdout: @@ -30,7 +43,8 @@ tests: - "DOMAIN custom-domain.com" - "STATUS pending_verification" - "PROVISIONING TYPE auth0_managed_certs" - 005 - update domain minimal flags: + + 006 - update domain minimal flags: command: auth0 domains update $(./test/integration/scripts/get-custom-domain-id.sh) --no-input exit-code: 0 stdout: @@ -39,7 +53,8 @@ tests: - "DOMAIN custom-domain.com" - "STATUS pending_verification" - "PROVISIONING TYPE auth0_managed_certs" - 006 - update domain maximal flags: + + 007 - update domain maximal flags: command: auth0 domains update $(./test/integration/scripts/get-custom-domain-id.sh) --policy recommended --no-input exit-code: 0 stdout: @@ -49,7 +64,8 @@ tests: - "STATUS pending_verification" - "PROVISIONING TYPE auth0_managed_certs" - "TLS POLICY recommended" - 007 - verify domain: + + 008 - verify domain: command: auth0 domains update $(./test/integration/scripts/get-custom-domain-id.sh) --policy recommended --no-input exit-code: 0 stdout: @@ -58,10 +74,12 @@ tests: - "DOMAIN custom-domain.com" - "PROVISIONING TYPE auth0_managed_certs" - "TLS POLICY recommended" - 008 - delete domain: + + 009 - delete domain: command: auth0 domains delete $(./test/integration/scripts/get-custom-domain-id.sh) --no-input exit-code: 0 - 009 - create domain with maximal flags: + + 010 - create domain with maximal flags: command: auth0 domains create --domain "custom-domain.com" --verification txt --type self --policy recommended --no-input exit-code: 0 stdout: @@ -73,3 +91,12 @@ tests: - "VERIFICATION METHOD txt" - "TLS POLICY recommended" - "CUSTOM CLIENT IP HEADER" + + 011 - list custom domains with results: + command: auth0 domains list + exit-code: 0 + stdout: + contains: + - "ID DOMAIN STATUS" + - "cd_" + - "custom-domain.com" diff --git a/test/integration/fixtures/update-rule.json b/test/integration/fixtures/update-rule.json index 086974999..347e717d7 100644 --- a/test/integration/fixtures/update-rule.json +++ b/test/integration/fixtures/update-rule.json @@ -1,5 +1,5 @@ { - "id": "rul_LBnc1o7UxvuiEmkt", + "id": "rul_xWavq6OFKbMma9DH", "name": "integration-test-rule-betterName", "script": "function(user, context, cb) {\n cb(null, user, context);\n}\n", "order": 3, diff --git a/test/integration/logs-test-cases.yaml b/test/integration/logs-test-cases.yaml index 904a7924f..4210cdbe1 100644 --- a/test/integration/logs-test-cases.yaml +++ b/test/integration/logs-test-cases.yaml @@ -21,11 +21,17 @@ tests: contains: - Use 'auth0 logs streams create' to add one - 003 - it successfully creates a datadog log stream: + 003 - it successfully lists all log streams with no data (json): + command: auth0 logs streams list --json + exit-code: 0 + stdout: + exactly: "[]" + + 004 - it successfully creates a datadog log stream: command: ./test/integration/scripts/create-log-stream-datadog-id.sh exit-code: 0 - 004 - it successfully lists all log streams with data: + 005 - it successfully lists all log streams with data: command: auth0 logs streams list exit-code: 0 stdout: @@ -35,7 +41,7 @@ tests: - TYPE - STATUS - 005 - given a datadog log stream, it successfully gets the log stream's details: + 006 - given a datadog log stream, it successfully gets the log stream's details: command: auth0 logs streams show $(cat ./test/integration/identifiers/log-stream-datadog-id) exit-code: 0 stdout: @@ -44,7 +50,7 @@ tests: - TYPE datadog - STATUS active - 006 - given a datadog log stream, it successfully gets the log stream's details and outputs in json: + 007 - given a datadog log stream, it successfully gets the log stream's details and outputs in json: command: auth0 logs streams show $(cat ./test/integration/identifiers/log-stream-datadog-id) --json exit-code: 0 stdout: @@ -54,7 +60,7 @@ tests: status: "active" sink.datadogRegion: "eu" - 007 - given a datadog log stream, it successfully updates the log stream's details: + 008 - given a datadog log stream, it successfully updates the log stream's details: command: auth0 logs streams update datadog $(cat ./test/integration/identifiers/log-stream-datadog-id) --name integration-test-updated-datadog --region us --api-key 123123123123123 --json exit-code: 0 stdout: @@ -64,22 +70,22 @@ tests: status: "active" sink.datadogRegion: "us" - 008 - given a datadog log stream, it successfully opens the log stream's settings page: + 009 - given a datadog log stream, it successfully opens the log stream's settings page: command: auth0 logs streams open $(cat ./test/integration/identifiers/log-stream-datadog-id) --no-input exit-code: 0 stderr: contains: - "Open the following URL in a browser" - 009 - given a datadog log stream, it successfully deletes the log stream: + 010 - given a datadog log stream, it successfully deletes the log stream: command: auth0 logs streams delete $(cat ./test/integration/identifiers/log-stream-datadog-id) --force --no-input exit-code: 0 - 010 - it successfully creates an eventbridge log stream: + 011 - it successfully creates an eventbridge log stream: command: ./test/integration/scripts/create-log-stream-eventbridge-id.sh exit-code: 0 - 011 - given an eventbridge log stream, it successfully updates the log stream's details: + 012 - given an eventbridge log stream, it successfully updates the log stream's details: command: auth0 logs streams update eventbridge $(cat ./test/integration/identifiers/log-stream-eventbridge-id) --name integration-test-updated-eventbridge --json exit-code: 0 stdout: @@ -88,15 +94,15 @@ tests: type: "eventbridge" status: "active" - 012 - given an eventbridge log stream, it successfully deletes the log stream: + 013 - given an eventbridge log stream, it successfully deletes the log stream: command: auth0 logs streams delete $(cat ./test/integration/identifiers/log-stream-eventbridge-id) --force --no-input exit-code: 0 - 013 - it successfully creates an http log stream: + 014 - it successfully creates an http log stream: command: ./test/integration/scripts/create-log-stream-http-id.sh exit-code: 0 - 014 - given an http log stream, it successfully updates the log stream's details: + 015 - given an http log stream, it successfully updates the log stream's details: command: auth0 logs streams update http $(cat ./test/integration/identifiers/log-stream-http-id) --name integration-test-updated-http --endpoint "https://example.com/webhook/logs/v2" --format "JSONOBJECT" --type "application/xml" --authorization "KHEWXXXXXXXXXXXXXXXX" --json --no-input exit-code: 0 stdout: @@ -109,15 +115,15 @@ tests: sink.httpEndpoint: "https://example.com/webhook/logs/v2" sink.httpAuthorization: "KHEWXXXXXXXXXXXXXXXX" - 015 - given an http log stream, it successfully deletes the log stream: + 016 - given an http log stream, it successfully deletes the log stream: command: auth0 logs streams delete $(cat ./test/integration/identifiers/log-stream-http-id) --force --no-input exit-code: 0 - 016 - it successfully creates a splunk log stream: + 017 - it successfully creates a splunk log stream: command: ./test/integration/scripts/create-log-stream-splunk-id.sh exit-code: 0 - 017 - given a splunk log stream, it successfully updates the log stream's details: + 018 - given a splunk log stream, it successfully updates the log stream's details: command: auth0 logs streams update splunk $(cat ./test/integration/identifiers/log-stream-splunk-id) --name integration-test-updated-splunk --domain "example.splunk.com" --token "92a34ab5-c6d7-8901-23ef-456b7c89d0c1" --port 8000 --secure --json --no-input exit-code: 0 stdout: @@ -130,15 +136,15 @@ tests: sink.splunkPort: "8000" sink.splunkSecure: "true" - 018 - given a splunk log stream, it successfully deletes the log stream: + 019 - given a splunk log stream, it successfully deletes the log stream: command: auth0 logs streams delete $(cat ./test/integration/identifiers/log-stream-splunk-id) --force --no-input exit-code: 0 - 019 - it successfully creates a sumo log stream: + 020 - it successfully creates a sumo log stream: command: ./test/integration/scripts/create-log-stream-sumo-id.sh exit-code: 0 - 020 - given a sumo log stream, it successfully updates the log stream's details: + 021 - given a sumo log stream, it successfully updates the log stream's details: command: auth0 logs streams update sumo $(cat ./test/integration/identifiers/log-stream-sumo-id) --name integration-test-updated-sumo --source "example.sumo.com" --json --no-input exit-code: 0 stdout: @@ -148,6 +154,6 @@ tests: status: "active" sink.sumoSourceAddress: "example.sumo.com" - 021 - given a sumo log stream, it successfully deletes the log stream: + 022 - given a sumo log stream, it successfully deletes the log stream: command: auth0 logs streams delete $(cat ./test/integration/identifiers/log-stream-sumo-id) --force --no-input exit-code: 0 diff --git a/test/integration/organizations-test-cases.yaml b/test/integration/organizations-test-cases.yaml index b7b9da5a7..50b44b8c5 100644 --- a/test/integration/organizations-test-cases.yaml +++ b/test/integration/organizations-test-cases.yaml @@ -10,14 +10,20 @@ tests: contains: - Use 'auth0 orgs create' to add one - 002 - list organizations with invalid number arg: + 002 - list organizations with no data (json): + command: auth0 orgs list --json + exit-code: 0 + stdout: + exactly: "[]" + + 003 - list organizations with invalid number arg: command: auth0 orgs list -n 1001 exit-code: 1 stderr: contains: - number flag invalid, please pass a number between 1 and 1000 - 003 - create organization and check json output: + 004 - create organization and check json output: command: auth0 orgs create --name integration-test-org-new --display "Integration Test Organization" --json --no-input exit-code: 0 stdout: @@ -25,7 +31,7 @@ tests: name: "integration-test-org-new" display_name: "Integration Test Organization" - 004 - create organization and check table output: + 005 - create organization and check table output: command: auth0 orgs create --name integration-test-org-new2 --display "Integration Test Organization2" --metadata "KEY=value" --logo "https://example.com/logo.png" --accent "#FFFFFF" --background "#FFFFFF" --no-input exit-code: 0 stdout: @@ -37,14 +43,14 @@ tests: - "ACCENT COLOR #FFFFFF" - "BACKGROUND COLOR #FFFFFF" - 005 - attempt to create organization with a name that already exists: + 006 - attempt to create organization with a name that already exists: command: auth0 orgs create --name integration-test-org-new2 exit-code: 1 stderr: contains: - failed to create an organization with name 'integration-test-org-new2' - - 006 - list organizations with data: + + 007 - list organizations with data: command: auth0 orgs list exit-code: 0 stdout: @@ -53,7 +59,7 @@ tests: - NAME - DISPLAY NAME - 007 - show organization and check json output: + 008 - show organization and check json output: command: auth0 orgs show $(./test/integration/scripts/get-org-id.sh) --json exit-code: 0 stdout: @@ -61,7 +67,7 @@ tests: name: "integration-test-org-better" display_name: "Integration Test Better Organization" - 008 - show organization and check table output: + 009 - show organization and check table output: command: auth0 orgs show $(./test/integration/scripts/get-org-id.sh) exit-code: 0 stdout: @@ -69,14 +75,14 @@ tests: - NAME integration-test-org-better - DISPLAY NAME Integration Test Better Organization - 009 - show organization with invalid organization ID: + 010 - show organization with invalid organization ID: command: auth0 orgs show "this-org-id-does-not-exist" exit-code: 1 stderr: contains: - "Unable to get an organization with ID 'this-org-id-does-not-exist'" - 010 - update organization with minimal flags: + 011 - update organization with minimal flags: command: auth0 orgs update $(./test/integration/scripts/get-org-id.sh) --no-input exit-code: 0 stdout: @@ -88,7 +94,7 @@ tests: - LOGO URL - METADATA null - 011 - update organization with all flags: + 012 - update organization with all flags: command: auth0 orgs update $(./test/integration/scripts/get-org-id.sh) -d "Integration Test Updated Organization" -a "#00FFAA" -b "#AA1166" -m "FOO=bar" -l "https://example.com/logo.png" --json --no-input exit-code: 0 stdout: @@ -99,7 +105,7 @@ tests: branding.colors.primary: "#00FFAA" metadata.FOO: "bar" - 012 - open organization dashboard view in browser: + 013 - open organization dashboard view in browser: command: auth0 orgs open $(./test/integration/scripts/get-org-id.sh) --no-input exit-code: 0 stderr: @@ -107,18 +113,17 @@ tests: - "Open the following URL in a browser: https://manage.auth0.com/dashboard/" - "/organizations/org_" - 013 - list organization members should return an empty array if no members found: + 014 - list organization members should return an empty array if no members found: command: auth0 orgs members list $(./test/integration/scripts/get-org-id.sh) --json exit-code: 0 stdout: - contains: - - "[]" + exactly: "[]" - 014 - add organization members: + 015 - add organization members: command: auth0 api POST "organizations/$(./test/integration/scripts/get-org-id.sh)/members" --data "{\"members\":[\"$(./test/integration/scripts/get-user-id.sh)\"]}" exit-code: 0 - 015 - list organization members: + 016 - list organization members: command: auth0 orgs members list $(./test/integration/scripts/get-org-id.sh) exit-code: 0 stdout: @@ -130,7 +135,7 @@ tests: config: retries: 3 - 016 - list organization members as json: + 017 - list organization members as json: command: auth0 orgs members list $(./test/integration/scripts/get-org-id.sh) --json exit-code: 0 stdout: @@ -140,7 +145,7 @@ tests: config: retries: 3 - 017 - list organization members with invalid number: + 018 - list organization members with invalid number: command: auth0 orgs members list $(./test/integration/scripts/get-org-id.sh) --number 1001 exit-code: 1 stderr: @@ -149,22 +154,22 @@ tests: config: retries: 3 - 018 - list organization roles: + 019 - list organization roles: command: auth0 orgs roles list $(./test/integration/scripts/get-org-id.sh) exit-code: 0 - 019 - list organization roles with invalid number: + 020 - list organization roles with invalid number: command: auth0 orgs roles list $(./test/integration/scripts/get-org-id.sh) --number 1001 exit-code: 1 stderr: contains: - number flag invalid, please pass a number between 1 and 1000 - 020 - list organization roles members: + 021 - list organization roles members: command: auth0 orgs roles members list $(./test/integration/scripts/get-org-id.sh) exit-code: 0 - 021 - list organization roles members with invalid number: + 022 - list organization roles members with invalid number: command: auth0 orgs roles members list $(./test/integration/scripts/get-org-id.sh) --number 1001 exit-code: 1 stderr: diff --git a/test/integration/roles-permissions-test-cases.yaml b/test/integration/roles-permissions-test-cases.yaml deleted file mode 100644 index 7910020ea..000000000 --- a/test/integration/roles-permissions-test-cases.yaml +++ /dev/null @@ -1,49 +0,0 @@ -config: - inherit-env: true - -tests: - 001 - list role permissions with no data: - command: auth0 roles permissions ls $(./test/integration/scripts/get-role-id.sh) - exit-code: 0 - stderr: - contains: - - No role permissions available. - - 002 - list role permissions with invalid number: - command: auth0 roles permissions ls $(./test/integration/scripts/get-role-id.sh) --number -1 - exit-code: 1 - stderr: - contains: - - number flag invalid, please pass a number between 1 and 1000 - - 003 - add role permissions: - command: auth0 roles permissions add $(./test/integration/scripts/get-role-id.sh) --api-id $(./test/integration/scripts/get-api-id.sh) --permissions read:todos - exit-code: 0 - stderr: - contains: - - Added permissions read:todos (http://integration-test-api-newapi) to role integration-test-role-newRole. - - 004 - list role permissions with data: - command: auth0 roles permissions ls $(./test/integration/scripts/get-role-id.sh) - exit-code: 0 - stdout: - contains: - - API IDENTIFIER API NAME PERMISSION NAME DESCRIPTION - - http://integration-test-api-newapi integration-test-api-betterApiName read:todos - - 005 - list role permissions with data as json: - command: auth0 roles permissions ls $(./test/integration/scripts/get-role-id.sh) --json - exit-code: 0 - stdout: - json: - 0.resource_server_identifier: "http://integration-test-api-newapi" - 0.resource_server_name: "integration-test-api-betterApiName" - 0.permission_name: "read:todos" - 0.description: "" - - 006 - remove role permissions: - command: auth0 roles permissions rm $(./test/integration/scripts/get-role-id.sh) --api-id $(./test/integration/scripts/get-api-id.sh) --permissions read:todos - exit-code: 0 - stderr: - contains: - - Removed permissions read:todos (http://integration-test-api-newapi) from role integration-test-role-newRole. diff --git a/test/integration/roles-test-cases.yaml b/test/integration/roles-test-cases.yaml new file mode 100644 index 000000000..c8fa9fbcf --- /dev/null +++ b/test/integration/roles-test-cases.yaml @@ -0,0 +1,135 @@ +config: + inherit-env: true + retries: 1 + +tests: + 001 - roles list no results: + command: auth0 roles list + exit-code: 0 + stderr: + contains: + - "No roles available." + - "Use 'auth0 roles create' to add one" + + 002 - roles list no results (json): + command: auth0 roles list --json + exit-code: 0 + stdout: + exactly: "[]" + + 003 - roles create and check data: + command: auth0 roles create --name integration-test-role-new1 --description testRole --json --no-input + exit-code: 0 + stdout: + json: + name: integration-test-role-new1 + description: testRole + + 004 - roles create and check output: + command: auth0 roles create --name integration-test-role-new2 --description testRole2 --no-input + stdout: + contains: + - NAME integration-test-role-new2 + - DESCRIPTION testRole2 + exit-code: 0 + + 005 - roles list all with data: + command: auth0 roles list + exit-code: 0 + stdout: + contains: + - ID + - NAME + - DESCRIPTION + + 006 - roles list all with invalid number: + command: auth0 roles list --number 1001 + exit-code: 1 + stderr: + contains: + - number flag invalid, please pass a number between 1 and 1000 + + 007 - roles show json: + command: auth0 roles show $(./test/integration/scripts/get-role-id.sh) --json + stdout: + json: + name: integration-test-role-newRole + description: integration-test-role + exit-code: 0 + + 008 - roles show: + command: auth0 roles show $(./test/integration/scripts/get-role-id.sh) + stdout: + contains: + - NAME integration-test-role-newRole + - DESCRIPTION integration-test-role + exit-code: 0 + + 009 - roles update name: + command: auth0 roles update $(./test/integration/scripts/get-role-id.sh) --name integration-test-role-betterName --json + stdout: + json: + name: integration-test-role-betterName + exit-code: 0 + + 010 - roles update description: + command: auth0 roles update $(./test/integration/scripts/get-role-id.sh) --description betterDescription --json + stdout: + json: + description: betterDescription + exit-code: 0 + + 011 - list role permissions with no data: + command: auth0 roles permissions ls $(./test/integration/scripts/get-role-id.sh) + exit-code: 0 + stderr: + contains: + - No role permissions available. + + 012 - list role permissions with no data (JSON): + command: auth0 roles permissions ls $(./test/integration/scripts/get-role-id.sh) --json + exit-code: 0 + stdout: + exactly: "[]" + + 013 - list role permissions with invalid number: + command: auth0 roles permissions ls $(./test/integration/scripts/get-role-id.sh) --number -1 + exit-code: 1 + stderr: + contains: + - number flag invalid, please pass a number between 1 and 1000 + + 014 - add role permissions: + command: auth0 roles permissions add $(./test/integration/scripts/get-role-id.sh) --api-id $(./test/integration/scripts/get-api-id.sh) --permissions read:todos + exit-code: 0 + stderr: + contains: + - Added permissions read:todos (http://integration-test-api-newapi) to role integration-test-role-betterName. + + 015 - list role permissions with data: + command: auth0 roles permissions ls $(./test/integration/scripts/get-role-id.sh) + exit-code: 0 + stdout: + contains: + - API IDENTIFIER + - API NAME + - PERMISSION NAME + - DESCRIPTION + - http://integration-test-api-newapi + - read:todos + + 016 - list role permissions with data as json: + command: auth0 roles permissions ls $(./test/integration/scripts/get-role-id.sh) --json + exit-code: 0 + stdout: + json: + 0.resource_server_identifier: "http://integration-test-api-newapi" + 0.permission_name: "read:todos" + 0.description: "" + + 017 - remove role permissions: + command: auth0 roles permissions rm $(./test/integration/scripts/get-role-id.sh) --api-id $(./test/integration/scripts/get-api-id.sh) --permissions read:todos + exit-code: 0 + stderr: + contains: + - Removed permissions read:todos (http://integration-test-api-newapi) from role integration-test-role-betterName. diff --git a/test/integration/rules-test-cases.yaml b/test/integration/rules-test-cases.yaml new file mode 100644 index 000000000..9d61c5a69 --- /dev/null +++ b/test/integration/rules-test-cases.yaml @@ -0,0 +1,88 @@ +config: + inherit-env: true + retries: 1 + +tests: + 001 - rules list no results: + command: auth0 rules list + exit-code: 0 + stderr: + contains: + - No rules available. + - Use 'auth0 rules create' to add one + + 002 - rules list no results (json): + command: auth0 rules list --json + exit-code: 0 + stdout: + exactly: "[]" + + 003 - rules create and check data: + command: cat ./test/integration/fixtures/create-rule.json | jq '.[0]' | auth0 rules create --json + stdout: + json: + name: integration-test-rule-new1 + enabled: "true" + order: "1" + script: "function(user, context, cb) {\n cb(null, user, context);\n}\n" + exit-code: 0 + + 004 - rules create and check output: + command: cat ./test/integration/fixtures/create-rule.json | jq '.[1]' | auth0 rules create + stdout: + contains: + - NAME integration-test-rule-new2 + - ENABLED ✗ + - ORDER 2 + - SCRIPT function(user, context, cb) { + exit-code: 0 + + 005 - rules list all with data: + command: auth0 rules list + exit-code: 0 + stdout: + contains: + - ID + - NAME + - ENABLED + - ORDER + + 006 - rules show json: + command: auth0 rules show $(./test/integration/scripts/get-rule-id.sh) --json + stdout: + json: + name: integration-test-rule-newRule + enabled: "false" + order: "3" + exit-code: 0 + + 007 - rules show: + command: auth0 rules show $(./test/integration/scripts/get-rule-id.sh) + stdout: + contains: + - NAME integration-test-rule-newRule + - ENABLED ✗ + - ORDER 3 + exit-code: 0 + + 008 - rules update: + command: cat ./test/integration/fixtures/update-rule.json | auth0 rules update --json + stdout: + json: + name: integration-test-rule-betterName + enabled: "false" + exit-code: 0 + + 009 - rules enable: + command: auth0 rules enable $(./test/integration/scripts/get-rule-id.sh) --json + stdout: + json: + enabled: "true" + exit-code: 0 + + 010 - rules disable: + command: auth0 rules disable $(./test/integration/scripts/get-rule-id.sh) --json + stdout: + json: + enabled: "false" + exit-code: 0 diff --git a/test/integration/test-cases.yaml b/test/integration/test-cases.yaml index e1e06ae7c..f266a8e29 100644 --- a/test/integration/test-cases.yaml +++ b/test/integration/test-cases.yaml @@ -6,12 +6,6 @@ tests: auth0 tenants list: exit-code: 0 - auth0 roles list: - exit-code: 0 - - auth0 rules list: - exit-code: 0 - auth0 completion bash: exit-code: 0 @@ -24,144 +18,6 @@ tests: auth0 completion powershell: exit-code: 0 - # Test 'roles create' - roles create and check data: - command: auth0 roles create --name integration-test-role-new1 --description testRole --json --no-input - exit-code: 0 - stdout: - json: - name: integration-test-role-new1 - description: testRole - - roles create and check output: - command: auth0 roles create --name integration-test-role-new2 --description testRole2 --no-input - stdout: - contains: - - NAME integration-test-role-new2 - - DESCRIPTION testRole2 - exit-code: 0 - - roles list all with data: - command: auth0 roles list - exit-code: 0 - stdout: - contains: - - ID - - NAME - - DESCRIPTION - - roles list all with invalid number: - command: auth0 roles list --number 1001 - exit-code: 1 - stderr: - contains: - - number flag invalid, please pass a number between 1 and 1000 - - roles show json: - command: auth0 roles show $(./test/integration/scripts/get-role-id.sh) --json - stdout: - json: - name: integration-test-role-newRole - description: integration-test-role - exit-code: 0 - - roles show: - command: auth0 roles show $(./test/integration/scripts/get-role-id.sh) - stdout: - contains: - - NAME integration-test-role-newRole - - DESCRIPTION integration-test-role - exit-code: 0 - - # Test 'roles update' - roles update name: - command: auth0 roles update $(./test/integration/scripts/get-role-id.sh) --name integration-test-role-betterName --json - stdout: - json: - name: integration-test-role-betterName - exit-code: 0 - - roles update description: - command: auth0 roles update $(./test/integration/scripts/get-role-id.sh) --description betterDescription --json - stdout: - json: - description: betterDescription - exit-code: 0 - - # Test 'rules create' - rules create and check data: - command: cat ./test/integration/fixtures/create-rule.json | jq '.[0]' | auth0 rules create --json - stdout: - json: - name: integration-test-rule-new1 - enabled: "true" - order: "1" - script: "function(user, context, cb) {\n cb(null, user, context);\n}\n" - exit-code: 0 - - rules create and check output: - command: cat ./test/integration/fixtures/create-rule.json | jq '.[1]' | auth0 rules create - stdout: - contains: - - NAME integration-test-rule-new2 - - ENABLED ✗ - - ORDER 2 - - SCRIPT function(user, context, cb) { - exit-code: 0 - - rules list all with data: - command: auth0 rules list - exit-code: 0 - stdout: - contains: - - ID - - NAME - - ENABLED - - ORDER - - rules show json: - command: auth0 rules show $(./test/integration/scripts/get-rule-id.sh) --json - stdout: - json: - name: integration-test-rule-newRule - enabled: "true" - order: "3" - exit-code: 0 - - rules show: - command: auth0 rules show $(./test/integration/scripts/get-rule-id.sh) - stdout: - contains: - - NAME integration-test-rule-newRule - - ENABLED ✓ - - ORDER 3 - exit-code: 0 - - # Test 'rules update' - rules update: - command: cat ./test/integration/fixtures/update-rule.json | auth0 rules update --json - stdout: - json: - name: integration-test-rule-betterName - enabled: "false" - exit-code: 0 - - # Test 'rules enable' - rules enable: - command: auth0 rules enable $(./test/integration/scripts/get-rule-id.sh) --json - stdout: - json: - enabled: "true" - exit-code: 0 - - # Test 'rules disable' - rules disable: - command: auth0 rules disable $(./test/integration/scripts/get-rule-id.sh) --json - stdout: - json: - enabled: "false" - exit-code: 0 - attack protection breached password detection show: command: auth0 attack-protection breached-password-detection show stdout: diff --git a/test/integration/users-test-cases.yaml b/test/integration/users-test-cases.yaml index d1a6eff31..c47dc2f2b 100644 --- a/test/integration/users-test-cases.yaml +++ b/test/integration/users-test-cases.yaml @@ -75,40 +75,55 @@ tests: connection: Username-Password-Authentication exit-code: 0 - 010 - users roles show: + 010 - users roles show no results: command: auth0 users roles show $(./test/integration/scripts/get-user-id.sh) exit-code: 0 + stderr: + contains: + - "No user roles available. Use 'auth0 users roles assign' to assign roles to a user" + + 011 - users roles show no results (json): + command: auth0 users roles show $(./test/integration/scripts/get-user-id.sh) --json + exit-code: 0 + stdout: + exactly: "[]" - 011 - users roles show with invalid number: + 012 - users roles show with invalid number: command: auth0 users roles show $(./test/integration/scripts/get-user-id.sh) --number 1001 exit-code: 1 stderr: contains: - number flag invalid, please pass a number between 1 and 1000 - 012 - users roles add: + 013 - users roles add: command: auth0 users roles add $(./test/integration/scripts/get-user-id.sh) -r $(./test/integration/scripts/get-role-id.sh) exit-code: 0 - 013 - users roles remove: + 014 - users roles remove: command: auth0 users roles rm $(./test/integration/scripts/get-user-id.sh) -r $(./test/integration/scripts/get-role-id.sh) exit-code: 0 - 014 - users blocks list: + 015 - users blocks list: command: auth0 users blocks list $(./test/integration/scripts/get-user-id.sh) exit-code: 0 stderr: contains: - No user blocks available. - 015 - open user dashboard page: + 016 - users blocks list (json): + command: auth0 users blocks list $(./test/integration/scripts/get-user-id.sh) --json + exit-code: 0 + stdout: + exactly: "[]" + + 017 - open user dashboard page: command: auth0 users open $(./test/integration/scripts/get-user-id.sh) --no-input exit-code: 0 stderr: contains: - "Open the following URL in a browser: https://manage.auth0.com/dashboard/" - 016 - users import: + 018 - users import: command: auth0 users import -c "Username-Password-Authentication" --users "[]" --email-results=false --no-input exit-code: 0 stderr: @@ -118,7 +133,7 @@ tests: - "successfully started" - "to get the status of the job" - 017 - users import with piped data: + 019 - users import with piped data: command: echo "[]" | auth0 users import -c "Username-Password-Authentication" --email-results=false --no-input exit-code: 0 stderr: