Skip to content

Commit dd2fca7

Browse files
authored
Merge pull request #1488 from arshidkv12/master
Drop setAccessible() usage for PHP 8.5 support
2 parents 2c076b1 + 80c79fa commit dd2fca7

File tree

4 files changed

+0
-32
lines changed

4 files changed

+0
-32
lines changed

tests/AuthorizationServerTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ public function testGetResponseType(): void
140140

141141
$abstractGrantReflection = new ReflectionClass($server);
142142
$method = $abstractGrantReflection->getMethod('getResponseType');
143-
$method->setAccessible(true);
144143

145144
self::assertInstanceOf(BearerTokenResponse::class, $method->invoke($server));
146145
}
@@ -161,17 +160,14 @@ public function testGetResponseTypeExtended(): void
161160

162161
$abstractGrantReflection = new ReflectionClass($server);
163162
$method = $abstractGrantReflection->getMethod('getResponseType');
164-
$method->setAccessible(true);
165163

166164
$responseType = $method->invoke($server);
167165

168166
$responseTypeReflection = new ReflectionClass($responseType);
169167

170168
$privateKeyProperty = $responseTypeReflection->getProperty('privateKey');
171-
$privateKeyProperty->setAccessible(true);
172169

173170
$encryptionKeyProperty = $responseTypeReflection->getProperty('encryptionKey');
174-
$encryptionKeyProperty->setAccessible(true);
175171

176172
// generated instances should have keys setup
177173
self::assertSame($privateKey, $privateKeyProperty->getValue($responseType)->getKeyPath());
@@ -211,7 +207,6 @@ public function getEncryptionKey(): Key|string|null
211207

212208
$abstractGrantReflection = new ReflectionClass($server);
213209
$method = $abstractGrantReflection->getMethod('getResponseType');
214-
$method->setAccessible(true);
215210

216211
$responseTypeA = $method->invoke($server);
217212
$responseTypeB = $method->invoke($server);

tests/AuthorizationValidators/BearerTokenValidatorTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public function testBearerTokenValidatorAcceptsValidToken(): void
2929

3030
$bearerTokenValidatorReflection = new ReflectionClass(BearerTokenValidator::class);
3131
$jwtConfiguration = $bearerTokenValidatorReflection->getProperty('jwtConfiguration');
32-
$jwtConfiguration->setAccessible(true);
3332

3433
$validJwt = $jwtConfiguration->getValue($bearerTokenValidator)->builder()
3534
->permittedFor('client-id')
@@ -57,7 +56,6 @@ public function testBearerTokenValidatorRejectsExpiredToken(): void
5756

5857
$bearerTokenValidatorReflection = new ReflectionClass(BearerTokenValidator::class);
5958
$jwtConfiguration = $bearerTokenValidatorReflection->getProperty('jwtConfiguration');
60-
$jwtConfiguration->setAccessible(true);
6159

6260
$expiredJwt = $jwtConfiguration->getValue($bearerTokenValidator)->builder()
6361
->permittedFor('client-id')
@@ -89,7 +87,6 @@ public function testBearerTokenValidatorAcceptsExpiredTokenWithinLeeway(): void
8987

9088
$bearerTokenValidatorReflection = new ReflectionClass(BearerTokenValidator::class);
9189
$jwtConfiguration = $bearerTokenValidatorReflection->getProperty('jwtConfiguration');
92-
$jwtConfiguration->setAccessible(true);
9390

9491
$jwtTokenFromFutureWithinLeeway = $jwtConfiguration->getValue($bearerTokenValidator)->builder()
9592
->permittedFor('client-id')
@@ -120,7 +117,6 @@ public function testBearerTokenValidatorRejectsExpiredTokenBeyondLeeway(): void
120117

121118
$bearerTokenValidatorReflection = new ReflectionClass(BearerTokenValidator::class);
122119
$jwtConfiguration = $bearerTokenValidatorReflection->getProperty('jwtConfiguration');
123-
$jwtConfiguration->setAccessible(true);
124120

125121
$jwtTokenFromFutureBeyondLeeway = $jwtConfiguration->getValue($bearerTokenValidator)->builder()
126122
->permittedFor('client-id')

tests/Exception/OAuthServerExceptionTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ private function issueInvalidClientException(ServerRequestInterface $serverReque
101101
$abstractGrantReflection = new ReflectionClass($grantMock);
102102

103103
$validateClientMethod = $abstractGrantReflection->getMethod('validateClient');
104-
$validateClientMethod->setAccessible(true);
105104

106105
$validateClientMethod->invoke($grantMock, $serverRequest);
107106
}

tests/Grant/AbstractGrantTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public function testHttpBasicWithPassword(): void
4040

