diff --git a/internal/cli/organizations.go b/internal/cli/organizations.go index 9ddcfcf2a..9413b477e 100644 --- a/internal/cli/organizations.go +++ b/internal/cli/organizations.go @@ -781,7 +781,7 @@ func (cli *cli) getOrgMembers( }) if err != nil { - return nil, fmt.Errorf("Unable to list members of an organization with Id '%s': %w", orgID, err) + return nil, fmt.Errorf("Unable to list members of an organization with ID '%s': %w", orgID, err) } var typedList []management.OrganizationMember for _, item := range list { diff --git a/internal/cli/users.go b/internal/cli/users.go index a7ead61d4..913c841b3 100644 --- a/internal/cli/users.go +++ b/internal/cli/users.go @@ -460,15 +460,11 @@ func updateUserCmd(cli *cli) *cobra.Command { user.Name = &inputs.Name } - if len(inputs.Email) == 0 { - user.Email = current.Email - } else { + if len(inputs.Email) != 0 { user.Email = &inputs.Email } - if len(inputs.Password) == 0 { - user.Password = current.Password - } else { + if len(inputs.Password) != 0 { user.Password = &inputs.Password } diff --git a/test/integration/test-cases.yaml b/test/integration/test-cases.yaml index 915592809..36b75d3a6 100644 --- a/test/integration/test-cases.yaml +++ b/test/integration/test-cases.yaml @@ -145,61 +145,6 @@ tests: allow_offline_access: "false" exit-code: 0 - # Test 'users create' - users create and check data: - command: auth0 users create --name integration-test-user-new --connection Username-Password-Authentication --email testuser@example.com --password testUser12 --username testuser1 --json --no-input - exit-code: 0 - stdout: - json: - email: "testuser@example.com" - connection: "Username-Password-Authentication" - - users create and check output: - command: auth0 users create --name integration-test-user-new2 --connection Username-Password-Authentication --email testuser2@example.com --password testUser12 --username testuser2 --no-input - exit-code: 0 - stdout: - contains: - - EMAIL testuser2@example.com - - CONNECTION Username-Password-Authentication - - users show json: - command: auth0 users show $(./test/integration/scripts/get-user-id.sh) --json - stdout: - json: - email: "newuser@example.com" - connection: "Username-Password-Authentication" - exit-code: 0 - - users show: - command: auth0 users show $(./test/integration/scripts/get-user-id.sh) - stdout: - contains: - - EMAIL newuser@example.com - - CONNECTION Username-Password-Authentication - exit-code: 0 - - users search: - command: auth0 users search --query user_id:"$(./test/integration/scripts/get-user-id.sh)" --number 1 --sort "name:-1" - exit-code: 0 - stdout: - contains: - - newuser@example.com - - # Test 'users update' - users update email: - command: auth0 users update $(./test/integration/scripts/get-user-id.sh) --email betteruser@example.com --json --no-input - stdout: - json: - email: betteruser@example.com - exit-code: 0 - - users update name: - command: auth0 users update $(./test/integration/scripts/get-user-id.sh) --name integration-test-user-bettername --json --no-input - stdout: - json: - email: betteruser@example.com # Name is not being displayed, hence using email - 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 @@ -387,15 +332,3 @@ tests: update universal login branding prompts (mfa-push): command: cat ./test/integration/fixtures/update-ul-prompts-mfa-push.json | auth0 ul prompts update mfa-push exit-code: 0 - - users roles show: - command: auth0 users roles show $(./test/integration/scripts/get-user-id.sh) - exit-code: 0 - - 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 - - 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 diff --git a/test/integration/users-test-cases.yaml b/test/integration/users-test-cases.yaml new file mode 100644 index 000000000..235968c18 --- /dev/null +++ b/test/integration/users-test-cases.yaml @@ -0,0 +1,94 @@ +config: + inherit-env: true + +tests: + 001 - users create and check data: + command: auth0 users create --name integration-test-user-new --connection Username-Password-Authentication --email testuser@example.com --password testUser12 --username testuser1 --json --no-input + exit-code: 0 + stdout: + json: + email: "testuser@example.com" + connection: "Username-Password-Authentication" + + 002 - users create and check output: + command: auth0 users create --name integration-test-user-new2 --connection Username-Password-Authentication --email testuser2@example.com --password testUser12 --username testuser2 --no-input + exit-code: 0 + stdout: + contains: + - EMAIL testuser2@example.com + - CONNECTION Username-Password-Authentication + + 003 - users create test user: + command: ./test/integration/scripts/get-user-id.sh + exit-code: 0 + + 004 - users show json: + command: auth0 users show $(./test/integration/scripts/get-user-id.sh) --json + stdout: + json: + email: "newuser@example.com" + connection: "Username-Password-Authentication" + exit-code: 0 + + 005 - users show: + command: auth0 users show $(./test/integration/scripts/get-user-id.sh) + stdout: + contains: + - EMAIL newuser@example.com + - CONNECTION Username-Password-Authentication + exit-code: 0 + + 005 - users search: + command: auth0 users search --query user_id:"$(./test/integration/scripts/get-user-id.sh)" --number 1 --sort "name:-1" + exit-code: 0 + stdout: + contains: + - newuser@example.com + 006 - users search with invalid number flag: + command: auth0 users search --query "*" --number 1001 + exit-code: 1 + stderr: + contains: + - number flag invalid, please pass a number between 1 and 1000 + + 007 - users update minimal flags: + command: auth0 users update $(./test/integration/scripts/get-user-id.sh) --json --no-input + stdout: + contains: + - "id" + exit-code: 0 + + 008 - users update password: #needs to be done in isolation + command: auth0 users update $(./test/integration/scripts/get-user-id.sh) --password 'S0me-new-P@$$Word' --json --no-input + stdout: + json: + password: "S0me-new-P@$$Word" + exit-code: 0 + + 009 - users update maximal flags: + command: auth0 users update $(./test/integration/scripts/get-user-id.sh) --email betteruser@example.com --connection Username-Password-Authentication --name integration-test-user-bettername --json --no-input + stdout: + json: + email: betteruser@example.com + name: integration-test-user-bettername + connection: Username-Password-Authentication + exit-code: 0 + + 010 - users roles show: + command: auth0 users roles show $(./test/integration/scripts/get-user-id.sh) + exit-code: 0 + + 011 - 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 + + 012 - 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 + + 013 - 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/"