From 48cf4a943f611678be7337c46706a45b6e7684d7 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Fri, 30 Aug 2024 15:10:03 +0200 Subject: [PATCH] fix(oauth2): fix tests Signed-off-by: Julien Veyssier --- .../lib/Migration/Version011901Date20240829164356.php | 2 +- .../oauth2/tests/Controller/OauthApiControllerTest.php | 10 +++++----- .../oauth2/tests/Controller/SettingsControllerTest.php | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/oauth2/lib/Migration/Version011901Date20240829164356.php b/apps/oauth2/lib/Migration/Version011901Date20240829164356.php index 9ce9ff371cbde..20f5754bf1138 100644 --- a/apps/oauth2/lib/Migration/Version011901Date20240829164356.php +++ b/apps/oauth2/lib/Migration/Version011901Date20240829164356.php @@ -23,7 +23,7 @@ public function __construct( ) { } - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { $qbUpdate = $this->connection->getQueryBuilder(); $qbUpdate->update('oauth2_clients') ->set('secret', $qbUpdate->createParameter('updateSecret')) diff --git a/apps/oauth2/tests/Controller/OauthApiControllerTest.php b/apps/oauth2/tests/Controller/OauthApiControllerTest.php index ec4826b75e870..56a49288ada1e 100644 --- a/apps/oauth2/tests/Controller/OauthApiControllerTest.php +++ b/apps/oauth2/tests/Controller/OauthApiControllerTest.php @@ -282,7 +282,7 @@ public function testRefreshTokenInvalidClient($clientId, $clientSecret) { $client = new Client(); $client->setClientIdentifier('clientId'); - $client->setSecret('hashedClientSecret'); + $client->setSecret(bin2hex('hashedClientSecret')); $this->clientMapper->method('getByUid') ->with(42) ->willReturn($client); @@ -307,7 +307,7 @@ public function testRefreshTokenInvalidAppToken() { $client = new Client(); $client->setClientIdentifier('clientId'); - $client->setSecret('hashedClientSecret'); + $client->setSecret(bin2hex('hashedClientSecret')); $this->clientMapper->method('getByUid') ->with(42) ->willReturn($client); @@ -345,7 +345,7 @@ public function testRefreshTokenValidAppToken() { $client = new Client(); $client->setClientIdentifier('clientId'); - $client->setSecret('hashedClientSecret'); + $client->setSecret(bin2hex('hashedClientSecret')); $this->clientMapper->method('getByUid') ->with(42) ->willReturn($client); @@ -441,7 +441,7 @@ public function testRefreshTokenValidAppTokenBasicAuth() { $client = new Client(); $client->setClientIdentifier('clientId'); - $client->setSecret('hashedClientSecret'); + $client->setSecret(bin2hex('hashedClientSecret')); $this->clientMapper->method('getByUid') ->with(42) ->willReturn($client); @@ -540,7 +540,7 @@ public function testRefreshTokenExpiredAppToken() { $client = new Client(); $client->setClientIdentifier('clientId'); - $client->setSecret('hashedClientSecret'); + $client->setSecret(bin2hex('hashedClientSecret')); $this->clientMapper->method('getByUid') ->with(42) ->willReturn($client); diff --git a/apps/oauth2/tests/Controller/SettingsControllerTest.php b/apps/oauth2/tests/Controller/SettingsControllerTest.php index 06eca4f0fb9d3..0b1f0809eaa11 100644 --- a/apps/oauth2/tests/Controller/SettingsControllerTest.php +++ b/apps/oauth2/tests/Controller/SettingsControllerTest.php @@ -108,7 +108,7 @@ public function testAddClient() { $client = new Client(); $client->setName('My Client Name'); $client->setRedirectUri('https://example.com/'); - $client->setSecret('MyHashedSecret'); + $client->setSecret(bin2hex('MyHashedSecret')); $client->setClientIdentifier('MyClientIdentifier'); $this->clientMapper @@ -117,7 +117,7 @@ public function testAddClient() { ->with($this->callback(function (Client $c) { return $c->getName() === 'My Client Name' && $c->getRedirectUri() === 'https://example.com/' && - $c->getSecret() === 'MyHashedSecret' && + $c->getSecret() === bin2hex('MyHashedSecret') && $c->getClientIdentifier() === 'MyClientIdentifier'; }))->willReturnCallback(function (Client $c) { $c->setId(42); @@ -160,7 +160,7 @@ public function testDeleteClient() { $client->setId(123); $client->setName('My Client Name'); $client->setRedirectUri('https://example.com/'); - $client->setSecret('MyHashedSecret'); + $client->setSecret(bin2hex('MyHashedSecret')); $client->setClientIdentifier('MyClientIdentifier'); $this->clientMapper