#!/usr/bin/env python3
import imaplib
import ssl

def test_login(username, password):
    try:
        print(f"Testing login with username: {username}")
        context = ssl.create_default_context()
        context.check_hostname = False
        context.verify_mode = ssl.CERT_NONE
        
        mail = imaplib.IMAP4_SSL('localhost', 9930, ssl_context=context)
        result = mail.login(username, password)
        print(f"SUCCESS: {username} - {result}")
        mail.logout()
        return True
        
    except Exception as e:
        print(f"FAILED: {username} - {e}")
        return False

# Try different username formats
usernames = [
    'tanya@jongsma.me',
    'tanya',
    'Tanya',
    'TANYA',
    'tanya@inou.com',
    'admin'  # Fallback admin account
]

password = 'Tanya-Migrate-2026!'

for username in usernames:
    if test_login(username, password):
        print(f"Found working username: {username}")
        break
    print()

# Try admin with different password if configured
admin_passwords = [
    'Tanya-Migrate-2026!',
    'admin',
    'password',
    ''
]

print("\nTrying admin account with different passwords:")
for pwd in admin_passwords:
    if test_login('admin', pwd):
        print(f"Admin works with password: {pwd}")
        break