4141
$serverRequest = (new ServerRequest())->withHeader('Authorization', 'Basic ' . base64_encode('Open:Sesame'));
4242
$basicAuthMethod = $abstractGrantReflection->getMethod('getBasicAuthCredentials');
43-
$basicAuthMethod->setAccessible(true);
4443

4544
self::assertSame(['Open', 'Sesame'], $basicAuthMethod->invoke($grantMock, $serverRequest));
4645
}
@@ -54,7 +53,6 @@ public function testHttpBasicNoPassword(): void
5453

5554
$serverRequest = (new ServerRequest())->withHeader('Authorization', 'Basic ' . base64_encode('Open:'));
5655
$basicAuthMethod = $abstractGrantReflection->getMethod('getBasicAuthCredentials');
57-
$basicAuthMethod->setAccessible(true);
5856

5957
self::assertSame(['Open', ''], $basicAuthMethod->invoke($grantMock, $serverRequest));
6058
}
@@ -68,7 +66,6 @@ public function testHttpBasicNotBasic(): void
6866

6967
$serverRequest = (new ServerRequest())->withHeader('Authorization', 'Foo ' . base64_encode('Open:Sesame'));
7068
$basicAuthMethod = $abstractGrantReflection->getMethod('getBasicAuthCredentials');
71-
$basicAuthMethod->setAccessible(true);
7269

7370
self::assertSame([null, null], $basicAuthMethod->invoke($grantMock, $serverRequest));
7471
}
@@ -82,7 +79,6 @@ public function testHttpBasicCaseInsensitive(): void
8279

8380
$serverRequest = (new ServerRequest())->withHeader('Authorization', 'bAsIc ' . base64_encode('Open:Sesame'));
8481
$basicAuthMethod = $abstractGrantReflection->getMethod('getBasicAuthCredentials');
85-
$basicAuthMethod->setAccessible(true);
8682

8783
self::assertSame(['Open', 'Sesame'], $basicAuthMethod->invoke($grantMock, $serverRequest));
8884
}
@@ -96,7 +92,6 @@ public function testHttpBasicNotBase64(): void
9692

9793
$serverRequest = (new ServerRequest())->withHeader('Authorization', 'Basic ||');
9894
$basicAuthMethod = $abstractGrantReflection->getMethod('getBasicAuthCredentials');
99-
$basicAuthMethod->setAccessible(true);
10095

10196
self::assertSame([null, null], $basicAuthMethod->invoke($grantMock, $serverRequest));
10297
}
@@ -110,7 +105,6 @@ public function testHttpBasicNoColon(): void
110105

111106
$serverRequest = (new ServerRequest())->withHeader('Authorization', 'Basic ' . base64_encode('OpenSesame'));
112107
$basicAuthMethod = $abstractGrantReflection->getMethod('getBasicAuthCredentials');
113-
$basicAuthMethod->setAccessible(true);
114108

115109
self::assertSame([null, null], $basicAuthMethod->invoke($grantMock, $serverRequest));
116110
}
@@ -141,7 +135,6 @@ public function testGetClientCredentialsClientSecretNotAString(): void
141135
]
142136
);
143137
$getClientCredentialsMethod = $abstractGrantReflection->getMethod('getClientCredentials');
144-
$getClientCredentialsMethod->setAccessible(true);
145138

146139
$this->expectException(OAuthServerException::class);
147140

@@ -170,7 +163,6 @@ public function testValidateClientPublic(): void
170163
]);
171164

172165
$validateClientMethod = $abstractGrantReflection->getMethod('validateClient');
173-
$validateClientMethod->setAccessible(true);
174166

175167
$result = $validateClientMethod->invoke($grantMock, $serverRequest);
176168
self::assertEquals($client, $result);
@@ -200,7 +192,6 @@ public function testValidateClientConfidential(): void
200192
]);
201193

202194
$validateClientMethod = $abstractGrantReflection->getMethod('validateClient');
203-
$validateClientMethod->setAccessible(true);
204195

205196
$result = $validateClientMethod->invoke($grantMock, $serverRequest, true, true);
206197
self::assertEquals($client, $result);
@@ -221,7 +212,6 @@ public function testValidateClientMissingClientId(): void
221212

222213
$serverRequest = new ServerRequest();
223214
$validateClientMethod = $abstractGrantReflection->getMethod('validateClient');
224-
$validateClientMethod->setAccessible(true);
225215

226216
$this->expectException(OAuthServerException::class);
227217

@@ -245,7 +235,6 @@ public function testValidateClientMissingClientSecret(): void
245235
]);
246236

