Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Revocation of access token was fixed #44

Merged
merged 1 commit into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Repository/Pdo/AccessTokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function revokeAccessToken($tokenId)
$sth = $this->pdo->prepare(
'UPDATE oauth_access_tokens SET revoked=:revoked WHERE id = :tokenId'
);
$sth->bindValue(':revoked', 0);
$sth->bindValue(':revoked', 1);
$sth->bindParam(':tokenId', $tokenId);

$sth->execute();
Expand Down
19 changes: 19 additions & 0 deletions test/Repository/Pdo/AccessTokenRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@

class AccessTokenRepositoryTest extends TestCase
{
/**
* @var AccessTokenRepository
*/
private $repo;

public function setUp()
{
$this->pdo = $this->prophesize(PdoService::class);
Expand Down Expand Up @@ -125,4 +130,18 @@ public function testIsAccessTokenRevokedReturnsTrueWhenRowRevokedFlagIsTrue()

$this->assertTrue($this->repo->isAccessTokenRevoked('token_id'));
}

public function testRevokeAccessToken()
{
$statement = $this->prophesize(PDOStatement::class);
$statement->bindParam(':tokenId', 'token_id')->shouldBeCalled();
$statement->bindValue(':revoked', 1)->shouldBeCalled();
$statement->execute()->willReturn(null)->shouldBeCalled();

$this->pdo
->prepare(Argument::containingString('UPDATE oauth_access_tokens SET revoked=:revoked'))
->will([$statement, 'reveal']);

$this->repo->revokeAccessToken('token_id');
}
}