Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy remember-me value when renewing a session token #2353

Merged
merged 1 commit into from
Nov 28, 2016
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
1 change: 1 addition & 0 deletions lib/private/Authentication/Token/DefaultTokenProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public function renewSessionToken($oldSessionId, $sessionId) {
$newToken->setName($token->getName());
$newToken->setToken($this->hashToken($sessionId));
$newToken->setType(IToken::TEMPORARY_TOKEN);
$newToken->setRemember($token->getRemember());
$newToken->setLastActivity($this->time->getTime());
$this->mapper->insert($newToken);
}
Expand Down
12 changes: 11 additions & 1 deletion tests/lib/Authentication/Token/DefaultTokenProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ public function testRenewSessionTokenWithoutPassword() {
->expects($this->at(3))
->method('getName')
->willReturn('MyTokenName');
$token
->expects($this->at(3))
->method('getRememberMe')
->willReturn(IToken::DO_NOT_REMEMBER);
$this->config
->expects($this->exactly(2))
->method('getSystemValue')
Expand All @@ -308,6 +312,7 @@ public function testRenewSessionTokenWithoutPassword() {
$newToken->setName('MyTokenName');
$newToken->setToken(hash('sha512', 'newId' . 'MyInstanceSecret'));
$newToken->setType(IToken::TEMPORARY_TOKEN);
$newToken->setRemember(IToken::DO_NOT_REMEMBER);
$newToken->setLastActivity(1313131);
$this->mapper
->expects($this->at(1))
Expand Down Expand Up @@ -342,6 +347,10 @@ public function testRenewSessionTokenWithPassword() {
->expects($this->at(4))
->method('getName')
->willReturn('MyTokenName');
$token
->expects($this->at(3))
->method('getRememberMe')
->willReturn(IToken::REMEMBER);
$this->crypto
->expects($this->any(0))
->method('decrypt')
Expand All @@ -368,12 +377,13 @@ public function testRenewSessionTokenWithPassword() {
$newToken->setName('MyTokenName');
$newToken->setToken(hash('sha512', 'newId' . 'MyInstanceSecret'));
$newToken->setType(IToken::TEMPORARY_TOKEN);
$newToken->setRemember(IToken::REMEMBER);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, the test method also passes if I omit this line. I thought the line ->with($this->equalTo($newToken)) below would assert that those objects are equal. Apparently it doesn't really care, or at least with my version of phpunit locally.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is because the object is the same, but the content is not mandatorily the same. So it's not a in-depth comparison, but only a comparison of the "pointers" to an object.

$newToken->setLastActivity(1313131);
$newToken->setPassword('EncryptedPassword');
$this->mapper
->expects($this->at(1))
->method('insert')
->with($newToken);
->with($this->equalTo($newToken));

$this->tokenProvider->renewSessionToken('oldId', 'newId');
}
Expand Down