20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
45 protected function setUp()
47 $this->backendUserMock = $this->createMock(\
TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class);
48 $this->backendUserMock->user[
'uid'] = 1;
49 $this->registryMock = $this->createMock(Registry::class);
51 $this->backendUserMock,
54 throw new \Exception(
'Closure called', 1442592030);
64 $this->backendUserMock
65 ->expects($this->once())
66 ->method(
'getSessionData')
67 ->with(
'formProtectionSessionToken')
68 ->will($this->returnValue([]));
69 $this->subject->generateToken(
'foo');
77 $sessionToken =
'881ffea2159ac72182557b79dc0c723f5a8d20136f9fab56cdd4f8b3a1dbcfcd';
80 $formInstanceName =
'42';
82 $tokenId = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac(
83 $formName . $action . $formInstanceName . $sessionToken
86 $this->backendUserMock
87 ->expects($this->atLeastOnce())
88 ->method(
'getSessionData')
89 ->with(
'formProtectionSessionToken')
90 ->will($this->returnValue($sessionToken));
93 $this->subject->validateToken($tokenId, $formName, $action, $formInstanceName)
102 $this->expectException(\UnexpectedValueException::class);
103 $this->expectExceptionCode(1301827270);
105 $this->subject->setSessionTokenFromRegistry();
113 $this->backendUserMock
114 ->expects($this->once())
115 ->method(
'setAndSaveSessionData');
116 $this->subject->persistSessionToken();
124 $this->expectException(\Exception::class);
125 $this->expectExceptionCode(1442592030);
127 $this->subject->validateToken(
'foo',
'bar');