123456789101112131415161718192021222324252627282930313233343536373839 |
- #!/bin/bash
-
- # Prompt the user to enter the value of HOSTNAME
- read -p "Enter the HOSTNAME: " HOSTNAME
-
-
- # Function to obtain access token for a given email and password
- get_access_token() {
- local email=$1
- local password=$2
-
- # Use curl to get the access token and jq to extract it
- local access_token=$(curl "http://$HOSTNAME/identity/api/auth/login" \
- -H 'Content-Type: application/json' \
- --data-raw '{"email":"'"$email"'","password":"'"$password"'"}' \
- --insecure -s | jq -j .token)
-
- echo "$access_token"
- }
-
- # Define the common password
- COMMON_PASSWORD='cRaPi2023!!!'
-
- # Define the email addresses
- emails=(
- 'apilab@akamai.com'
- 'apilab2@akamai.com'
- 'apilab3@akamai.com'
- 'apilab4@akamai.com'
- )
- for ((i=0; i<${#emails[@]}; i++)); do
- # Generate access token
- access_token=$(get_access_token "${emails[i]}" "$COMMON_PASSWORD")
- # Execute the ab commands for each access token.
- ab -k -c 5 -n 200 -H "Authorization: Bearer $access_token" -H 'Content-Type: application/json' "http://$HOSTNAME/identity/api/v2/vehicle/e00d6df3-3aa9-4a9f-b4af-5cd6e54c3eee/location/"
- ab -k -c 5 -n 200 -H "Authorization: Bearer $access_token" -H 'Content-Type: application/json' "http://$HOSTNAME/identity/api/v2/vehicle/7e3633e8-f8e7-47a2-9076-705210dcc213/location/"
- ab -k -c 5 -n 200 -H "Authorization: Bearer $access_token" -H 'Content-Type: application/json' "http://$HOSTNAME/identity/api/v2/vehicle/5cb870b1-1938-4d7f-9763-004b3da1fecc/location/"
- ab -k -c 5 -n 200 -H "Authorization: Bearer $access_token" -H 'Content-Type: application/json' "http://$HOSTNAME/identity/api/v2/vehicle/2de56bec-c096-4033-83f8-1a4bd73865cf/location/"
- done
|