Skip to content

Commit

Permalink
Extend test to verify scope
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Jan 12, 2020
1 parent 09a9552 commit a2c6747
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/test/php/web/auth/oauth/unittest/OAuth2FlowTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public function can_create() {
new OAuth2Flow(self::AUTH, self::TOKENS, [self::ID, self::SECRET]);
}

#[@test]
public function redirects_to_auth() {
$fixture= new OAuth2Flow(self::AUTH, self::TOKENS, [self::ID, self::SECRET]);
#[@test, @values([[['user']], [['user', 'openid']]])]
public function redirects_to_auth_and_passes_scope($scope) {
$fixture= new OAuth2Flow(self::AUTH, self::TOKENS, [self::ID, self::SECRET], $scope);

$req= new Request(new TestInput('GET', '/'));
$res= new Response(new TestOutput());
Expand All @@ -32,10 +32,11 @@ public function redirects_to_auth() {
$fixture->authenticate($req, $res, $session);

$url= sprintf(
'%s?response_type=code&client_id=%s&redirect_uri=%s&scope=user&state=%s',
'%s?response_type=code&client_id=%s&redirect_uri=%s&scope=%s&state=%s',
self::AUTH,
self::ID,
urlencode('http://localhost/'),
implode('+', $scope),
$session->value('oauth.state')
);
$this->assertEquals($url, $res->headers()['Location']);
Expand Down

0 comments on commit a2c6747

Please sign in to comment.