Skip to content

Commit dc75520

Browse files
committed
tests for bshaffer#336 so this doesn't happen again
1 parent 2e7d1d2 commit dc75520

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/OAuth2/Storage/AuthorizationCodeTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,31 @@ public function testSetAuthorizationCode(AuthorizationCodeInterface $storage)
7171
$this->assertEquals($code['redirect_uri'], 'http://example.org');
7272
$this->assertEquals($code['expires'], $expires);
7373
}
74+
75+
/** @dataProvider provideStorage */
76+
public function testExpireAccessToken(AccessTokenInterface $storage)
77+
{
78+
if ($storage instanceof NullStorage) {
79+
$this->markTestSkipped('Skipped Storage: ' . $storage->getMessage());
80+
81+
return;
82+
}
83+
84+
// create a valid code
85+
$expires = time() + 20;
86+
$success = $storage->setAuthorizationCode('code-to-expire', 'client ID', 'SOMEUSERID', 'http://example.com', time() + 20);
87+
$this->assertTrue($success);
88+
89+
// verify the new code exists
90+
$code = $storage->getAuthorizationCode('code-to-expire');
91+
$this->assertNotNull($code);
92+
93+
$this->assertArrayHasKey('authorization_code', $code);
94+
$this->assertEquals($code['authorization_code'], 'code-to-expire');
95+
96+
// now expire the code and ensure it's no longer available
97+
$storage->expireAuthorizationCode('code-to-expire');
98+
$code = $storage->getAuthorizationCode('code-to-expire');
99+
$this->assertFalse($code);
100+
}
74101
}

0 commit comments

Comments
 (0)