mirror of
https://github.com/ION606/MailPocket.git
synced 2026-05-14 22:06:55 +00:00
added admin routes
This commit is contained in:
+20
-17
@@ -1,6 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONTAINER_NAME="batched-server"
|
||||
SERVER_URL="http://localhost:15521"
|
||||
VOLUME_PATH="/app/data" # Path inside container
|
||||
|
||||
test_server_running() {
|
||||
echo "Testing if the server is running..."
|
||||
@@ -14,40 +16,41 @@ test_server_running() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
test_submit_email() {
|
||||
echo "Testing email submission..."
|
||||
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X POST -d "email=test@example.com" "$SERVER_URL/submit")
|
||||
test_form_submission() {
|
||||
echo "Testing form submission to dynamic endpoint..."
|
||||
FORM_NAME="testform"
|
||||
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X POST -d "email=test@example.com" "$SERVER_URL/$FORM_NAME")
|
||||
|
||||
if [ "$RESPONSE" -eq 200 ]; then
|
||||
echo "✅ Email submission successful (Status: 200 OK)"
|
||||
echo "✅ Form submission to /$FORM_NAME successful (Status: 200 OK)"
|
||||
else
|
||||
echo "❌ Email submission failed (Received status: $RESPONSE)"
|
||||
echo "❌ Form submission failed (Received status: $RESPONSE)"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
test_csv_written() {
|
||||
CSV_FILE="batched-server/emails.csv"
|
||||
CSV_FILE="$VOLUME_PATH/emails.csv"
|
||||
FORM_NAME="testform"
|
||||
|
||||
if [ -f "$CSV_FILE" ]; then
|
||||
if grep -q "test@example.com" "$CSV_FILE"; then
|
||||
echo "✅ Email found in $CSV_FILE"
|
||||
# Use docker exec to check CSV inside container
|
||||
if docker exec $CONTAINER_NAME /bin/sh -c "[ -f $CSV_FILE ]"; then
|
||||
if docker exec $CONTAINER_NAME grep -q "test@example.com,$FORM_NAME" "$CSV_FILE"; then
|
||||
echo "✅ Entry found in CSV (form: $FORM_NAME)"
|
||||
else
|
||||
echo "❌ Email NOT found in $CSV_FILE"
|
||||
echo "❌ Entry NOT found in CSV"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "❌ CSV file not found!"
|
||||
echo "❌ CSV file not found in container!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# run the tests
|
||||
# Run tests
|
||||
test_server_running
|
||||
test_submit_email
|
||||
sleep 2 # wait for the batched write to complete
|
||||
test_form_submission
|
||||
sleep 2 # Allow time for batched write
|
||||
test_csv_written
|
||||
|
||||
echo "✅ All tests passed successfully!"
|
||||
echo "✅ All batched CSV tests passed!"
|
||||
Reference in New Issue
Block a user