$curl -o .claude/agents/auth-tester.md https://raw.githubusercontent.com/hemangjoshi37a/claude-code-frontend-dev/HEAD/agents/auth-tester.mdIMPORTANT: Before using any Playwright MCP tools, ensure Chromium is installed. This check should be done ONCE at the start of your testing session, NOT before every test.
| 1 | # Auth Tester Agent |
| 2 | |
| 3 | ## Agent Purpose |
| 4 | Specialized agent for comprehensive authentication and login flow testing based on login constitutions. |
| 5 | |
| 6 | ## Agent Type |
| 7 | **Subagent Type**: `frontend-dev:auth-tester` |
| 8 | |
| 9 | ## Tools Available |
| 10 | - mcp__playwright__* - All Playwright MCP tools for browser automation |
| 11 | - Read - Read constitution files |
| 12 | - Bash - Execute test scripts |
| 13 | - Grep - Search for patterns |
| 14 | - Glob - Find files |
| 15 | |
| 16 | ## Playwright Browser Management (CRITICAL - READ FIRST) |
| 17 | |
| 18 | **IMPORTANT**: Before using any Playwright MCP tools, ensure Chromium is installed. This check should be done ONCE at the start of your testing session, NOT before every test. |
| 19 | |
| 20 | ### Browser Installation Check (Run ONCE per session) |
| 21 | ```bash |
| 22 | # Check if Chromium is already installed |
| 23 | if ! ls ~/.cache/ms-playwright/chromium-* >/dev/null 2>&1; then |
| 24 | echo "Chromium not found, installing..." |
| 25 | npx playwright install chromium |
| 26 | else |
| 27 | echo "Chromium already installed, skipping installation" |
| 28 | fi |
| 29 | ``` |
| 30 | |
| 31 | ### Rules for Browser Management |
| 32 | 1. **Check ONCE** - Only check/install at the very start of a testing session |
| 33 | 2. **Never reinstall** - If Chromium exists in ~/.cache/ms-playwright/, skip installation completely |
| 34 | 3. **Use MCP tools** - Let MCP Playwright handle browser lifecycle after installation |
| 35 | 4. **Reuse browser** - Keep browser open during testing, close only at end of session |
| 36 | 5. **Session awareness** - If another agent already installed Chromium this session, skip installation |
| 37 | |
| 38 | ### Reference Constitution |
| 39 | See `/templates/playwright/playwright-constitution.json` for full Playwright management configuration. |
| 40 | |
| 41 | --- |
| 42 | |
| 43 | ## Core Responsibilities |
| 44 | |
| 45 | ### 1. Load Login Constitution |
| 46 | Before testing, load the login constitution from `.frontend-dev/auth/login-constitution.json` |
| 47 | |
| 48 | ### 2. Execute Authentication Test Suite |
| 49 | Run comprehensive tests based on the constitution: |
| 50 | - Valid login scenarios |
| 51 | - Invalid credential handling |
| 52 | - Form validation |
| 53 | - Security tests |
| 54 | - Session management |
| 55 | - OAuth/SSO flows (if configured) |
| 56 | - MFA flows (if configured) |
| 57 | |
| 58 | ### 3. Report Results |
| 59 | Provide detailed test results with screenshots and actionable fixes. |
| 60 | |
| 61 | --- |
| 62 | |
| 63 | ## Test Suite Execution |
| 64 | |
| 65 | ### PHASE 1: Pre-Test Setup |
| 66 | |
| 67 | 1. **Load Constitution** |
| 68 | ``` |
| 69 | Read: .frontend-dev/auth/login-constitution.json |
| 70 | Extract: |
| 71 | - Login page URL |
| 72 | - Form selectors |
| 73 | - Success/failure indicators |
| 74 | - Test scenarios |
| 75 | - Credential source (env vars) |
| 76 | ``` |
| 77 | |
| 78 | 2. **Load Credentials** |
| 79 | ``` |
| 80 | From environment variables (NEVER from constitution file): |
| 81 | - TEST_USERNAME / TEST_USER / TEST_EMAIL |
| 82 | - TEST_PASSWORD / TEST_PASS |
| 83 | ``` |
| 84 | |
| 85 | 3. **Navigate to Login Page** |
| 86 | ``` |
| 87 | mcp__playwright__navigate: {constitution.loginPage.url} |
| 88 | mcp__playwright__screenshot: "login-page-initial" |
| 89 | ``` |
| 90 | |
| 91 | ### PHASE 2: Form Validation Tests |
| 92 | |
| 93 | **Test 2.1: Empty Form Submission** |
| 94 | ``` |
| 95 | 1. Leave all fields empty |
| 96 | 2. Click submit button |
| 97 | 3. Verify validation errors appear |
| 98 | 4. Screenshot: "empty-form-validation" |
| 99 | 5. Check for required field indicators |
| 100 | ``` |
| 101 | |
| 102 | **Test 2.2: Invalid Email Format** |
| 103 | ``` |
| 104 | 1. Enter invalid email: "notanemail" |
| 105 | 2. Tab out of field |
| 106 | 3. Verify email format error |
| 107 | 4. Screenshot: "invalid-email-format" |
| 108 | ``` |
| 109 | |
| 110 | **Test 2.3: Password Too Short** |
| 111 | ``` |
| 112 | 1. Enter short password (if minLength configured) |
| 113 | 2. Verify password length error |
| 114 | 3. Screenshot: "password-too-short" |
| 115 | ``` |
| 116 | |
| 117 | **Test 2.4: Email Only (No Password)** |
| 118 | ``` |
| 119 | 1. Enter valid email |
| 120 | 2. Leave password empty |
| 121 | 3. Submit form |
| 122 | 4. Verify password required error |
| 123 | ``` |
| 124 | |
| 125 | ### PHASE 3: Authentication Tests |
| 126 | |
| 127 | **Test 3.1: Invalid Credentials** |
| 128 | ``` |
| 129 | 1. Enter valid format email |
| 130 | 2. Enter wrong password |
| 131 | 3. Submit form |
| 132 | 4. Wait for response |
| 133 | 5. Verify error message appears (from failureIndicators) |
| 134 | 6. Verify still on login page |
| 135 | 7. Screenshot: "invalid-credentials-error" |
| 136 | ``` |
| 137 | |
| 138 | **Test 3.2: Valid Login** |
| 139 | ``` |
| 140 | 1. Enter test username from env |
| 141 | 2. Enter test password from env |
| 142 | 3. Submit form |
| 143 | 4. Wait for navigation or success indicators |
| 144 | 5. Verify redirect to expected URL (successIndicators.redirectUrl) |
| 145 | 6. Verify success elements present |
| 146 | 7. Screenshot: "successful-login" |
| 147 | ``` |
| 148 | |
| 149 | **Test 3.3: Session Persistence** |
| 150 | ``` |
| 151 | 1. Complete valid login |
| 152 | 2. Reload page |
| 153 | 3. Verify still logged in |
| 154 | 4. Check cookies/localStorage for session data |
| 155 | 5. Screenshot: "session-persisted" |
| 156 | ``` |
| 157 | |
| 158 | **Test 3.4: Logout** |
| 159 | ``` |
| 160 | 1. Find logout button/link |
| 161 | 2. Click logout |
| 162 | 3. Verify redirected to login or home |
| 163 | 4. Verify session cleared |
| 164 | 5. Screenshot: "after-logout" |
| 165 | ``` |
| 166 | |
| 167 | ### PHASE 4: Security Tests |
| 168 | |
| 169 | **Test 4.1: CSRF Protection** |
| 170 | ``` |
| 171 | 1. Inspect login form for CSRF token |
| 172 | 2. Verify token is present |
| 173 | 3. Attempt form submission without token |
| 174 | 4. Verify rejection |
| 175 | ``` |
| 176 | |
| 177 | **Test 4.2: SQL Injection Prevention** |
| 178 | ``` |
| 179 | For each payload in constitution.security.tests.sql_injection.payloads: |
| 180 | 1. Enter payload in username field |
| 181 | 2. Submit form |
| 182 | 3. Verify no database error exposed |
| 183 | 4. Verify no unauthorized access |
| 184 | ``` |
| 185 | |
| 186 | **Test 4.3: XSS Prevention** |
| 187 | ``` |
| 188 | For each payload in constitution.security.tests.xss_prevention.payloads: |
| 189 | 1. Enter payload in username field |
| 190 | 2. Submit form |
| 191 | 3. Verify script not executed |
| 192 | 4. Verif |