File tree Expand file tree Collapse file tree
service-account-access-list-entry/test
service-account-secret/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,13 +9,21 @@ set -o nounset
99set -o pipefail
1010
1111function usage {
12- echo " usage:$0 <org_id>"
12+ echo " usage: $0 "
13+ echo " Requires MONGODB_ATLAS_ORG_ID environment variable to be set."
1314 echo " Generates test input files for service account access list entry"
1415 exit 0
1516}
1617
17- if [ " $# " -ne 1 ]; then usage; fi
18- if [[ " $* " == help ]]; then usage; fi
18+ if [[ " ${1:- } " == help ]]; then usage; fi
19+
20+ if [ -z " ${MONGODB_ATLAS_ORG_ID:- } " ]; then
21+ echo " Error: MONGODB_ATLAS_ORG_ID environment variable is not set"
22+ exit 1
23+ fi
24+
25+ orgId=" ${MONGODB_ATLAS_ORG_ID} "
26+ echo " OrgId: $orgId "
1927
2028rm -rf inputs
2129mkdir inputs
@@ -27,9 +35,6 @@ if [ ${MONGODB_ATLAS_PROFILE+x} ]; then
2735 profile=${MONGODB_ATLAS_PROFILE}
2836fi
2937
30- orgId=" ${1} "
31- echo " OrgId: $orgId "
32-
3338serviceAccountName=" cfn-test-sa-accesslist-$( date +%s) -$RANDOM "
3439echo " Creating service account: $serviceAccountName "
3540
Original file line number Diff line number Diff line change @@ -5,12 +5,4 @@ set -o errexit
55set -o nounset
66set -o pipefail
77
8- if [ -z " ${MONGODB_ATLAS_ORG_ID:- } " ]; then
9- echo " Error: MONGODB_ATLAS_ORG_ID environment variable is not set"
10- exit 1
11- fi
12-
13- orgId=" ${MONGODB_ATLAS_ORG_ID} "
14- echo " Using OrgId: $orgId "
15-
16- ./test/cfn-test-create-inputs.sh " $orgId "
8+ ./test/cfn-test-create-inputs.sh
Original file line number Diff line number Diff line change @@ -9,13 +9,21 @@ set -o nounset
99set -o pipefail
1010
1111function usage {
12- echo " usage:$0 <org_id>"
12+ echo " usage: $0 "
13+ echo " Requires MONGODB_ATLAS_ORG_ID environment variable to be set."
1314 echo " Generates test input files for service account secret"
1415 exit 0
1516}
1617
17- if [ " $# " -ne 1 ]; then usage; fi
18- if [[ " $* " == help ]]; then usage; fi
18+ if [[ " ${1:- } " == help ]]; then usage; fi
19+
20+ if [ -z " ${MONGODB_ATLAS_ORG_ID:- } " ]; then
21+ echo " Error: MONGODB_ATLAS_ORG_ID environment variable is not set"
22+ exit 1
23+ fi
24+
25+ orgId=" ${MONGODB_ATLAS_ORG_ID} "
26+ echo " OrgId: $orgId "
1927
2028rm -rf inputs
2129mkdir inputs
@@ -27,9 +35,6 @@ if [ ${MONGODB_ATLAS_PROFILE+x} ]; then
2735 profile=${MONGODB_ATLAS_PROFILE}
2836fi
2937
30- orgId=" ${1} "
31- echo " OrgId: $orgId "
32-
3338# Create a service account for testing using Atlas CLI
3439serviceAccountName=" cfn-test-sa-$( date +%s) -$RANDOM "
3540echo " Creating service account: $serviceAccountName "
Original file line number Diff line number Diff line change @@ -5,13 +5,4 @@ set -o errexit
55set -o nounset
66set -o pipefail
77
8- # Get org ID from environment or use default
9- if [ -z " ${MONGODB_ATLAS_ORG_ID:- } " ]; then
10- echo " Error: MONGODB_ATLAS_ORG_ID environment variable is not set"
11- exit 1
12- fi
13-
14- orgId=" ${MONGODB_ATLAS_ORG_ID} "
15- echo " Using OrgId: $orgId "
16-
17- ./test/cfn-test-create-inputs.sh " $orgId "
8+ ./test/cfn-test-create-inputs.sh
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3- # This tool deletes the mongodb resources used for `cfn test` as inputs.
3+ # This tool deletes the MongoDB resources used for `cfn test` as inputs.
44set -o errexit
55set -o nounset
66set -o pipefail
77
8- if [ ! -f ./inputs/inputs_1_create.json ]; then
9- echo " No inputs file found, nothing to clean up"
10- exit 0
11- fi
12-
13- orgId=$( jq -r ' .OrgId' ./inputs/inputs_1_create.json)
14- clientId=$( jq -r ' .ClientId' ./inputs/inputs_1_create.json)
15-
16- # Delete service account using Atlas CLI (this will also delete all its secrets)
17- if atlas api serviceAccounts deleteOrgServiceAccount --orgId " $orgId " --clientId " $clientId " --version " 2024-08-05" --output json 2> /dev/null; then
18- echo " Service account $clientId deletion OK"
19- else
20- exitCode=$?
21- if [ $exitCode -eq 0 ]; then
22- echo " Service account $clientId deletion OK"
23- else
24- echo " Warning: Failed cleaning service account: $clientId (may already be deleted)"
25- fi
26- fi
8+ ./test/cfn-test-delete-inputs.sh
You can’t perform that action at this time.
0 commit comments