Skip to content

Commit

Permalink
Generate tests certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
outscale-toa committed Aug 1, 2024
1 parent 51a6fd1 commit c215b55
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ tofu-examples:
@sh -c "'$(CURDIR)/scripts/tofu-examples.sh'"

.PHONY: test-integration
test-integration:
test-integration: test-gen-cert
@sh -c "'$(CURDIR)/scripts/integration.sh'"

.PHONY: test-gen-cert
Expand Down
24 changes: 18 additions & 6 deletions scripts/generate-certificate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ set -e

project_dir=$(cd "$(dirname $0)" && pwd)
project_root=$(cd $project_dir/.. && pwd)
if [ ! -d "$project_root/tests/qa_provider_oapi/data/cert_example" ]; then
mkdir $project_root/tests/qa_provider_oapi/data/cert_example
fi
build_dir=$(cd $project_root/tests/qa_provider_oapi/data/cert_example && pwd)
tf_file="gen-cert-test.tf"

cd $project_root
Expand All @@ -20,23 +24,31 @@ terraform {
resource "shell_script" "ca_gen" {
lifecycle_commands {
create = <<-EOF
openssl req -x509 -sha256 -nodes -newkey rsa:4096 -keyout test-cert.key -days 2 -out test-cert.pem -subj /CN=domain.com
openssl req -x509 -sha256 -nodes -newkey rsa:4096 -keyout certificate.key -days 2 -out certificate.pem -subj /CN=domain.com
EOF
read = <<-EOF
echo "{\"filename\": \"test-cert.pem\"}"
echo "{\"filename\": \"certificate.pem\"}"
EOF
delete = ""
}
working_directory = path.module
}
' > "outscale/$tf_file"
' > "$project_root/outscale/$tf_file" >"$build_dir/$tf_file"

if [ ! -e "outscale/$tf_file" ]; then
if [ ! -e "$build_dir/$tf_file" ] && [ ! -e "$project_root/outscale/$tf_file" ]; then
echo " $tf_file doesn't existe"
exit 1
fi

cd $project_root/outscale && terraform init || exit 1
cd $project_root/outscale && terraform apply -auto-approve || exit 1
cd "$project_root/outscale"
terraform init || exit 1
terraform apply -auto-approve || exit 1
cd $project_root


cd $build_dir
terraform init || exit 1
terraform apply -auto-approve || exit 1
cd $project_root

exit 0

0 comments on commit c215b55

Please sign in to comment.