You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bola3_ab.sh 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. # Prompt the user to enter the value of HOSTNAME
  3. read -p "Enter the HOSTNAME: " HOSTNAME
  4. # Function to obtain access token for a given email and password
  5. get_access_token() {
  6. local email=$1
  7. local password=$2
  8. # Use curl to get the access token and jq to extract it
  9. local access_token=$(curl "http://$HOSTNAME/identity/api/auth/login" \
  10. -H 'Content-Type: application/json' \
  11. --data-raw '{"email":"'"$email"'","password":"'"$password"'"}' \
  12. --insecure -s | jq -j .token)
  13. echo "$access_token"
  14. }
  15. # Define the common password
  16. COMMON_PASSWORD='cRaPi2023!!!'
  17. # Define the email addresses
  18. emails=(
  19. 'apilab@akamai.com'
  20. 'apilab2@akamai.com'
  21. 'apilab3@akamai.com'
  22. 'apilab4@akamai.com'
  23. )
  24. for ((i=0; i<${#emails[@]}; i++)); do
  25. # Generate access token
  26. access_token=$(get_access_token "${emails[i]}" "$COMMON_PASSWORD")
  27. # Execute the ab commands for each access token.
  28. 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/"
  29. 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/"
  30. 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/"
  31. 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/"
  32. done