-
Notifications
You must be signed in to change notification settings - Fork 0
Add test case for admin login #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a test case and implementation updates to verify admin login functionality during scanning.
- Updated
getAdminin ScannerService to POST toadmin-auth/and fall back to GETadmin/ - Added a new GitHub Actions job
EtherpadAdminLoginto run an end-to-end admin login check
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Service/ScannerService.php | Replace GET with POST admin-auth, handle auth responses and fallback GET request |
| .github/workflows/e2e-test.yml | Add new EtherpadAdminLogin job to test admin login in CI |
Comments suppressed due to low confidence (1)
.github/workflows/e2e-test.yml:395
- E2E tests cover successful admin login but lack a test for failed login scenarios. Consider adding a case with incorrect credentials to verify the false path.
command_line: bin/console.php ether:scan http://localhost:9001
| $callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200); | ||
| return; | ||
| } catch (GuzzleException) { | ||
| $callback->onScanAdminResult($user, $password, false); |
Copilot
AI
Jul 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing return after callback in the second catch block. Without an explicit return, code after this block could execute, causing multiple callbacks or unintended behavior. Add return; after invoking the callback.
| $callback->onScanAdminResult($user, $password, false); | |
| $callback->onScanAdminResult($user, $password, false); | |
| return; |
| ]); | ||
| $callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200); | ||
| return; | ||
| } catch (GuzzleException $e) { |
Copilot
AI
Jul 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Catching all GuzzleExceptions without logging or rethrowing hides potential issues beyond authentication failures. Consider logging the exception or rethrowing unexpected errors to improve debuggability.
| $callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200); | ||
| return; | ||
| } catch (GuzzleException $e) { | ||
| if ($e->getCode() === 401) { | ||
| $callback->onScanAdminResult($user, $password, false); |
Copilot
AI
Jul 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The callback invocation is duplicated across multiple branches. Consider refactoring to extract a helper or iterate endpoints to reduce duplication.
| $callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200); | |
| return; | |
| } catch (GuzzleException $e) { | |
| if ($e->getCode() === 401) { | |
| $callback->onScanAdminResult($user, $password, false); | |
| $this->invokeScanAdminResult($callback, $user, $password, $response->getStatusCode() === 200); | |
| return; | |
| } catch (GuzzleException $e) { | |
| if ($e->getCode() === 401) { | |
| $this->invokeScanAdminResult($callback, $user, $password, false); |
No description provided.