Skip to content

Commit

Permalink
[CLI-167] integration test for roles (#309)
Browse files Browse the repository at this point in the history
* [CLI-167] integration test for roles

* Update integration/get-role-id.sh

Co-authored-by: Rita Zerrizuela <[email protected]>
  • Loading branch information
bright-poku and Widcket authored Jun 8, 2021
1 parent 22e4114 commit 383439d
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
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

0 comments on commit 383439d

Please sign in to comment.