Skip to content

Commit

Permalink
if AUTH == null, the authorization header will not be checked
Browse files Browse the repository at this point in the history
  • Loading branch information
LyonSyonII committed Nov 21, 2023
1 parent 4050365 commit c715adc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ warp = "0.3.6"

[profile.release]
strip = true
opt-level = "z"
opt-level = "s"
lto = true
codegen-units = 1
panic = "abort"
debug = false
4 changes: 3 additions & 1 deletion runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ async fn main() -> Result<(), &'static str> {
.then_some(())
.ok_or(Error::not_authorized())
})
.untuple_one();
.untuple_one()
.or_else(move |r| async move { authorization.is_empty().then_some(()).ok_or(r) });

let process_input = warp::body::content_length_limit(512)
.and(warp::body::json())
.or_else(|_| async move { Err(Error::body_not_correct()) });
Expand Down
12 changes: 4 additions & 8 deletions runner/stress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,21 @@ function request() {
for ((i = 1; i <= $2; i++))
do
curl -i --request POST \
--url http://$1/evaluate.json \
--url $1/evaluate.json \
--header 'Content-Type: application/json' \
--header 'authorization: potato' \
--header 'authorization: macarena' \
--data "{
\"code\": \"fn main() { println!(\\\"Hello, $i!\\\") } \"
}" &
done
wait
}

USAGE="Usage: ./stress.sh [local|server] [requests]"
USAGE="Usage: ./stress.sh [url] [requests]"

if [ -z $2 ]; then
echo $USAGE
exit 1
fi

case $1 in
"local"*) time request localhost:3030 $2;;
"server") time request 0.0.0.0:3030 $2;;
*) echo $USAGE;;
esac
time request $1 $2

0 comments on commit c715adc

Please sign in to comment.