|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* The MIT License (MIT) |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright (c) 2014-2017 Spomky-Labs |
|
9
|
|
|
* |
|
10
|
|
|
* This software may be modified and distributed under the terms |
|
11
|
|
|
* of the MIT license. See the LICENSE file for details. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace OAuth2Framework\Component\Server\Tests\Context; |
|
15
|
|
|
|
|
16
|
|
|
use Behat\Behat\Context\Context; |
|
17
|
|
|
use Behat\Behat\Hook\Scope\BeforeScenarioScope; |
|
18
|
|
|
|
|
19
|
|
|
final class HybridFlowContext implements Context |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @var ResponseContext |
|
23
|
|
|
*/ |
|
24
|
|
|
private $responseContext; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var ResponseTypeContext |
|
28
|
|
|
*/ |
|
29
|
|
|
private $responseTypeContext; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var ApplicationContext |
|
33
|
|
|
*/ |
|
34
|
|
|
private $applicationContext; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @BeforeScenario |
|
38
|
|
|
* |
|
39
|
|
|
* @param BeforeScenarioScope $scope |
|
40
|
|
|
*/ |
|
41
|
|
|
public function gatherContexts(BeforeScenarioScope $scope) |
|
42
|
|
|
{ |
|
43
|
|
|
$environment = $scope->getEnvironment(); |
|
44
|
|
|
|
|
45
|
|
|
$this->responseContext = $environment->getContext(ResponseContext::class); |
|
46
|
|
|
$this->applicationContext = $environment->getContext(ApplicationContext::class); |
|
47
|
|
|
$this->responseTypeContext = $environment->getContext(ResponseTypeContext::class); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @Given A client sends an authorization requests with the Authorization Code, the Id Token and the Token Response Types |
|
52
|
|
|
*/ |
|
53
|
|
|
public function aClientSendsAnAuthorizationRequestsWithTheAuthorizationCodeTheIdTokenAndTheTokenResponseTypes() |
|
54
|
|
|
{ |
|
55
|
|
|
$request = $this->applicationContext->getServerRequestFactory()->createServerRequest([]); |
|
56
|
|
|
$request = $request->withMethod('GET'); |
|
57
|
|
|
$request = $request->withQueryParams([ |
|
58
|
|
|
'client_id' => 'client1', |
|
59
|
|
|
'redirect_uri' => 'https://example.com/redirection/callback', |
|
60
|
|
|
'response_type' => 'code id_token token', |
|
61
|
|
|
'state' => '0123456789', |
|
62
|
|
|
'nonce' => 'ABCDEFGHIJ', |
|
63
|
|
|
'scope' => 'openid profile address email phone', |
|
64
|
|
|
]); |
|
65
|
|
|
|
|
66
|
|
|
$this->responseTypeContext->setAuthorizationRequest($request); |
|
67
|
|
|
$this->applicationContext->getApplication()->getAuthorizationEndpointPipe()->dispatch($request); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|