Skip to content

Commit

Permalink
[CLI-164] users integration test (#300)
Browse files Browse the repository at this point in the history
* [CLI-164] users integration test

* [CLI-164] updated scopes

* [CLI-164] updated scopes

Co-authored-by: Rita Zerrizuela <[email protected]>
  • Loading branch information
bright-poku and Widcket authored May 25, 2021
1 parent c5ff007 commit f0f9ca4
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 3 deletions.
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

0 comments on commit f0f9ca4

Please sign in to comment.