|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the U2F Security bundle. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Michael Barbey <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Mbarbey\U2fSecurityBundle\Tests\Event\Authentication; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase; |
|
15
|
|
|
use Mbarbey\U2fSecurityBundle\Event\Authentication\U2fAuthenticationFailureEvent; |
|
16
|
|
|
use Mbarbey\U2fSecurityBundle\Model\User\U2fUser; |
|
17
|
|
|
|
|
18
|
|
|
class U2fAuthenticationFailureEventTest extends TestCase |
|
19
|
|
|
{ |
|
20
|
|
|
private $event; |
|
21
|
|
|
private $user; |
|
22
|
|
|
private $error; |
|
23
|
|
|
private $counter; |
|
24
|
|
|
|
|
25
|
|
|
public function setUp() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->user = $this->getMockForAbstractClass(U2fUser::class); |
|
28
|
|
|
$this->error = new \Exception(); |
|
29
|
|
|
$this->counter = rand(10, 100); |
|
30
|
|
|
|
|
31
|
|
|
$this->event = new U2fAuthenticationFailureEvent($this->user, $this->error, $this->counter); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testName() |
|
35
|
|
|
{ |
|
36
|
|
|
$name = 'u2f.authentication.failure'; |
|
37
|
|
|
|
|
38
|
|
|
$this->assertEquals(U2fAuthenticationFailureEvent::getName(), $name); |
|
39
|
|
|
$this->assertEquals($this->event->getName(), $name); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function testUser() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->assertEquals($this->event->getUser(), $this->user); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function testError() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->assertEquals($this->event->getError(), $this->error); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function testFailureCounter() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->assertEquals($this->event->getFailureCounter(), $this->counter); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|