-
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
Changes from all commits
129f8d3
688d838
84eee93
ddd1ed9
8d74f95
01b6945
ee516af
852f9c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -351,3 +351,47 @@ jobs: | |
| command_line: bin/console.php ether:scan http://localhost:9001 | ||
| contains: "Package version: ${{ matrix.versions.expected }}" | ||
| expected_result: PASSED | ||
|
|
||
| EtherpadAdminLogin: | ||
| name: Docker admin login [${{ matrix.versions.tag }}] | ||
| runs-on: ubuntu-latest | ||
|
|
||
| services: | ||
| etherpad: | ||
| image: etherpad/etherpad:${{ matrix.versions.tag }} | ||
| env: | ||
| ADMIN_PASSWORD: admin | ||
| ports: | ||
| - 9001:9001 | ||
|
|
||
| strategy: | ||
| matrix: | ||
| versions: [ | ||
| { tag: "2.3.2" }, | ||
| { tag: "2.2.2" }, | ||
| { tag: "1.9.7" }, | ||
| { tag: "1.8.0" }, | ||
| ] | ||
| fail-fast: false | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Cache Composer packages | ||
| id: composer-cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: vendor | ||
| key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-php- | ||
|
|
||
| - name: Install dependencies | ||
| run: composer install --prefer-dist --no-progress | ||
|
|
||
| - name: Scan etherpad instance | ||
| uses: GuillaumeFalourd/[email protected] | ||
| with: | ||
| command_line: bin/console.php ether:scan http://localhost:9001 | ||
| contains: "Admin area is accessible with admin / admin" | ||
| expected_result: PASSED | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -225,16 +225,24 @@ private function scanPad(ScannerServiceCallbackInterface $callback): void | |||||||||||||||||||||
| private function getAdmin(string $user, string $password, ScannerServiceCallbackInterface $callback): void | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| try { | ||||||||||||||||||||||
| $response = $this->client->get($this->baseUrl . 'admin', [ | ||||||||||||||||||||||
| $response = $this->client->post($this->baseUrl . 'admin-auth/', [ | ||||||||||||||||||||||
| 'auth' => [$user, $password], | ||||||||||||||||||||||
| ]); | ||||||||||||||||||||||
| if ($response->getStatusCode() === 301) { | ||||||||||||||||||||||
| $response = $this->client->post($this->baseUrl . 'admin-auth/', [ | ||||||||||||||||||||||
| 'auth' => [$user, $password], | ||||||||||||||||||||||
| ]); | ||||||||||||||||||||||
| $callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } catch (GuzzleException $e) { | ||||||||||||||||||||||
| if ($e->getCode() === 401) { | ||||||||||||||||||||||
| $callback->onScanAdminResult($user, $password, false); | ||||||||||||||||||||||
|
Comment on lines
+231
to
+235
|
||||||||||||||||||||||
| $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); |
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; |
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.