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.

normal_traffic.sh 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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. # Loop through each email/password and output the corresponding access token
  25. for ((i=0; i<${#emails[@]}; i++)); do
  26. access_token=$(get_access_token "${emails[i]}" "$COMMON_PASSWORD")
  27. echo "GENERATING TRAFFIC FOR LOGIN API"
  28. echo "access_token$((i+1)): $access_token"
  29. echo "GENERATING TRAFFIC FOR DASHBOARD API (VIEW DASHBOARD)"
  30. for ((x=1; x<=10; x++)); do
  31. curl "http://$HOSTNAME/identity/api/v2/user/dashboard" \
  32. -H 'Accept: */*' \
  33. -H 'Accept-Language: en-US,en;q=0.9' \
  34. -H "Authorization: Bearer $access_token" \
  35. -H 'Connection: keep-alive' \
  36. -H 'Content-Type: application/json' \
  37. -H "Referer: http://$HOSTNAME/dashboard" \
  38. -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' \
  39. -H 'pragma: akamai-x-ro-trace' \
  40. -H 'x-akamai-a2-disable: on' \
  41. -H 'x-akamai-ro-piez: on' \
  42. -H 'x-im-piez: on' \
  43. --compressed \
  44. --insecure \
  45. -o /dev/null > /dev/null 2>&1
  46. # Check the esponse code
  47. if [ $? -ne 0 ]; then
  48. echo "Error: Request failed."
  49. fi
  50. done
  51. echo "GENERATING TRAFFIC FOR ORDERS API (PLACE ORDERS FOR SEAT & WHEEL)"
  52. curl "http://$HOSTNAME/workshop/api/shop/orders" \
  53. -H "Accept: */*" \
  54. -H "Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6" \
  55. -H "Authorization: Bearer $access_token" \
  56. -H "Cache-Control: no-cache" \
  57. -H "Connection: keep-alive" \
  58. -H "Content-Type: application/json" \
  59. -H "DNT: 1" \
  60. -H "Origin: http://$HOSTNAME" \
  61. -H "Pragma: no-cache" \
  62. -H "Referer: http://$HOSTNAME/workshop/api/shop/products" \
  63. -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" \
  64. --data-raw '{"product_id":1,"quantity":1}' \
  65. --compressed \
  66. --insecure \
  67. -o /dev/null > /dev/null 2>&1
  68. # Check the esponse code
  69. if [ $? -ne 0 ]; then
  70. echo "Error: Request failed."
  71. fi
  72. curl "http://$HOSTNAME/workshop/api/shop/orders" \
  73. -H "Accept: */*" \
  74. -H "Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6" \
  75. -H "Authorization: Bearer $access_token" \
  76. -H "Cache-Control: no-cache" \
  77. -H "Connection: keep-alive" \
  78. -H "Content-Type: application/json" \
  79. -H "DNT: 1" \
  80. -H "Origin: http://$HOSTNAME" \
  81. -H "Pragma: no-cache" \
  82. -H "Referer: http://$HOSTNAME/workshop/api/shop/products" \
  83. -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" \
  84. --data-raw '{"product_id":2,"quantity":1}' \
  85. --compressed \
  86. --insecure \
  87. -o /dev/null > /dev/null 2>&1
  88. # Check the esponse code
  89. if [ $? -ne 0 ]; then
  90. echo "Error: Request failed."
  91. fi
  92. echo "GENERATING TRAFFIC FOR COMMUNITY POSTS API (VIEW RECENT POSTS)"
  93. for ((x=1; x<=10; x++)); do
  94. curl "http://$HOSTNAME/community/api/v2/community/posts/recent" \
  95. -H 'Accept: */*' \
  96. -H 'Accept-Language: en-US,en;q=0.9' \
  97. -H "Authorization: Bearer $access_token" \
  98. -H 'Connection: keep-alive' \
  99. -H 'Content-Type: application/json' \
  100. -H "Referer: http://$HOSTNAME/dashboard" \
  101. -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' \
  102. -H 'pragma: akamai-x-ro-trace' \
  103. -H 'x-akamai-a2-disable: on' \
  104. -H 'x-akamai-ro-piez: on' \
  105. -H 'x-im-piez: on' \
  106. --compressed \
  107. --insecure \
  108. -o /dev/null > /dev/null 2>&1
  109. # Check the esponse code
  110. if [ $? -ne 0 ]; then
  111. echo "Error: Request failed."
  112. fi
  113. done
  114. echo "GENERATING TRAFFIC FOR ORDERS API (VIEW ALL PAST ORDERS)"
  115. for ((x=1; x<=10; x++)); do
  116. curl "http://$HOSTNAME/workshop/api/shop/orders/all" \
  117. -H 'Accept: */*' \
  118. -H 'Accept-Language: en-US,en;q=0.9' \
  119. -H "Authorization: Bearer $access_token" \
  120. -H 'Connection: keep-alive' \
  121. -H 'Content-Type: application/json' \
  122. -H "Referer: http://$HOSTNAME/dashboard" \
  123. -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' \
  124. -H 'pragma: akamai-x-ro-trace' \
  125. -H 'x-akamai-a2-disable: on' \
  126. -H 'x-akamai-ro-piez: on' \
  127. -H 'x-im-piez: on' \
  128. --compressed \
  129. --insecure \
  130. -o /dev/null > /dev/null 2>&1
  131. done
  132. echo "GENERATING TRAFFIC FOR ORDERS API (VIEW INDIVIDUAL ORDERS)"
  133. for ((order_id=1; order_id<=5; order_id++)); do
  134. curl "http://$HOSTNAME/workshop/api/shop/orders/$order_id" \
  135. -H "Accept: */*" \
  136. -H "Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6" \
  137. -H "Authorization: Bearer $access_token" \
  138. -H "Cache-Control: no-cache" \
  139. -H "Connection: keep-alive" \
  140. -H "Content-Type: application/json" \
  141. -H "DNT: 1" \
  142. -H "Origin: http://$HOSTNAME" \
  143. -H "Pragma: no-cache" \
  144. -H "Referer: http://$HOSTNAME/workshop/api/shop/orders/all" \
  145. -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" \
  146. --compressed \
  147. --insecure \
  148. -o /dev/null > /dev/null 2>&1
  149. # Check the esponse code
  150. if [ $? -ne 0 ]; then
  151. echo "Error: DASHBOARD PAGE request failed."
  152. fi
  153. done
  154. echo "GENERATING TRAFFIC FOR PRODUCTS API (VIEW AVAILABLE PRODUCTS)"
  155. for ((x=1; x<=10; x++)); do
  156. curl "http://$HOSTNAME/workshop/api/shop/products" \
  157. -H 'Accept: */*' \
  158. -H 'Accept-Language: en-US,en;q=0.9' \
  159. -H "Authorization: Bearer $access_token" \
  160. -H 'Connection: keep-alive' \
  161. -H 'Content-Type: application/json' \
  162. -H "Referer: http://$HOSTNAME/dashboard" \
  163. -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' \
  164. -H 'pragma: akamai-x-ro-trace' \
  165. -H 'x-akamai-a2-disable: on' \
  166. -H 'x-akamai-ro-piez: on' \
  167. -H 'x-im-piez: on' \
  168. --compressed \
  169. --insecure \
  170. -o /dev/null > /dev/null 2>&1
  171. # Check the esponse code
  172. if [ $? -ne 0 ]; then
  173. echo "Error: Request failed."
  174. fi
  175. done
  176. echo "GENERATING TRAFFIC FOR VEHICLES API (VIEW VEHICLE DETAILS)"
  177. for ((x=1; x<=10; x++)); do
  178. curl "http://$HOSTNAME/identity/api/v2/vehicle/vehicles" \
  179. -H 'Accept: */*' \
  180. -H 'Accept-Language: en-US,en;q=0.9' \
  181. -H "Authorization: Bearer $access_token" \
  182. -H 'Connection: keep-alive' \
  183. -H 'Content-Type: application/json' \
  184. -H "Referer: http://$HOSTNAME/dashboard" \
  185. -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' \
  186. -H 'pragma: akamai-x-ro-trace' \
  187. -H 'x-akamai-a2-disable: on' \
  188. -H 'x-akamai-ro-piez: on' \
  189. -H 'x-im-piez: on' \
  190. --compressed \
  191. --insecure \
  192. -o /dev/null > /dev/null 2>&1
  193. # Check the esponse code
  194. if [ $? -ne 0 ]; then
  195. echo "Error: Request failed."
  196. fi
  197. done
  198. echo "----------------------------------------------------------------------------"
  199. done
  200. echo "GENERATING TRAFFIC FOR LOCATIONS API (REFRESH LOCATION)"
  201. # Loop through each combination
  202. for ((x=1; x<=10; x++)); do
  203. for ((i=0; i<${#emails[@]}; i++)); do
  204. # Generate access token
  205. access_token=$(get_access_token "${emails[i]}" "$COMMON_PASSWORD")
  206. # Get the corresponding UUID
  207. UUIDS=("7e3633e8-f8e7-47a2-9076-705210dcc213" "b1804463-03be-4c51-88d3-e13b5b9a2331" "50e17ffb-3e81-4f93-8825-fd959310de6c" "2f3fd019-b89e-45dc-9d51-ee0aed14e550")
  208. UUID=${UUIDS[i]}
  209. curl "http://$HOSTNAME/identity/api/v2/vehicle/$UUID/location" \
  210. -H "Accept: */*" \
  211. -H "Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6" \
  212. -H "Authorization: Bearer $access_token" \
  213. -H "Cache-Control: no-cache" \
  214. -H "Connection: keep-alive" \
  215. -H "Content-Type: application/json" \
  216. -H "DNT: 1" \
  217. -H "Origin: http://$HOSTNAME" \
  218. -H "Pragma: no-cache" \
  219. -H "Referer: http://$HOSTNAME/identity/api/v2/user/dashboard" \
  220. -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" \
  221. --compressed \
  222. --insecure \
  223. -o /dev/null > /dev/null 2>&1
  224. # Check the esponse code
  225. if [ $? -ne 0 ]; then
  226. echo "Error: Request failed."
  227. fi
  228. done
  229. done
  230. echo "--------------------------------------------------------------------------------------------------------"
  231. echo "GENERATING TRAFFIC FOR CONTACT MECHANIC (NEW SERVICE REQUEST) & REPORTS (VIEW REPORTS) API"
  232. for ((i=0; i<${#emails[@]}; i++)); do
  233. # Generate access token
  234. access_token=$(get_access_token "${emails[i]}" "$COMMON_PASSWORD")
  235. # Define VINs
  236. VINS=("8WNFQ29UASO325881" "2QJHA06QPTA452548" "9MZWD50MITK534430" "2QBSC54ZIHY224823")
  237. VIN=${VINS[i]}
  238. # Execute curl command to view mechanic info
  239. for ((x=1; x<=25; x++)); do
  240. curl "http://$HOSTNAME/workshop/api/mechanic/" \
  241. -H "Accept: */*" \
  242. -H "Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6" \
  243. -H "Authorization: Bearer $access_token" \
  244. -H "Cache-Control: no-cache" \
  245. -H "Connection: keep-alive" \
  246. -H "Content-Type: application/json" \
  247. -H "DNT: 1" \
  248. -H "Pragma: no-cache" \
  249. -H "Referer: http://$HOSTNAME/contact-mechanic?VIN=$VIN" \
  250. -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" \
  251. --compressed \
  252. --insecure \
  253. -o /dev/null > /dev/null 2>&1
  254. # Check the esponse code
  255. if [ $? -ne 0 ]; then
  256. echo "Error: Request failed."
  257. fi
  258. done
  259. # Execute curl command to create service request for TRAC_JHN mechanic code
  260. response_jhn=$(curl "http://$HOSTNAME/workshop/api/merchant/contact_mechanic" \
  261. -H "Accept: */*" \
  262. -H "Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6" \
  263. -H "Authorization: Bearer $access_token" \
  264. -H "Cache-Control: no-cache" \
  265. -H "Connection: keep-alive" \
  266. -H "Content-Type: application/json" \
  267. -H "DNT: 1" \
  268. -H "Origin: http://$HOSTNAME" \
  269. -H "Pragma: no-cache" \
  270. -H "Referer: http://$HOSTNAME/contact-mechanic?VIN=$VIN" \
  271. -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" \
  272. --data-raw "{\"mechanic_code\":\"TRAC_JHN\",\"problem_details\":\"123\",\"vin\":\"$VIN\",\"mechanic_api\":\"http://$HOSTNAME/workshop/api/mechanic/receive_report\",\"repeat_request_if_failed\":false,\"number_of_repeats\":1}" \
  273. --compressed \
  274. --insecure)
  275. # Extract the report link for TRAC_JHN
  276. report_link_jhn=$(echo "$response_jhn" | jq -r '.response_from_mechanic_api.report_link')
  277. # Execute curl command to create service request for TRAC_JME mechanic code
  278. response_jme=$(curl "http://$HOSTNAME/workshop/api/merchant/contact_mechanic" \
  279. -H "Accept: */*" \
  280. -H "Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6" \
  281. -H "Authorization: Bearer $access_token" \
  282. -H "Cache-Control: no-cache" \
  283. -H "Connection: keep-alive" \
  284. -H "Content-Type: application/json" \
  285. -H "DNT: 1" \
  286. -H "Origin: http://$HOSTNAME" \
  287. -H "Pragma: no-cache" \
  288. -H "Referer: http://$HOSTNAME/contact-mechanic?VIN=$VIN" \
  289. -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" \
  290. --data-raw "{\"mechanic_code\":\"TRAC_JME\",\"problem_details\":\"123\",\"vin\":\"$VIN\",\"mechanic_api\":\"http://$HOSTNAME/workshop/api/mechanic/receive_report\",\"repeat_request_if_failed\":false,\"number_of_repeats\":1}" \
  291. --compressed \
  292. --insecure)
  293. # Extract the report link for TRAC_JME
  294. report_link_jme=$(echo "$response_jme" | jq -r '.response_from_mechanic_api.report_link')
  295. # Make a curl command for each report link using the corresponding access token
  296. curl "$report_link_jhn" -H "Authorization: Bearer $access_token" --insecure -sS > /dev/null
  297. # Check the esponse code
  298. if [ $? -ne 0 ]; then
  299. echo "Error: Request failed for TRAC_JHN."
  300. fi
  301. curl "$report_link_jme" -H "Authorization: Bearer $access_token" --insecure -sS > /dev/null
  302. # Check the esponse code
  303. if [ $? -ne 0 ]; then
  304. echo "Error: Request failed for TRAC_JHN."
  305. fi
  306. done
  307. echo "--------------------------------------------------------------------------------------------------------"
  308. echo "GENERATING TRAFFIC FOR COMMUNITY API (ADD POSTS AND COMMENTS)"
  309. # Function to make the first curl request
  310. make_first_request() {
  311. local access_token=$1
  312. curl "http://$HOSTNAME/community/api/v2/community/posts" \
  313. -H 'Accept: */*' \
  314. -H 'Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6' \
  315. -H "Authorization: Bearer $access_token" \
  316. -H 'Cache-Control: no-cache' \
  317. -H 'Connection: keep-alive' \
  318. -H 'Content-Type: application/json' \
  319. -H 'DNT: 1' \
  320. -H "Origin: http://$HOSTNAME" \
  321. -H 'Pragma: no-cache' \
  322. -H "Referer: http://$HOSTNAME/new-post" \
  323. -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' \
  324. --data-raw '{"title":"script","content":"script"}' \
  325. --compressed \
  326. --insecure \
  327. -o /dev/null > /dev/null 2>&1
  328. # Check the esponse code
  329. if [ $? -ne 0 ]; then
  330. echo "Error: Request failed for POSTS."
  331. fi
  332. }
  333. # Function to make the second curl request
  334. make_second_request() {
  335. local access_token=$1
  336. local post_id=$2
  337. curl "http://$HOSTNAME/community/api/v2/community/posts/$post_id/comment" \
  338. -H 'Accept: */*' \
  339. -H 'Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6' \
  340. -H "Authorization: Bearer $access_token" \
  341. -H 'Cache-Control: no-cache' \
  342. -H 'Connection: keep-alive' \
  343. -H 'Content-Type: application/json' \
  344. -H 'DNT: 1' \
  345. -H "Origin: http://$HOSTNAME" \
  346. -H 'Pragma: no-cache' \
  347. -H "Referer: http://$HOSTNAME/post?post_id=$post_id" \
  348. -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' \
  349. --data-raw '{"content":"script"}' \
  350. --compressed \
  351. --insecure \
  352. -o /dev/null > /dev/null 2>&1
  353. # Check the esponse code
  354. if [ $? -ne 0 ]; then
  355. echo "Error: Request failed for COMMENTS."
  356. fi
  357. }
  358. # Loop through the email addresses
  359. for email in "${emails[@]}"; do
  360. # Generate access token
  361. access_token=$(get_access_token "$email" "$COMMON_PASSWORD")
  362. # Make the first request and capture the response
  363. response=$(make_first_request "$access_token")
  364. # Extract the post ID from the response
  365. post_id=$(echo "$response" | jq -r '.id')
  366. # Make the second request
  367. make_second_request "$access_token" "$post_id"
  368. done