Fix quick-test.sh to verify embedded credentials correctly
Updated test script to: - Check for actual credential values (not just empty strings) - Distinguish between empty, default, and custom values - Provide clear error messages if credentials are missing - Test with actual user credentials (josh@shortcutsolutions.net) This should prevent confusing 'credential missing' errors when credentials are properly embedded.
This commit is contained in:
1 parent
c9e957c5da
commit
2c3a49f2d5
1 file changed
+106
-71
+106
-71
@@ -14,7 +14,7 @@ echo ""
|
|||||||
|
|
||||||
# Check if binary has credentials before running
|
# Check if binary has credentials before running
|
||||||
echo "Checking binary credentials..."
|
echo "Checking binary credentials..."
|
||||||
if ~/bin/nextcloud-mail --help 2>&1 | grep -q '"imap-server".*"\"\"'; then
|
if ~/bin/nextcloud-mail --help 2>&1 | grep -q '"imap-server".*"\"'; then
|
||||||
echo "❌ Error: nextcloud-mail binary was built with empty credentials!"
|
echo "❌ Error: nextcloud-mail binary was built with empty credentials!"
|
||||||
echo " Please run ./build.sh again and provide valid IMAP/SMTP credentials."
|
echo " Please run ./build.sh again and provide valid IMAP/SMTP credentials."
|
||||||
echo ""
|
echo ""
|
||||||
@@ -29,9 +29,104 @@ echo "Username: $USERNAME"
|
|||||||
echo "Test Directory: $TEST_DIR"
|
echo "Test Directory: $TEST_DIR"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Create test directory
|
# Verify embedded credentials
|
||||||
mkdir -p "$TEST_DIR"
|
echo "Verifying embedded IMAP credentials..."
|
||||||
echo "✓ Test directory created: $TEST_DIR"
|
if ~/bin/nextcloud-mail --help 2>&1 | grep -q "imap-server.*teamwork"; then
|
||||||
|
echo " ✅ IMAP Server: using default (teamworkapps.com)"
|
||||||
|
elif ~/bin/nextcloud-mail --help 2>&1 | grep -q "imap-server.*\""; then
|
||||||
|
echo " ❌ IMAP Server: EMPTY string"
|
||||||
|
IMAP_EMPTY=true
|
||||||
|
elif ~/bin/nextcloud-mail --help 2>&1 | grep -q "imap-server.*[^[:alnum:]]"; then
|
||||||
|
echo " ✅ IMAP Server: using custom value"
|
||||||
|
else
|
||||||
|
echo " ⚠️ IMAP Server: UNKNOWN state"
|
||||||
|
IMAP_EMPTY=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ~/bin/nextcloud-mail --help 2>&1 | grep -q "imap-port.*993"; then
|
||||||
|
echo " ✅ IMAP Port: 993"
|
||||||
|
elif ~/bin/nextcloud-mail --help 2>&1 | grep -q "imap-port.*\""; then
|
||||||
|
echo " ❌ IMAP Port: EMPTY"
|
||||||
|
IMAP_PORT_EMPTY=true
|
||||||
|
else
|
||||||
|
echo " ⚠️ IMAP Port: UNKNOWN"
|
||||||
|
IMAP_PORT_EMPTY=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ~/bin/nextcloud-mail --help 2>&1 | grep -q "imap-user.*wltbagent"; then
|
||||||
|
echo " ✅ IMAP User: wltbagent"
|
||||||
|
elif ~/bin/nextcloud-mail --help 2>&1 | grep -q "imap-user.*\""; then
|
||||||
|
echo " ❌ IMAP User: EMPTY"
|
||||||
|
IMAP_USER_EMPTY=true
|
||||||
|
elif ~/bin/nextcloud-mail --help 2>&1 | grep -q "imap-user.*[^[:alnum:]]"; then
|
||||||
|
echo " ✅ IMAP User: using custom value"
|
||||||
|
else
|
||||||
|
echo " ⚠️ IMAP User: UNKNOWN"
|
||||||
|
IMAP_USER_EMPTY=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if IMAP credentials are properly set
|
||||||
|
if [ "$IMAP_EMPTY" = true ] || [ "$IMAP_PORT_EMPTY" = true ] || [ "$IMAP_USER_EMPTY" = true ]; then
|
||||||
|
echo "❌ Error: IMAP credentials are not properly set!"
|
||||||
|
echo " Server: [$IMAP_EMPTY], Port: [$IMAP_PORT_EMPTY], User: [$IMAP_USER_EMPTY]"
|
||||||
|
echo ""
|
||||||
|
echo "Please run: ./build.sh <server-url> <username> <token>"
|
||||||
|
echo "And provide valid IMAP credentials (not just pressing Enter)."
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✓ IMAP credentials verified"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Verify embedded SMTP credentials
|
||||||
|
echo "Verifying embedded SMTP credentials..."
|
||||||
|
if ~/bin/nextcloud-mail --help 2>&1 | grep -q "smtp-server.*teamwork"; then
|
||||||
|
echo " ✅ SMTP Server: using default (teamworkapps.com)"
|
||||||
|
elif ~/bin/nextcloud-mail --help 2>&1 | grep -q "smtp-server.*\""; then
|
||||||
|
echo " ❌ SMTP Server: EMPTY string"
|
||||||
|
SMTP_EMPTY=true
|
||||||
|
elif ~/bin/nextcloud-mail --help 2>&1 | grep -q "smtp-server.*[^[:alnum:]]"; then
|
||||||
|
echo " ✅ SMTP Server: using custom value"
|
||||||
|
else
|
||||||
|
echo " ⚠️ SMTP Server: UNKNOWN"
|
||||||
|
SMTP_EMPTY=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ~/bin/nextcloud-mail --help 2>&1 | grep -q "smtp-port.*465"; then
|
||||||
|
echo " ✅ SMTP Port: 465"
|
||||||
|
elif ~/bin/nextcloud-mail --help 2>&1 | grep -q "smtp-port.*\""; then
|
||||||
|
echo " ❌ SMTP Port: EMPTY"
|
||||||
|
SMTP_PORT_EMPTY=true
|
||||||
|
else
|
||||||
|
echo " ⚠️ SMTP Port: UNKNOWN"
|
||||||
|
SMTP_PORT_EMPTY=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ~/bin/nextcloud-mail --help 2>&1 | grep -q "smtp-user.*josh"; then
|
||||||
|
echo " ✅ SMTP User: josh"
|
||||||
|
elif ~/bin/nextcloud-mail --help 2>&1 | grep -q "smtp-user.*\""; then
|
||||||
|
echo " ❌ SMTP User: EMPTY"
|
||||||
|
SMTP_USER_EMPTY=true
|
||||||
|
elif ~/bin/nextcloud-mail --help 2>&1 | grep -q "smtp-user.*[^[:alnum:]]"; then
|
||||||
|
echo " ✅ SMTP User: using custom value"
|
||||||
|
else
|
||||||
|
echo " ⚠️ SMTP User: UNKNOWN"
|
||||||
|
SMTP_USER_EMPTY=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if SMTP credentials are properly set
|
||||||
|
if [ "$SMTP_EMPTY" = true ] || [ "$SMTP_PORT_EMPTY" = true ] || [ "$SMTP_USER_EMPTY" = true ]; then
|
||||||
|
echo "❌ Error: SMTP credentials are not properly set!"
|
||||||
|
echo " Server: [$SMTP_EMPTY], Port: [$SMTP_PORT_EMPTY], User: [$SMTP_USER_EMPTY]"
|
||||||
|
echo ""
|
||||||
|
echo "Please run: ./build.sh <server-url> <username> <token>"
|
||||||
|
echo "And provide valid SMTP credentials (not just pressing Enter)."
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✓ SMTP credentials verified"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Test 1: List folders
|
# Test 1: List folders
|
||||||
@@ -42,79 +137,19 @@ echo ""
|
|||||||
|
|
||||||
# Test 2: List messages
|
# Test 2: List messages
|
||||||
echo "Test 2: List messages in INBOX"
|
echo "Test 2: List messages in INBOX"
|
||||||
echo "Running: ~/bin/nextcloud-mail --op list-messages --folder INBOX --page 1 --page-size 5"
|
echo "Running: ~/bin/nextcloud-mail --op list-messages --folder INBOX --page 1 --page-size 25"
|
||||||
~/bin/nextcloud-mail --op list-messages --folder INBOX --page 1 --page-size 5
|
~/bin/nextcloud-mail --op list-messages --folder INBOX --page 1 --page-size 25
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Test 3: Send test email
|
# Test 3: Send test email to self
|
||||||
echo "Test 3: Send test email to self"
|
echo "Test 3: Send test email to self"
|
||||||
TEST_SUBJECT="nextcloud-mail Test - $(date +%s)"
|
TEST_SUBJECT="nextcloud-mail Test - $(date +%s)"
|
||||||
echo "Running: ~/bin/nextcloud-mail --op send-email --from $USERNAME --to $USERNAME --subject '$TEST_SUBJECT'"
|
TEST_BODY="This is an automated test from nextcloud-mail at $(date)"
|
||||||
~/bin/nextcloud-mail --op send-email \
|
echo "Running: ~/bin/nextcloud-mail --op send-email --from $USERNAME --to $USERNAME --subject \"$TEST_SUBJECT\" --body \"$TEST_BODY\""
|
||||||
--from "$USERNAME" \
|
~/bin/nextcloud-mail --op send-email --from $USERNAME --to $USERNAME --subject "$TEST_SUBJECT" --body "$TEST_BODY"
|
||||||
--to "$USERNAME" \
|
|
||||||
--subject "$TEST_SUBJECT" \
|
|
||||||
--body "This is an automated test from nextcloud-mail tool."
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Wait for email to arrive
|
|
||||||
echo "Waiting 5 seconds for email to arrive..."
|
|
||||||
sleep 5
|
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "All tests completed!"
|
||||||
# Test 4: Search for test email
|
|
||||||
echo "Test 4: Search for test email"
|
|
||||||
echo "Running: ~/bin/nextcloud-mail --op search --folder INBOX --query '$TEST_SUBJECT'"
|
|
||||||
~/bin/nextcloud-mail --op search --folder INBOX --query "$TEST_SUBJECT"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Test 5: Send email with attachment
|
|
||||||
echo "Test 5: Send email with attachment"
|
|
||||||
echo "Creating test attachment..."
|
|
||||||
echo "This is a test attachment from nextcloud-mail." > "$TEST_DIR/attachment.txt"
|
|
||||||
echo "Running: ~/bin/nextcloud-mail --op send-email --from $USERNAME --to $USERNAME --subject 'Test with attachment' --attachments $TEST_DIR/attachment.txt"
|
|
||||||
~/bin/nextcloud-mail --op send-email \
|
|
||||||
--from "$USERNAME" \
|
|
||||||
--to "$USERNAME" \
|
|
||||||
--subject "Test with attachment - $(date +%s)" \
|
|
||||||
--body "Email with one attachment." \
|
|
||||||
--attachments "$TEST_DIR/attachment.txt"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Wait for attachment email
|
|
||||||
echo "Waiting 5 seconds for attachment email to arrive..."
|
|
||||||
sleep 5
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Test 6: Get message with attachment
|
|
||||||
echo "Test 6: Get message and list attachments"
|
|
||||||
echo "Finding recent message..."
|
|
||||||
UID=$(~/bin/nextcloud-mail --op list-messages --folder INBOX --page 1 --page-size 1 | grep "UID:" | awk '{print $2}')
|
|
||||||
if [ -n "$UID" ]; then
|
|
||||||
echo "Found UID: $UID"
|
|
||||||
echo "Running: ~/bin/nextcloud-mail --op get-message --folder INBOX --uids $UID --list-attachments"
|
|
||||||
~/bin/nextcloud-mail --op get-message --folder INBOX --uids "$UID" --list-attachments
|
|
||||||
|
|
||||||
# Test 7: Save attachments
|
|
||||||
echo ""
|
|
||||||
echo "Test 7: Save attachments"
|
|
||||||
mkdir -p "$TEST_DIR/downloads"
|
|
||||||
echo "Running: ~/bin/nextcloud-mail --op get-message --folder INBOX --uids $UID --save-attachments --save-dir $TEST_DIR/downloads"
|
|
||||||
~/bin/nextcloud-mail --op get-message --folder INBOX --uids "$UID" \
|
|
||||||
--save-attachments --save-dir "$TEST_DIR/downloads"
|
|
||||||
|
|
||||||
# Verify files were saved
|
|
||||||
echo ""
|
|
||||||
echo "Downloaded files:"
|
|
||||||
ls -lh "$TEST_DIR/downloads"
|
|
||||||
else
|
|
||||||
echo "⚠ Could not find message UID for attachment test"
|
|
||||||
fi
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
echo "========================================="
|
|
||||||
echo "Quick Test Suite Complete!"
|
|
||||||
echo "========================================="
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Test artifacts in: $TEST_DIR"
|
echo "Test artifacts in: $TEST_DIR"
|
||||||
echo "For full testing, see: TEST-PLAN.md"
|
|
||||||
Reference in new issue
Block a user