trying to bake auth cookies to the mix.
This commit is contained in:
parent
8c9f14e12b
commit
ee8571e8ea
|
@ -1,5 +1,30 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
function fetch_auth_cookie {
|
||||||
|
local cms_type=${CMS_TYPE}
|
||||||
|
local cookie_file="/tmp/cookie.txt"
|
||||||
|
|
||||||
|
case $cms_type in
|
||||||
|
"Concrete5")
|
||||||
|
local login_url="https://bishopairport.org/login/concrete/authenticate"
|
||||||
|
local login_data="uName=$USERNAME&uPassword=$PASSWORD"
|
||||||
|
|
||||||
|
# Fetch and store the cookie for Concrete5
|
||||||
|
curl -c "$cookie_file" -d "$login_data" -X POST "$login_url"
|
||||||
|
;;
|
||||||
|
|
||||||
|
"WordPress")
|
||||||
|
# Placeholder for WordPress authentication
|
||||||
|
echo "WordPress authentication: To be developed"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Unsupported CMS type: $cms_type"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function prepare_log_file {
|
function prepare_log_file {
|
||||||
local log_file="/logs/authenticated.csv"
|
local log_file="/logs/authenticated.csv"
|
||||||
> "$log_file"
|
> "$log_file"
|
||||||
|
@ -9,34 +34,34 @@ function prepare_log_file {
|
||||||
|
|
||||||
function run_apache_bench_and_check_ttfb {
|
function run_apache_bench_and_check_ttfb {
|
||||||
local urls=(${URLS//,/ })
|
local urls=(${URLS//,/ })
|
||||||
local username=$USERNAME
|
|
||||||
local password=$PASSWORD
|
|
||||||
local requests=$REQUESTS
|
local requests=$REQUESTS
|
||||||
local concurrency=$CONCURRENCY
|
local concurrency=$CONCURRENCY
|
||||||
local log_file="/logs/authenticated.csv"
|
local log_file="/logs/authenticated.csv"
|
||||||
|
local cookie_file="/tmp/cookie"
|
||||||
|
|
||||||
echo "URL,Username,HTTP Code,Average TTFB (ms),AB Mean Time per Request (ms)" | tee "$log_file"
|
echo "URL,HTTP Code,Average TTFB (ms),AB Mean Time per Request (ms)" | tee "$log_file"
|
||||||
|
|
||||||
for url in "${urls[@]}"; do
|
for url in "${urls[@]}"; do
|
||||||
local total_ttfb=0
|
local total_ttfb=0
|
||||||
local ttfb=0
|
local ttfb=0
|
||||||
local http_code=$(curl -o /dev/null -s -w "%{http_code}" -u "$username:$password" "$url")
|
local http_code=$(curl -o /dev/null -s -w "%{http_code}" -b "$cookie_file" "$url")
|
||||||
|
|
||||||
# Apache Bench
|
# Apache Bench with cookie
|
||||||
local ab_summary=$(ab -n "$requests" -c "$concurrency" -A "$username:$password" "$url" 2>&1 | grep "Time per request" | head -1)
|
local ab_summary=$(ab -n "$requests" -c "$concurrency" -C "$(cat $cookie_file)" "$url" 2>&1 | grep "Time per request" | head -1)
|
||||||
local ab_mean_time_per_request=$(echo "$ab_summary" | awk '{print $4}' | awk '{printf "%.3f", $1}')
|
local ab_mean_time_per_request=$(echo "$ab_summary" | awk '{print $4}' | awk '{printf "%.3f", $1}')
|
||||||
|
|
||||||
# TTFB
|
# TTFB with cookie
|
||||||
for i in {1..5}; do
|
for i in {1..5}; do
|
||||||
ttfb=$(curl -o /dev/null -s -w "%{time_starttransfer}\n" -u "$username:$password" "$url")
|
ttfb=$(curl -o /dev/null -s -w "%{time_starttransfer}\n" -b "$cookie_file" "$url")
|
||||||
total_ttfb=$(echo "$total_ttfb + $ttfb" | bc -l)
|
total_ttfb=$(echo "$total_ttfb + $ttfb" | bc -l)
|
||||||
done
|
done
|
||||||
local mean_ttfb=$(echo "scale=3; ($total_ttfb / 5) * 1000" | bc)
|
local mean_ttfb=$(echo "scale=3; ($total_ttfb / 5) * 1000" | bc)
|
||||||
|
|
||||||
echo "$url,$username,$http_code,${mean_ttfb},${ab_mean_time_per_request}" | tee -a "$log_file"
|
echo "$url,$http_code,${mean_ttfb},${ab_mean_time_per_request}" | tee -a "$log_file"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function upload_to_hastebin_and_notify {
|
function upload_to_hastebin_and_notify {
|
||||||
local log_file="/logs/authenticated.csv"
|
local log_file="/logs/authenticated.csv"
|
||||||
local response=$(curl -X POST -s --data-binary @"${log_file}" https://haste.nixc.us/documents)
|
local response=$(curl -X POST -s --data-binary @"${log_file}" https://haste.nixc.us/documents)
|
||||||
|
@ -54,5 +79,6 @@ function upload_to_hastebin_and_notify {
|
||||||
|
|
||||||
|
|
||||||
prepare_log_file
|
prepare_log_file
|
||||||
|
fetch_auth_cookie
|
||||||
run_apache_bench_and_check_ttfb
|
run_apache_bench_and_check_ttfb
|
||||||
upload_to_hastebin_and_notify
|
upload_to_hastebin_and_notify
|
||||||
|
|
Loading…
Reference in New Issue