-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtesla_token_function_test.sh
More file actions
35 lines (31 loc) · 1.01 KB
/
tesla_token_function_test.sh
File metadata and controls
35 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# Filename: tesla_token_function_test.sh
# By: Dan Burkland
# Date: 2021-02-03
# Purpose: Validates the latest build of the Tesla Token function. This is meant to be used in a CI/CD pipeline.
# Version: 1.0
# Variables
FUNCTION_URL="$1"
TESLA_EMAIL="$2"
TESLA_PASSWORD="$3"
TESLA_MFA_CODE="$4"
# Generate Curl Request Body
generate_curl_body() {
cat <<EOF
{
"TESLA_EMAIL": "${TESLA_EMAIL}",
"TESLA_PASSWORD": "${TESLA_PASSWORD}",
"TESLA_MFA_CODE": "${TESLA_MFA_CODE}"
}
EOF
}
# Validate the front-end function
CURL_OUTPUT=$(curl -s -o /dev/null -w "%{http_code}" --location --request POST $FUNCTION_URL --header 'Content-Type: application/json' --data-raw "$(generate_curl_body)")
# Exit script with proper status code based on the test result
if [ "$CURL_OUTPUT" -eq "200" ]; then
echo "tesla_token_aws_lambda_function build test result: PASSED"
exit 0
else
echo "tesla_token_aws_lambda_function build test result: FAILED"
exit 1
fi