|
12 | 12 | use GuzzleHttp\Psr7\Request;
|
13 | 13 | use GuzzleHttp\Psr7\Response;
|
14 | 14 | use Http\Mock\Client;
|
| 15 | +use Http\Promise\FulfilledPromise; |
15 | 16 | use PHPUnit\Framework\MockObject\MockObject;
|
16 | 17 | use PrivatePackagist\ApiClient\HttpClient\HttpPluginClientBuilder;
|
17 | 18 | use PrivatePackagist\OIDC\Identities\Token;
|
@@ -51,16 +52,18 @@ public function testTokenExchange(): void
|
51 | 52 | $this->httpClient->addResponse(new Response(200, [], json_encode(['audience' => 'test'])));
|
52 | 53 | $this->httpClient->addResponse(new Response(200, [], json_encode(['key' => 'key', 'secret' => 'secret'])));
|
53 | 54 |
|
54 |
| - $this->plugin->handleRequest($request, $this->next, $this->first); |
| 55 | + $this->plugin->handleRequest($request, function (Request $request) use (&$requestAfterPlugin) { |
| 56 | + $requestAfterPlugin = $request; |
| 57 | + |
| 58 | + return new FulfilledPromise($request); |
| 59 | + }, $this->first); |
55 | 60 |
|
56 | 61 | $requests = $this->httpClient->getRequests();
|
57 | 62 | $this->assertCount(2, $requests);
|
58 | 63 | $this->assertSame('/oidc/audience', (string) $requests[0]->getUri());
|
59 | 64 | $this->assertSame('/oidc/token-exchange/organization/acme/package', (string) $requests[1]->getUri());
|
60 |
| - |
61 |
| - // Verify that the signature is configured using the correct key |
62 |
| - $this->builder->getHttpClient()->get('/api/foo'); |
63 |
| - $this->assertStringContainsString('PACKAGIST-HMAC-SHA256 Key=key', $requests[2]->getHeader('Authorization')[0]); |
| 65 | + |
| 66 | + $this->assertStringContainsString('PACKAGIST-HMAC-SHA256 Key=key', $requestAfterPlugin->getHeader('Authorization')[0]); |
64 | 67 | }
|
65 | 68 |
|
66 | 69 | public function testNoTokenGenerated(): void
|
|
0 commit comments