247237
$validateClientMethod = $abstractGrantReflection->getMethod('validateClient');
248-
$validateClientMethod->setAccessible(true);
249238

250239
$this->expectException(OAuthServerException::class);
251240

@@ -270,7 +259,6 @@ public function testValidateClientInvalidClientSecret(): void
270259
]);
271260

272261
$validateClientMethod = $abstractGrantReflection->getMethod('validateClient');
273-
$validateClientMethod->setAccessible(true);
274262

275263
$this->expectException(OAuthServerException::class);
276264

@@ -295,7 +283,6 @@ public function testValidateClientBadClient(): void
295283
]);
296284

297285
$validateClientMethod = $abstractGrantReflection->getMethod('validateClient');
298-
$validateClientMethod->setAccessible(true);
299286

300287
$this->expectException(OAuthServerException::class);
301288

@@ -333,7 +320,6 @@ public function testIssueRefreshToken(): void
333320

334321
$abstractGrantReflection = new ReflectionClass($grantMock);
335322
$issueRefreshTokenMethod = $abstractGrantReflection->getMethod('issueRefreshToken');
336-
$issueRefreshTokenMethod->setAccessible(true);
337323

338324
$accessToken = new AccessTokenEntity();
339325
$accessToken->setClient(new ClientEntity());
@@ -360,7 +346,6 @@ public function testIssueNullRefreshToken(): void
360346

361347
$abstractGrantReflection = new ReflectionClass($grantMock);
362348
$issueRefreshTokenMethod = $abstractGrantReflection->getMethod('issueRefreshToken');
363-
$issueRefreshTokenMethod->setAccessible(true);
364349

365350
$accessToken = new AccessTokenEntity();
366351
$accessToken->setClient(new ClientEntity());
@@ -387,7 +372,6 @@ public function testIssueNullRefreshTokenUnauthorizedClient(): void
387372

388373
$abstractGrantReflection = new ReflectionClass($grantMock);
389374
$issueRefreshTokenMethod = $abstractGrantReflection->getMethod('issueRefreshToken');
390-
$issueRefreshTokenMethod->setAccessible(true);
391375

392376
$accessToken = new AccessTokenEntity();
393377
$accessToken->setClient($client);
@@ -408,7 +392,6 @@ public function testIssueAccessToken(): void
408392

409393
$abstractGrantReflection = new ReflectionClass($grantMock);
410394
$issueAccessTokenMethod = $abstractGrantReflection->getMethod('issueAccessToken');
411-
$issueAccessTokenMethod->setAccessible(true);
412395

413396
/** @var AccessTokenEntityInterface $accessToken */
414397
$accessToken = $issueAccessTokenMethod->invoke(
@@ -434,7 +417,6 @@ public function testIssueAuthCode(): void
434417

435418
$abstractGrantReflection = new ReflectionClass($grantMock);
436419
$issueAuthCodeMethod = $abstractGrantReflection->getMethod('issueAuthCode');
437-
$issueAuthCodeMethod->setAccessible(true);
438420

439421
$scope = new ScopeEntity();
440422
$scope->setIdentifier('scopeId');
@@ -460,7 +442,6 @@ public function testGetCookieParameter(): void
460442

461443
$abstractGrantReflection = new ReflectionClass($grantMock);
462444
$method = $abstractGrantReflection->getMethod('getCookieParameter');
463-
$method->setAccessible(true);
464445

465446
$serverRequest = (new ServerRequest())->withCookieParams([
466447
'foo' => 'bar',
@@ -478,7 +459,6 @@ public function testGetQueryStringParameter(): void
478459

479460
$abstractGrantReflection = new ReflectionClass($grantMock);
480461
$method = $abstractGrantReflection->getMethod('getQueryStringParameter');
481-
$method->setAccessible(true);
482462

483463
$serverRequest = (new ServerRequest())->withQueryParams([
484464
'foo' => 'bar',
@@ -525,7 +505,6 @@ public function testGenerateUniqueIdentifier(): void
525505

526506
$abstractGrantReflection = new ReflectionClass($grantMock);
527507
$method = $abstractGrantReflection->getMethod('generateUniqueIdentifier');
528-
$method->setAccessible(true);
529508

530509
self::assertIsString($method->invoke($grantMock));
531510
}
@@ -580,7 +559,6 @@ public function testUnauthorizedClient(): void
580559
$abstractGrantReflection = new ReflectionClass($grantMock);
581560

582561
$getClientEntityOrFailMethod = $abstractGrantReflection->getMethod('getClientEntityOrFail');
583-
$getClientEntityOrFailMethod->setAccessible(true);
584562

585563
$this->expectException(OAuthServerException::class);
586564

0 commit comments

Comments
 (0)