public function testRefreshToken()
 {
     $this->tokenGenerator->expects($this->once())->method('generateToken')->willReturn('MyNewToken');
     $this->storageInterface->expects($this->once())->method('setToken')->with('MyNewToken');
     $expected = new \OC\Security\CSRF\CsrfToken('MyNewToken');
     $this->assertEquals($expected, $this->csrfTokenManager->refreshToken());
 }
Пример #2
0
 public function testGenerateTokenWithDefault()
 {
     $this->random->expects($this->once())->method('generate')->with(32)->willReturn('12345678901234567890123456789012');
     $this->assertSame('12345678901234567890123456789012', $this->csrfTokenGenerator->generateToken(32));
 }
Пример #3
0
 /**
  * Invalidates any current token and sets a new one.
  *
  * @return CsrfToken
  */
 public function refreshToken()
 {
     $value = $this->tokenGenerator->generateToken();
     $this->sessionStorage->setToken($value);
     return new CsrfToken($value);
 }