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

[CLI-164] users integration test #300

Merged
merged 4 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions commander.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,56 @@ tests:
json:
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 --format 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 --no-input
exit-code: 0
stdout:
contains:
- EMAIL [email protected]
- CONNECTION Username-Password-Authentication

# Test 'users show'
users create test user:
command: ./integration/get-user-id.sh
exit-code: 0

users show json:
command: auth0 users show $(cat ./integration/identifiers/user-id) --format json
stdout:
json:
Email: "[email protected]"
Connection: "Username-Password-Authentication"
exit-code: 0

users show:
command: auth0 users show $(cat ./integration/identifiers/user-id)
stdout:
contains:
- EMAIL [email protected]
- CONNECTION Username-Password-Authentication
exit-code: 0

# Test 'users update'
users update email:
command: auth0 users update $(cat ./integration/identifiers/user-id) --email [email protected] --format json --no-input
stdout:
json:
Email: [email protected]
exit-code: 0

users update name:
command: auth0 users update $(cat ./integration/identifiers/user-id) --name integration-test-user-bettername --format json --no-input
stdout:
json:
Email: [email protected] # Name is not being displayed, hence using email
exit-code: 0
6 changes: 6 additions & 0 deletions integration/get-user-id.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /bin/bash

user=$( auth0 users create -n integration-test-user-better -c Username-Password-Authentication -e [email protected] -p testUser12 --format json --no-input )

mkdir -p ./integration/identifiers
echo "$user" | jq -r '.["UserID"]' > ./integration/identifiers/user-id
17 changes: 17 additions & 0 deletions integration/test-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,20 @@ for api in $( echo "${apis}" | jq -r '.[] | @base64' ); do
$( auth0 apis delete "$id")
fi
done

# using the search command since users have no list command
users=$( auth0 users search -q "*" --format json --no-input )

for user in $( echo "${users}" | jq -r '.[] | @base64' ); do
_jq() {
echo "${user}" | base64 --decode | jq -r "${1}"
}

userid=$(_jq '.UserID')
# created during the same test session
if [[ integration-* ]]
then
echo deleting "$userid"
$( auth0 users delete "$userid")
fi
done
8 changes: 5 additions & 3 deletions pkg/auth0-cli-config-generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ type params struct {
}

var requiredScopes = []string{
// "openid",
// "offline_access", // <-- to get a refresh token.
//"openid",
//"offline_access", // <-- to get a refresh token.
"create:clients", "delete:clients", "read:clients", "update:clients",
"create:resource_servers", "delete:resource_servers", "read:resource_servers", "update:resource_servers",
"create:roles", "delete:roles", "read:roles", "update:roles",
"create:rules", "delete:rules", "read:rules", "update:rules",
"read:client_keys", "read:logs", "read:connections", "update:connections",
"create:users", "delete:users", "read:users", "update:users",
"read:branding", "update:branding",
"read:connections", "update:connections",
"read:client_keys", "read:logs", "read:tenant_settings", "read:custom_domains",
"read:anomaly_blocks", "delete:anomaly_blocks",
}

func (p params) validate() error {
Expand Down