-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DXCDT-501:
auth0 tf generate
end-to-end tests (#848)
* Allowing relationship resources to be included in resource argument flag * Changing provider version to 1.0.0-beta.4 * Removing auth0_log_stream from default list * Adding experimental designation * Adding reference to guide, examples * Updating changelog * Doc tweaks * Fixing example indentation * Fixing flaky unit test * Changing note to warning * Removing export alias, adding abbreviated args * Adding script, updating tests * Adding tests, scripts * Making test script executable * Making test script executable --------- Co-authored-by: Will Vedder <[email protected]>
- Loading branch information
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
test/integration/scripts/assert-tf-generate-files-exist.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
if [[ $1 == *partial_success* ]]; then | ||
files=( | ||
"tmp-tf-gen/auth0_import.tf" | ||
"tmp-tf-gen/auth0_main.tf" | ||
) | ||
else | ||
files=( | ||
"tmp-tf-gen/auth0_generated.tf" | ||
"tmp-tf-gen/auth0_import.tf" | ||
"tmp-tf-gen/auth0_main.tf" | ||
"tmp-tf-gen/terraform" | ||
"tmp-tf-gen/.terraform.lock.hcl" | ||
) | ||
fi | ||
|
||
has_error=false | ||
|
||
for file in "${files[@]}"; do | ||
if [ -e "$file" ]; then | ||
if ! [ -s "$file" ]; then | ||
echo "$file exists but is empty" | ||
has_error=true | ||
fi | ||
else | ||
echo "$file does not exist" | ||
has_error=true | ||
fi | ||
done | ||
|
||
if [ "$has_error" = true ]; then | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
config: | ||
inherit-env: true | ||
retries: 1 | ||
env: | ||
AUTH0_DOMAIN: $AUTH0_CLI_CLIENT_DOMAIN | ||
AUTH0_CLIENT_ID: $AUTH0_CLI_CLIENT_ID | ||
AUTH0_CLIENT_SECRET: $AUTH0_CLI_CLIENT_SECRET | ||
tests: | ||
001.0 - setup: | ||
command: rm -rdf tmp-tf-gen | ||
exit-code: 0 | ||
001.1 - it successfully runs for a single resource: | ||
command: auth0 tf generate --output-dir tmp-tf-gen -r auth0_tenant | ||
exit-code: 0 | ||
stderr: | ||
contains: | ||
- "Terraform resource config files generated successfully in: tmp-tf-gen" | ||
- Review the config and generate the terraform state by running | ||
- cd tmp-tf-gen && ./terraform apply | ||
- Once Terraform files are auto-generated, the terraform binary and auth0_import.tf files can be deleted. | ||
001.2 - it successfully generates the expected files for a single resource: | ||
command: ./test/integration/scripts/assert-tf-generate-files-exist.sh | ||
exit-code: 0 | ||
001.3 - cleanup: | ||
command: rm -rdf tmp-tf-gen | ||
|
||
002.0 - setup: | ||
command: rm -rdf tmp-tf-gen | ||
exit-code: 0 | ||
002.1 - it successfully runs for all default resources: | ||
command: auth0 tf generate --output-dir tmp-tf-gen | ||
exit-code: 0 | ||
stderr: | ||
contains: | ||
- "Terraform resource config files generated successfully in: tmp-tf-gen" | ||
- Review the config and generate the terraform state by running | ||
- cd tmp-tf-gen && ./terraform apply | ||
- Once Terraform files are auto-generated, the terraform binary and auth0_import.tf files can be deleted. | ||
002.2 - it successfully generates the expected files for all default resources: | ||
command: ./test/integration/scripts/assert-tf-generate-files-exist.sh | ||
exit-code: 0 | ||
002.3 - cleanup: | ||
command: rm -rdf tmp-tf-gen | ||
|
||
003.1 - it partially succeeds if Terraform credentials not provided: | ||
command: unset AUTH0_DOMAIN && auth0 tf generate --output-dir tmp-tf-gen | ||
exit-code: 0 | ||
stderr: | ||
contains: | ||
- "Terraform provider credentials not detected" | ||
- "Refer to following guide on how to create a dedicated Auth0 client and configure credentials: https://registry.terraform.io/providers/auth0/auth0/latest/docs/guides/quickstart" | ||
- "After provider credentials are set, run:" | ||
- "cd tmp-tf-gen && terraform init && terraform plan -generate-config-out=auth0_generated.tf && terraform apply" | ||
- "Once the Terraform file is auto-generated, the auth0_import.tf file can be deleted." | ||
003.2 - it successfully generates the expected files for a partial success: | ||
command: ./test/integration/scripts/assert-tf-generate-files-exist.sh partial_success | ||
exit-code: 0 | ||
003.3 - cleanup: | ||
command: rm -rdf tmp-tf-gen | ||
|
||
004 - it does not run if invalid resource provided: | ||
command: auth0 tf generate -r auth0_computer | ||
exit-code: 1 | ||
stderr: | ||
contains: | ||
- "unsupported resource type: auth0_computer" |