Skip to content

Commit b0efdeb

Browse files
Added testing script for login and create transaction
1 parent 7398344 commit b0efdeb

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# Step 1: Login to get the token
4+
login_response=$(curl -s -X POST http://localhost:8080/login \
5+
-H "Content-Type: application/json" \
6+
-d '{"username": "Jessica Pearson", "password": "iamthebest"}')
7+
8+
# Step 2: Extract token using jq (requires jq to be installed)
9+
token=$(echo "$login_response" | jq -r '.token')
10+
11+
# Optional: check if token is empty
12+
if [ -z "$token" ] || [ "$token" == "null" ]; then
13+
echo "Failed to get JWT token"
14+
echo "Response: $login_response"
15+
exit 1
16+
fi
17+
18+
while true; do
19+
# Step 3: Use the token in the authorized request
20+
curl -X POST http://localhost:8080/transactions/schedule \
21+
-H "Authorization: Bearer $token" \
22+
-H "Content-Type: application/json" \
23+
-d '{
24+
"operation": "setfacl",
25+
"targetPath": "/var/www/html",
26+
"entries": [
27+
{
28+
"entityType": "user",
29+
"entity": "alice",
30+
"permissions": "rwx",
31+
"action": "add"
32+
}
33+
]
34+
}'
35+
done

0 commit comments

Comments
 (0)