-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests and their associated utils
Add integration tests as per detailed in [solution design](https://github.com/cyberark/secrets-provider-for-k8s/blob/master/design/milestone_1_2_design_doc.md) Add helper utils for items needed to build the helm charts and get end to end successfully
- Loading branch information
Showing
6 changed files
with
198 additions
and
8 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
deploy/test/test_cases/TEST_ID_17_helm_job_deploys_successfully.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,33 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
# This test verifies that the Secrets Provider Job deploys successfully and Conjur secret appears in pod | ||
# TODO verify Job start up and completed logs | ||
|
||
set_namespace $CONJUR_NAMESPACE_NAME | ||
|
||
# Configure authn and login Conjur urls | ||
configure_env_url | ||
|
||
# Fetch SSL cert from Conjur/DAP | ||
fetch_ssl | ||
|
||
# Save cert for later setting in Helm | ||
$cli_with_timeout "exec ${conjur_pod_name} --namespace $CONJUR_NAMESPACE_NAME cat $cert_location" > "conjur.pem" | ||
|
||
set_namespace $APP_NAMESPACE_NAME | ||
|
||
pushd ../../../ | ||
fill_helm_chart | ||
helm install -f "cyberark-secrets-provider-for-kubernetes/ci/test-values.yaml" cyberark-secrets-provider-for-kubernetes ./cyberark-secrets-provider-for-kubernetes --set-file environment.conjur.sslCertificate.value="deploy/test/test_cases/conjur.pem" | ||
popd | ||
|
||
# Check for Job completion | ||
helm_chart_name="cyberark-secrets-provider-for-kubernetes" | ||
$cli_with_timeout wait --for=condition=complete job/$helm_chart_name | ||
|
||
# Deploy app to test against | ||
deploy_helm_app | ||
pod_name=$($cli_with_timeout get pods --namespace=$APP_NAMESPACE_NAME --selector app=test-env --no-headers | awk '{print $1}' ) | ||
verify_secret_value_in_pod $pod_name "TEST_SECRET" "supersecret" | ||
|
52 changes: 52 additions & 0 deletions
52
deploy/test/test_cases/TEST_ID_18_helm_multiple_provider_multiple_secrets.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,52 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
# This test verifies that two Secrets Provider Jobs deploy successfully in the same namespace | ||
# TODO verify Job start up and completed logs | ||
|
||
set_namespace $CONJUR_NAMESPACE_NAME | ||
|
||
# Configure authn and login Conjur urls | ||
configure_env_url | ||
|
||
# Fetch SSL cert from Conjur/DAP | ||
fetch_ssl | ||
|
||
# Save cert for later setting in Helm | ||
$cli_with_timeout "exec ${conjur_pod_name} --namespace $CONJUR_NAMESPACE_NAME cat $cert_location" > "conjur.pem" | ||
|
||
set_namespace $APP_NAMESPACE_NAME | ||
|
||
# Create second secret | ||
echo "Create second secret" | ||
$cli_with_timeout create -f ../helm-props/k8s_secrets_two.yml | ||
set_secret secrets/test_secret_two some-secret-2 | ||
|
||
pushd ../../../ | ||
fill_helm_chart | ||
helm install -f "cyberark-secrets-provider-for-kubernetes/ci/test-values.yaml" cyberark-secrets-provider-for-kubernetes ./cyberark-secrets-provider-for-kubernetes --set-file environment.conjur.sslCertificate.value="deploy/test/test_cases/conjur.pem" | ||
|
||
export SECRETS_PROVIDER_ROLE=secrets-provider-role-two | ||
export SECRETS_PROVIDER_ROLE_BINDING=secrets-provider-role-binding-two | ||
export SERVICE_ACCOUNT=secrets-provider-service-account-two | ||
export K8S_SECRETS=test-k8s-secret-two | ||
export SECRETS_PROVIDER_SSL_CONFIG_MAP=secrets-provider-ssl-config-map-two | ||
fill_helm_chart "-two" | ||
helm install -f "cyberark-secrets-provider-for-kubernetes/ci/test-values-two.yaml" cyberark-secrets-provider-for-kubernetes-two ./cyberark-secrets-provider-for-kubernetes --set-file environment.conjur.sslCertificate.value="deploy/test/test_cases/conjur.pem" | ||
popd | ||
|
||
# Check for Job completion | ||
helm_chart_name="cyberark-secrets-provider-for-kubernetes" | ||
$cli_with_timeout wait --for=condition=complete job/$helm_chart_name | ||
|
||
helm_chart_name="cyberark-secrets-provider-for-kubernetes-two" | ||
$cli_with_timeout wait --for=condition=complete job/$helm_chart_name | ||
|
||
# Deploy app to test against | ||
deploy_helm_app | ||
pod_name=$($cli_with_timeout get pods --namespace=$APP_NAMESPACE_NAME --selector app=test-env --no-headers | awk '{print $1}' | head -1) | ||
verify_secret_value_in_pod $pod_name "TEST_SECRET" "supersecret" | ||
|
||
deploy_helm_app "-two" | ||
pod_name=$($cli_with_timeout get pods --namespace=$APP_NAMESPACE_NAME --selector app=test-env-two --no-headers | awk '{print $1}' | head -1) | ||
verify_secret_value_in_pod $pod_name "TEST_SECRET-two" "some-secret-2" |
42 changes: 42 additions & 0 deletions
42
deploy/test/test_cases/TEST_ID_19_helm_multiple_provider_same_secret.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,42 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
# This test verifies that two Secrets Provider Jobs deploy successfully in the same namespace and access the same Conjur secret and update the same K8s Secret | ||
# TODO verify Job start up and completed logs | ||
|
||
set_namespace $CONJUR_NAMESPACE_NAME | ||
|
||
# Configure authn and login Conjur urls | ||
configure_env_url | ||
|
||
# Fetch SSL cert from Conjur/DAP | ||
fetch_ssl | ||
|
||
# Save cert for later setting in Helm | ||
$cli_with_timeout "exec ${conjur_pod_name} --namespace $CONJUR_NAMESPACE_NAME cat $cert_location" > "conjur.pem" | ||
|
||
set_namespace $APP_NAMESPACE_NAME | ||
|
||
pushd ../../../ | ||
fill_helm_chart | ||
helm install -f "cyberark-secrets-provider-for-kubernetes/ci/test-values.yaml" cyberark-secrets-provider-for-kubernetes ./cyberark-secrets-provider-for-kubernetes --set-file environment.conjur.sslCertificate.value="deploy/test/test_cases/conjur.pem" | ||
|
||
export SECRETS_PROVIDER_ROLE=secrets-provider-role-two | ||
export SECRETS_PROVIDER_ROLE_BINDING=secrets-provider-role-binding-two | ||
export SERVICE_ACCOUNT=secrets-provider-service-account-two | ||
export SECRETS_PROVIDER_SSL_CONFIG_MAP=secrets-provider-ssl-config-map-two | ||
fill_helm_chart "-two" | ||
helm install -f "cyberark-secrets-provider-for-kubernetes/ci/test-values-two.yaml" cyberark-secrets-provider-for-kubernetes-two ./cyberark-secrets-provider-for-kubernetes --set-file environment.conjur.sslCertificate.value="deploy/test/test_cases/conjur.pem" | ||
popd | ||
|
||
# Check for Job completion | ||
helm_chart_name="cyberark-secrets-provider-for-kubernetes" | ||
$cli_with_timeout wait --for=condition=complete job/$helm_chart_name | ||
|
||
helm_chart_name="cyberark-secrets-provider-for-kubernetes-two" | ||
$cli_with_timeout wait --for=condition=complete job/$helm_chart_name | ||
|
||
# Deploy app to test against | ||
deploy_helm_app | ||
pod_name=$($cli_with_timeout get pods --namespace=$APP_NAMESPACE_NAME --selector app=test-env --no-headers | awk '{print $1}' | head -1) | ||
verify_secret_value_in_pod $pod_name "TEST_SECRET" "supersecret" |
28 changes: 28 additions & 0 deletions
28
deploy/test/test_cases/TEST_ID_20_helm_service_account_does_not_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,28 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
# This test verifies that when the user declares that they will provide their own Service Account but that Service Account does not exist in their environment that the Job will fail | ||
# TODO verify Job start up and completed logs | ||
|
||
set_namespace $CONJUR_NAMESPACE_NAME | ||
|
||
# Configure authn and login Conjur urls | ||
configure_env_url | ||
|
||
# Fetch SSL cert from Conjur/DAP | ||
fetch_ssl | ||
|
||
# Save cert for later setting in Helm | ||
$cli_with_timeout "exec ${conjur_pod_name} --namespace $CONJUR_NAMESPACE_NAME cat $cert_location" > "conjur.pem" | ||
|
||
set_namespace $APP_NAMESPACE_NAME | ||
|
||
pushd ../../../ | ||
export CREATE_SERVICE_ACCOUNT="false" | ||
|
||
fill_helm_chart | ||
helm install -f "cyberark-secrets-provider-for-kubernetes/ci/test-values.yaml" cyberark-secrets-provider-for-kubernetes ./cyberark-secrets-provider-for-kubernetes --set-file environment.conjur.sslCertificate.value="deploy/test/test_cases/conjur.pem" | ||
popd | ||
|
||
helm_chart_name="cyberark-secrets-provider-for-kubernetes" | ||
$cli_with_timeout "describe job $helm_chart_name | grep 'error looking up service account'" |
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