diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 3fe9535..8c5d5eb 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -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/assert-command-line-output@v2.4 + with: + command_line: bin/console.php ether:scan http://localhost:9001 + contains: "Admin area is accessible with admin / admin" + expected_result: PASSED diff --git a/src/Service/ScannerService.php b/src/Service/ScannerService.php index 166c4cb..6d32807 100644 --- a/src/Service/ScannerService.php +++ b/src/Service/ScannerService.php @@ -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); + 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); }