Skip to content

Commit

Permalink
#4 blocked counters need unit tests
Browse files Browse the repository at this point in the history
- FunctionalTest ::testCheckAuthenticationWithUserReleasedOnIpAddressAndCookie
    made compatible with PHP 5.3
  • Loading branch information
metaclass-nl committed Aug 15, 2016
1 parent 65c3d2e commit eeb5c89
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
4 changes: 4 additions & 0 deletions doc/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,8 @@ AuthenticationGuardBundle Issue 9: cross framework library refactoring
#5 api docs for statistics functions
- removed "that not have been released"
-------------------------------
#4 blocked counters need unit tests
- FunctionalTest ::testCheckAuthenticationWithUserReleasedOnIpAddressAndCookie
made compatible with PHP 5.3
------------------------------------
#2DO: tag v0.3 (when finished solving issues)
26 changes: 14 additions & 12 deletions src/Metaclass/TresholdsGovernor/Tests/Service/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,23 +322,25 @@ function testCheckAuthenticationWithUserReleasedOnIpAddressAndCookie()
$counts = $this->statisticsManager->countsByAddressBetween('192.168.255.255', $from, $until);
$this->assertEquals(2, count($counts), '192.168.255.255 counter2');

$testuser1 = array_filter($counts, function($e) {
$countsTestuser1 = array_filter($counts, function($e) {
return $e['username'] == 'testuser1';
});
$this->assertEquals(1, count($testuser1) , '192.168.255.255 testuser1');
$this->assertEquals(0, current($testuser1)['ipAddressBlocked'], '192.168.255.255 ipAddressBlocked');
$this->assertEquals(0, current($testuser1)['usernameBlocked'], '192.168.255.255 usernameBlocked');
$this->assertEquals(1, current($testuser1)['usernameBlockedForIpAddress'], '192.168.255.255 usernameBlockedForIpAddress');
$this->assertEquals(0, current($testuser1)['usernameBlockedForCookie'], '192.168.255.255 usernameBlockedForCookie');
$this->assertEquals(1, count($countsTestuser1) , '192.168.255.255 testuser1');
$testuser1 = current($countsTestuser1);
$this->assertEquals(0, $testuser1['ipAddressBlocked'], '192.168.255.255 ipAddressBlocked');
$this->assertEquals(0, $testuser1['usernameBlocked'], '192.168.255.255 usernameBlocked');
$this->assertEquals(1, $testuser1['usernameBlockedForIpAddress'], '192.168.255.255 usernameBlockedForIpAddress');
$this->assertEquals(0, $testuser1['usernameBlockedForCookie'], '192.168.255.255 usernameBlockedForCookie');

$testuser2 = array_filter($counts, function($e) {
$countsTestuser2 = array_filter($counts, function($e) {
return $e['username'] == 'testuser2';
});
$this->assertEquals(1, count($testuser2) , '192.168.255.255 testuser1');
$this->assertEquals(1, current($testuser2)['ipAddressBlocked'], '192.168.255.255 ipAddressBlocked');
$this->assertEquals(0, current($testuser2)['usernameBlocked'], '192.168.255.255 usernameBlocked');
$this->assertEquals(0, current($testuser2)['usernameBlockedForIpAddress'], '192.168.255.255 usernameBlockedForIpAddress');
$this->assertEquals(0, current($testuser2)['usernameBlockedForCookie'], '192.168.255.255 usernameBlockedForCookie');
$this->assertEquals(1, count($countsTestuser2) , '192.168.255.255 testuser2');
$testuser2 = current($countsTestuser2);
$this->assertEquals(1, $testuser2['ipAddressBlocked'], '192.168.255.255 ipAddressBlocked');
$this->assertEquals(0, $testuser2['usernameBlocked'], '192.168.255.255 usernameBlocked');
$this->assertEquals(0, $testuser2['usernameBlockedForIpAddress'], '192.168.255.255 usernameBlockedForIpAddress');
$this->assertEquals(0, $testuser2['usernameBlockedForCookie'], '192.168.255.255 usernameBlockedForCookie');
}

function testBlockingDurations()
Expand Down

0 comments on commit eeb5c89

Please sign in to comment.