Files
nextcloud-integration/quick-test.sh
T
WLTBAgent 2c3a49f2d5 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.
2026-02-24 01:52:51 +00:00

156 lines
5.2 KiB
Bash
Executable File

#!/bin/bash
# Quick Test Script for nextcloud-mail
# Usage: ./quick-test.sh
set -e
USERNAME="${1:-wltbagent@shortcutsolutions.net}"
TEST_DIR="/tmp/mail-tests"
echo "========================================="
echo "nextcloud-mail Quick Test Suite"
echo "========================================="
echo ""
# Check if binary has credentials before running
echo "Checking binary credentials..."
if ~/bin/nextcloud-mail --help 2>&1 | grep -q '"imap-server".*"\"'; then
echo "❌ Error: nextcloud-mail binary was built with empty credentials!"
echo " Please run ./build.sh again and provide valid IMAP/SMTP credentials."
echo ""
echo "Current binary shows:"
~/bin/nextcloud-mail --help 2>&1 | grep -A2 '"imap-server"'
echo ""
exit 1
fi
echo "✓ Binary has credentials configured"
echo "Username: $USERNAME"
echo "Test Directory: $TEST_DIR"
echo ""
# Verify embedded credentials
echo "Verifying embedded IMAP credentials..."
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 ""
# Test 1: List folders
echo "Test 1: List folders"
echo "Running: ~/bin/nextcloud-mail --op list-folders"
~/bin/nextcloud-mail --op list-folders
echo ""
# Test 2: List messages
echo "Test 2: List messages in INBOX"
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 25
echo ""
# Test 3: Send test email to self
echo "Test 3: Send test email to self"
TEST_SUBJECT="nextcloud-mail Test - $(date +%s)"
TEST_BODY="This is an automated test from nextcloud-mail at $(date)"
echo "Running: ~/bin/nextcloud-mail --op send-email --from $USERNAME --to $USERNAME --subject \"$TEST_SUBJECT\" --body \"$TEST_BODY\""
~/bin/nextcloud-mail --op send-email --from $USERNAME --to $USERNAME --subject "$TEST_SUBJECT" --body "$TEST_BODY"
echo ""
echo ""
echo "All tests completed!"
echo ""
echo "Test artifacts in: $TEST_DIR"