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
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: Scan etherpad instance
uses: GuillaumeFalourd/[email protected]
with:
command_line: bin/console.php ether:scan -vvv http://localhost:8080 | grep -E "Package version|HTTP/1.1 400" | sed 's/ *$//'
command_line: bin/console.php ether:scan -vvv http://localhost:8080 | grep -E "Package version|HTTP/1.1 400|Websocket" | sed 's/ *$//'
assert_file_path: tests/e2e/fixture/reverse_proxy_no_websocket.txt
expected_result: PASSED

Expand Down
7 changes: 6 additions & 1 deletion src/Console/ScanCommandOutputHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,14 @@ public function onScanPadException(Throwable $e): void
$this->symfonyStyle->error($e->getMessage());
}

public function onScanPadSuccess(): void
public function onScanPadSuccess(bool $usedWebsocket): void
{
$this->symfonyStyle->success('Pads are publicly accessible');
if ($usedWebsocket) {
$this->symfonyStyle->success('Websocket is supported');
} else {
$this->symfonyStyle->error('Websocket is not supported');
}
}

public function onVersionResult(?string $minVersion, ?string $maxVersion): void
Expand Down
7 changes: 6 additions & 1 deletion src/Service/ScannerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Gared\EtherScan\Service;

use ElephantIO\Client as ElephantClient;
use ElephantIO\Engine\SocketIO;
use Exception;
use Gared\EtherScan\Api\GithubApi;
use Gared\EtherScan\Exception\EtherpadServiceNotFoundException;
Expand Down Expand Up @@ -337,6 +338,10 @@ private function doSocketWebsocket(
'password' => null,
'protocolVersion' => 2,
]);
$engine = $socketIoClient->getEngine();
if ($engine instanceof SocketIO === false) {
throw new Exception('Engine of unsupported class');
}

while ($result = $socketIoClient->wait('message', 2)) {
if (is_array($result->data)) {
Expand All @@ -357,7 +362,7 @@ private function doSocketWebsocket(
$this->versionRangeService->setPackageVersion($version);
$callback->onClientVars($version, $result->data);
$callback->onScanPluginsList($onlyPlugins);
$callback->onScanPadSuccess();
$callback->onScanPadSuccess($engine->getTransport() === SocketIO::TRANSPORT_WEBSOCKET);
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Service/ScannerServiceCallbackInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function onScanPadStart(): void;

public function onScanPadException(Throwable $e): void;

public function onScanPadSuccess(): void;
public function onScanPadSuccess(bool $usedWebsocket): void;

public function onVersionResult(?string $minVersion, ?string $maxVersion): void;

Expand All @@ -64,4 +64,4 @@ public function onVersionResult(?string $minVersion, ?string $maxVersion): void;
public function onClientVars(string $version, array $data): void;

public function getConsoleLogger(): ?LoggerInterface;
}
}
2 changes: 2 additions & 0 deletions tests/e2e/fixture/latest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Starting scan of a pad...

[OK] Pads are publicly accessible

[OK] Websocket is supported

[OK] Server is healthy

[INFO] Version is $EP_VERSION
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/fixture/master_with_plugins.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Plugins:

[OK] Pads are publicly accessible

[OK] Websocket is supported

[OK] Server is healthy


Expand Down
1 change: 1 addition & 0 deletions tests/e2e/fixture/reverse_proxy_no_websocket.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[debug] Stream receive: HTTP/1.1 400 Bad Request
[INFO] Package version: 1.8.17
[ERROR] Websocket is not supported
Loading