Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 13 additions & 5 deletions src/Service/ScannerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link

Copilot AI Jul 14, 2025

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.

Copilot uses AI. Check for mistakes.
if ($e->getCode() === 401) {
$callback->onScanAdminResult($user, $password, false);
Comment on lines +231 to +235
Copy link

Copilot AI Jul 14, 2025

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.

Suggested change
$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 uses AI. Check for mistakes.
return;
}
}

try {
$response = $this->client->get($this->baseUrl . 'admin/', [
'auth' => [$user, $password],
]);
$callback->onScanAdminResult($user, $password, $response->getStatusCode() === 200);
return;
} catch (GuzzleException) {
$callback->onScanAdminResult($user, $password, false);
Copy link

Copilot AI Jul 14, 2025

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.

Suggested change
$callback->onScanAdminResult($user, $password, false);
$callback->onScanAdminResult($user, $password, false);
return;

Copilot uses AI. Check for mistakes.
}
Expand Down