| 98 | |
| 99 | // Mock the passport authentication function behavior |
| 100 | const basicAuthCheck = req => { |
| 101 | const auth = req.headers.authorization; |
| 102 | if (!auth || !auth.startsWith("Basic ")) return false; |
| 103 | |
| 104 | const encoded = auth.slice(6); |
| 105 | const decoded = Buffer.from(encoded, "base64").toString(); |
| 106 | const [username, password] = decoded.split(":"); |
| 107 | |
| 108 | const validUsers = { "user1": "password1", "user2": "password2", "admin": "secret123" }; |
| 109 | |
| 110 | return validUsers[username] === password; |
| 111 | }; |
| 112 | |
| 113 | suite |
| 114 | .add("Basic Auth - Valid credentials", () => { |
no outgoing calls
no test coverage detected