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-167] integration test for roles #309

Merged
merged 2 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
56 changes: 56 additions & 0 deletions commander.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ tests:
auth0 tenants list:
exit-code: 0

auth0 roles list:
exit-code: 0

auth0 rules list:
exit-code: 0

Expand Down Expand Up @@ -426,4 +429,57 @@ tests:
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 --format 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

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

roles show json:
command: auth0 roles show $(cat ./integration/identifiers/role-id) --format json
stdout:
json:
Name: integration-test-role-newRole
Description: integration-test-role
exit-code: 0

roles show:
command: auth0 roles show $(cat ./integration/identifiers/role-id)
stdout:
contains:
- NAME integration-test-role-newRole
- DESCRIPTION integration-test-role
exit-code: 0

# Test 'roles update'
roles update name:
command: auth0 roles update $(cat ./integration/identifiers/role-id) --name integration-test-role-betterName --format json
stdout:
json:
Name: integration-test-role-betterName
exit-code: 0

roles update description:
command: auth0 roles update $(cat ./integration/identifiers/role-id) --description betterDescription --format json
stdout:
json:
Description: betterDescription
exit-code: 0
6 changes: 6 additions & 0 deletions integration/get-role-id.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /bin/bash

role=$( auth0 roles create -n integration-test-role-newRole -d integration-test-role --format json --no-input )

mkdir -p ./integration/identifiers
echo "$role" | jq -r '.["ID"]' > ./integration/identifiers/role-id
18 changes: 18 additions & 0 deletions integration/test-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,22 @@ for user in $( echo "${users}" | jq -r '.[] | @base64' ); do
echo deleting "$userid"
$( auth0 users delete "$userid")
fi
done

roles=$( auth0 roles list --format json --no-input )

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

id=$(_jq '.ID')
name=$(_jq '.Name')
# TODO(jfatta): should remove only those
# created during the same test session
if [[ $name = integration-test-role-* ]]
then
echo deleting "$name"
$( auth0 roles delete "$id")
fi
done