test: extract common JTW code from the multi-tenancy.sh test
Move some code related to using JWT tokens from the `multi-tenancy.sh` test case to `test/cases/api/common/common.sh`, `tools/provision.sh` and `tools/run-mock-auth-servers.sh`. Move the composer and worker configuration from the test to new testing configuration files. The `tools/provision.sh` now accepts an optional argument specifying the authentication method to use with the provisioned composer and workers. Valid values are `tls` and `jwt`. If no argument is specified, the `tls` option is used and the script defaults to its previous behavior.
This commit is contained in:
parent
faf911cd21
commit
765d218b6f
7 changed files with 164 additions and 101 deletions
|
|
@ -44,3 +44,28 @@ function _instanceCheck() {
|
|||
echo "Not RHEL OS. Skip subscription check."
|
||||
fi
|
||||
}
|
||||
|
||||
# Fetch a JWT token
|
||||
function access_token {
|
||||
# Refresh token represents the ORG ID
|
||||
local refresh_token="$1"
|
||||
curl --request POST \
|
||||
--data "refresh_token=$refresh_token" \
|
||||
--header "Content-Type: application/x-www-form-urlencoded" \
|
||||
--silent \
|
||||
--show-error \
|
||||
--fail \
|
||||
localhost:8081/token | jq -r .access_token
|
||||
}
|
||||
|
||||
# Get the compose status using a JWT token
|
||||
function compose_status {
|
||||
local compose="$1"
|
||||
local refresh_token="$2"
|
||||
curl \
|
||||
--silent \
|
||||
--show-error \
|
||||
--fail \
|
||||
--header "Authorization: Bearer $(access_token "$refresh_token")" \
|
||||
"http://localhost:443/api/image-builder-composer/v2/composes/$compose"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue