diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a105352..ea13ea2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,13 +16,13 @@ jobs: matrix: php-version: [ "8.2"] laravel: [11] - + name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} steps: - name: Checkout code uses: actions/checkout@v4 - + - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -31,9 +31,9 @@ jobs: ini-values: error_reporting=E_ALL tools: composer:v2 coverage: none - + - name: Start Centrifugo - run: docker run -d -p 8000:8000 -e CENTRIFUGO_TOKEN_HMAC_SECRET_KEY="secret" -e CENTRIFUGO_PRESENCE=1 -e CENTRIFUGO_JOIN_LEAVE=true -e CENTRIFUGO_FORCE_PUSH_JOIN_LEAVE=true -e CENTRIFUGO_HISTORY_TTL=300s -e CENTRIFUGO_HISTORY_SIZE=100 -e CENTRIFUGO_FORCE_RECOVERY=true -e CENTRIFUGO_USER_SUBSCRIBE_TO_PERSONAL=true -e CENTRIFUGO_ALLOW_PUBLISH_FOR_SUBSCRIBER=true -e CENTRIFUGO_ALLOW_PRESENCE_FOR_SUBSCRIBER=true -e CENTRIFUGO_ALLOW_HISTORY_FOR_SUBSCRIBER=true centrifugo/centrifugo:v5 centrifugo + run: docker run -d -p 8000:8000 -e CENTRIFUGO_TOKEN_HMAC_SECRET_KEY="secret" -e CENTRIFUGO_YOUR-API-KEY-HERE="api-key" -e CENTRIFUGO_PRESENCE=1 -e CENTRIFUGO_JOIN_LEAVE=true -e CENTRIFUGO_FORCE_PUSH_JOIN_LEAVE=true -e CENTRIFUGO_HISTORY_TTL=300s -e CENTRIFUGO_HISTORY_SIZE=100 -e CENTRIFUGO_FORCE_RECOVERY=true -e CENTRIFUGO_USER_SUBSCRIBE_TO_PERSONAL=true -e CENTRIFUGO_ALLOW_PUBLISH_FOR_SUBSCRIBER=true -e CENTRIFUGO_ALLOW_PRESENCE_FOR_SUBSCRIBER=true -e CENTRIFUGO_ALLOW_HISTORY_FOR_SUBSCRIBER=true centrifugo/centrifugo:v5 centrifugo - name: Check container status run: docker ps @@ -49,6 +49,6 @@ jobs: run: | composer require "illuminate/contracts=^${{ matrix.laravel }}" --no-update composer update --prefer-dist --no-interaction --no-progress - + - name: PHPUnit Tests run: vendor/bin/phpunit diff --git a/src/Centrifugo.php b/src/Centrifugo.php index 3c08773..be4365f 100644 --- a/src/Centrifugo.php +++ b/src/Centrifugo.php @@ -330,8 +330,6 @@ protected function getApiKey(): string */ protected function send(string $method, array $params = []) : array { - $json = json_encode(['method' => $method, 'params' => $params]); - $url = $this->prepareUrl(); $config =[ diff --git a/tests/TestCase.php b/tests/TestCase.php index 6a682f7..845c0ff 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -28,12 +28,12 @@ protected function getPackageProviders($app): array protected function getEnvironmentSetUp($app) { - + $app['config']->set('broadcasting.default', 'centrifugo'); $app['config']->set('broadcasting.connections.centrifugo', [ 'driver' => 'centrifugo', - 'token_hmac_secret_key' => '', //0cac68ac-5965-46bf-8c44-ed28a03ab8ba - 'api_key' => '', //ae3362d2-5862-4261-9b3b-6b231f8863c8 + 'token_hmac_secret_key' => 'secret', + 'api_key' => 'api-key', 'url' => 'http://localhost:8000', ]); } diff --git a/tests/Unit/CentrifugoTest.php b/tests/Unit/CentrifugoTest.php index 1167732..b68118d 100644 --- a/tests/Unit/CentrifugoTest.php +++ b/tests/Unit/CentrifugoTest.php @@ -1,4 +1,5 @@ "Tristian", @@ -25,17 +31,17 @@ public function testGenerateToken(): void ]; $clientId = "f2527b6a-6705-45b7-a1d9-d0029943dc20"; - $clientToken1 = $this->centrifuge->generateConnectionToken($clientId, $timestamp); - + $clientToken1 = $this->centrifuge->generateConnectionToken(userId:$clientId); $this->assertEquals( - 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJmMjUyN2I2YS02NzA1LTQ1YjctYTFkOS1kMDAyOTk0M2RjMjAiLCJleHAiOjE3Mjc3MTY4MDN9.om2AdKJLNYbZ7bfeIS9tw0AJqs1RIp5irUGNfPiqHqk', + 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJmMjUyN2I2YS02NzA1LTQ1YjctYTFkOS1kMDAyOTk0M2RjMjAifQ.csRuDJhBalF3J3v6JnsNZmOXLx6nbNMi3zcCieJJqng', $clientToken1 ); - $clientToken2 = $this->centrifuge->generatePrivateChannelToken($clientId, 'test', $timestamp, $info); + $clientToken2 = $this->centrifuge->generatePrivateChannelToken(userId:$clientId, channel:'test', info:$info); + $this->assertEquals( - 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjaGFubmVsIjoidGVzdCIsImNsaWVudCI6ImYyNTI3YjZhLTY3MDUtNDViNy1hMWQ5LWQwMDI5OTQzZGMyMCIsImluZm8iOnsiZmlyc3RfbmFtZSI6IlRyaXN0aWFuIiwibGFzdF9uYW1lIjoiUnVlY2tlciJ9LCJleHAiOjE3Mjc3MTY4MDN9.UtzQDjU1RDXKizcBlvF5VMR45_crs6AU4tcO-EfPnjM', + 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjaGFubmVsIjoidGVzdCIsInN1YiI6ImYyNTI3YjZhLTY3MDUtNDViNy1hMWQ5LWQwMDI5OTQzZGMyMCIsImluZm8iOnsiZmlyc3RfbmFtZSI6IlRyaXN0aWFuIiwibGFzdF9uYW1lIjoiUnVlY2tlciJ9fQ.8wNO3gQdg6Knk9J7mPZquV8aAsDtqI2a4A5tK5Y9IR8', $clientToken2 ); }