Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Adjust tests
Signed-off-by: Lukas Reschke <[email protected]>
  • Loading branch information
LukasReschke committed Sep 6, 2021
commit 6337bb3f59e7e47e20d634bd9b92e6e4b14cfe1c
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public function testGetAttempts() {
'1',
'2',
'87',
'123',
'123',
'124',
'223',
'223',
'224',
]));

$this->assertSame(3, $this->memoryCache->getAttempts('Method', 'User'));
Expand All @@ -106,7 +106,7 @@ public function testRegisterAttemptWithNoAttemptsBefore() {
->method('set')
->with(
'eea460b8d756885099c7f0a4c083bf6a745069ee4a301984e726df58fd4510bffa2dac4b7fd5d835726a6753ffa8343ba31c7e902bbef78fc68c2e743667cb4b',
json_encode(['123'])
json_encode(['223'])
);

$this->memoryCache->registerAttempt('Method', 'User', 100);
Expand All @@ -116,7 +116,7 @@ public function testRegisterAttempt() {
$this->timeFactory
->expects($this->once())
->method('getTime')
->willReturn(129);
->willReturn(86);

$this->cache
->expects($this->once())
Expand All @@ -140,7 +140,7 @@ public function testRegisterAttempt() {
'123',
'123',
'124',
'129',
'186',
])
);

Expand Down
16 changes: 6 additions & 10 deletions tests/lib/Security/RateLimiting/LimiterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public function testRegisterAnonRequestExceeded() {
->method('getAttempts')
->with(
'MyIdentifier',
'4664f0d9c88dcb7552be47b37bb52ce35977b2e60e1ac13757cf625f31f87050a41f3da064887fa87d49fd042e4c8eb20de8f10464877d3959677ab011b73a47',
100
'4664f0d9c88dcb7552be47b37bb52ce35977b2e60e1ac13757cf625f31f87050a41f3da064887fa87d49fd042e4c8eb20de8f10464877d3959677ab011b73a47'
)
->willReturn(101);

Expand All @@ -69,8 +68,7 @@ public function testRegisterAnonRequestSuccess() {
->method('getAttempts')
->with(
'MyIdentifier',
'4664f0d9c88dcb7552be47b37bb52ce35977b2e60e1ac13757cf625f31f87050a41f3da064887fa87d49fd042e4c8eb20de8f10464877d3959677ab011b73a47',
100
'4664f0d9c88dcb7552be47b37bb52ce35977b2e60e1ac13757cf625f31f87050a41f3da064887fa87d49fd042e4c8eb20de8f10464877d3959677ab011b73a47'
)
->willReturn(99);
$this->backend
Expand All @@ -79,7 +77,7 @@ public function testRegisterAnonRequestSuccess() {
->with(
'MyIdentifier',
'4664f0d9c88dcb7552be47b37bb52ce35977b2e60e1ac13757cf625f31f87050a41f3da064887fa87d49fd042e4c8eb20de8f10464877d3959677ab011b73a47',
2000
100
);

$this->limiter->registerAnonRequest('MyIdentifier', 100, 100, '127.0.0.1');
Expand All @@ -101,8 +99,7 @@ public function testRegisterUserRequestExceeded() {
->method('getAttempts')
->with(
'MyIdentifier',
'ddb2ec50fa973fd49ecf3d816f677c8095143e944ad10485f30fb3dac85c13a346dace4dae2d0a15af91867320957bfd38a43d9eefbb74fe6919e15119b6d805',
100
'ddb2ec50fa973fd49ecf3d816f677c8095143e944ad10485f30fb3dac85c13a346dace4dae2d0a15af91867320957bfd38a43d9eefbb74fe6919e15119b6d805'
)
->willReturn(101);

Expand All @@ -122,8 +119,7 @@ public function testRegisterUserRequestSuccess() {
->method('getAttempts')
->with(
'MyIdentifier',
'ddb2ec50fa973fd49ecf3d816f677c8095143e944ad10485f30fb3dac85c13a346dace4dae2d0a15af91867320957bfd38a43d9eefbb74fe6919e15119b6d805',
100
'ddb2ec50fa973fd49ecf3d816f677c8095143e944ad10485f30fb3dac85c13a346dace4dae2d0a15af91867320957bfd38a43d9eefbb74fe6919e15119b6d805'
)
->willReturn(99);
$this->backend
Expand All @@ -132,7 +128,7 @@ public function testRegisterUserRequestSuccess() {
->with(
'MyIdentifier',
'ddb2ec50fa973fd49ecf3d816f677c8095143e944ad10485f30fb3dac85c13a346dace4dae2d0a15af91867320957bfd38a43d9eefbb74fe6919e15119b6d805',
2000
100
);

$this->limiter->registerUserRequest('MyIdentifier', 100, 100, $user);
Expand Down