Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DXCDT-409: Users commands integration tests #686

Merged
merged 11 commits into from
Mar 30, 2023
2 changes: 1 addition & 1 deletion internal/cli/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 2 additions & 6 deletions internal/cli/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Comment on lines +463 to +467
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a bug where password would not be able to be update because you cannot update both email and password simultaneously.

user.Password = &inputs.Password
}

Expand Down
67 changes: 0 additions & 67 deletions test/integration/test-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] --password testUser12 --username testuser1 --json --no-input
exit-code: 0
stdout:
json:
email: "[email protected]"
connection: "Username-Password-Authentication"

users create and check output:
command: auth0 users create --name integration-test-user-new2 --connection Username-Password-Authentication --email [email protected] --password testUser12 --username testuser2 --no-input
exit-code: 0
stdout:
contains:
- EMAIL [email protected]
- CONNECTION Username-Password-Authentication

users show json:
command: auth0 users show $(./test/integration/scripts/get-user-id.sh) --json
stdout:
json:
email: "[email protected]"
connection: "Username-Password-Authentication"
exit-code: 0

users show:
command: auth0 users show $(./test/integration/scripts/get-user-id.sh)
stdout:
contains:
- EMAIL [email protected]
- 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:
- [email protected]

# Test 'users update'
users update email:
command: auth0 users update $(./test/integration/scripts/get-user-id.sh) --email [email protected] --json --no-input
stdout:
json:
email: [email protected]
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: [email protected] # 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
Expand Down Expand Up @@ -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
94 changes: 94 additions & 0 deletions test/integration/users-test-cases.yaml
Original file line number Diff line number Diff line change
@@ -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 [email protected] --password testUser12 --username testuser1 --json --no-input
exit-code: 0
stdout:
json:
email: "[email protected]"
connection: "Username-Password-Authentication"

002 - users create and check output:
command: auth0 users create --name integration-test-user-new2 --connection Username-Password-Authentication --email [email protected] --password testUser12 --username testuser2 --no-input
exit-code: 0
stdout:
contains:
- EMAIL [email protected]
- 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: "[email protected]"
connection: "Username-Password-Authentication"
exit-code: 0

005 - users show:
command: auth0 users show $(./test/integration/scripts/get-user-id.sh)
stdout:
contains:
- EMAIL [email protected]
- 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:
- [email protected]
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 [email protected] --connection Username-Password-Authentication --name integration-test-user-bettername --json --no-input
stdout:
json:
email: [email protected]
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/"