/
AuthFactoryTest.php
100 lines (83 loc) · 2.97 KB
/
AuthFactoryTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
namespace Aura\Auth;
use PDO;
use Aura\Auth\Session\Session;
use Aura\Auth\Session\Segment;
use Aura\Auth\Verifier\FakeVerifier;
class AuthFactoryTest extends \PHPUnit_Framework_TestCase
{
protected $factory;
protected function setUp()
{
$this->factory = new AuthFactory($_COOKIE);
}
public function testNewAuth()
{
$auth = $this->factory->newInstance(array());
$this->assertInstanceOf('Aura\Auth\Auth', $auth);
}
public function testNewAuthWithSessionAndSegment()
{
$auth = $this->factory->newInstance(array(), new Session(array()), new Segment);
$this->assertInstanceOf('Aura\Auth\Auth', $auth);
}
public function testNewPdoAdapter_passwordVerifier()
{
$pdo = new PDO('sqlite::memory:');
$adapter = $this->factory->newPdoAdapter(
$pdo,
1,
array('username', 'password'),
'accounts'
);
$this->assertInstanceOf('Aura\Auth\Adapter\PdoAdapter', $adapter);
$verifier = $adapter->getVerifier();
$this->assertInstanceOf('Aura\Auth\Verifier\PasswordVerifier',$verifier);
}
public function testNewPdoAdapter_customVerifier()
{
$pdo = new PDO('sqlite::memory:');
$adapter = $this->factory->newPdoAdapter(
$pdo,
new FakeVerifier,
array('username', 'password'),
'accounts'
);
$this->assertInstanceOf('Aura\Auth\Adapter\PdoAdapter', $adapter);
$verifier = $adapter->getVerifier();
$this->assertInstanceOf('Aura\Auth\Verifier\FakeVerifier', $verifier);
}
public function testNewHtpasswdAdapter()
{
$file = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'fake.htpasswd';
$adapter = $this->factory->newHtpasswdAdapter($file);
$this->assertInstanceOf('Aura\Auth\Adapter\HtpasswdAdapter', $adapter);
$verifier = $adapter->getVerifier();
$this->assertInstanceOf('Aura\Auth\Verifier\HtpasswdVerifier', $verifier);
}
public function testNewImapAdapter()
{
$adapter = $this->factory->newImapAdapter('imap.example.com', '{mbox}');
$this->assertInstanceOf('Aura\Auth\Adapter\ImapAdapter', $adapter);
}
public function testNewLdapAdapter()
{
$adapter = $this->factory->newLdapAdapter('ldap.example.com', 'ou=Org');
$this->assertInstanceOf('Aura\Auth\Adapter\LdapAdapter', $adapter);
}
public function testNewLoginService()
{
$service = $this->factory->newLoginService();
$this->assertInstanceOf('Aura\Auth\Service\LoginService', $service);
}
public function testNewLogoutService()
{
$service = $this->factory->newLogoutService();
$this->assertInstanceOf('Aura\Auth\Service\LogoutService', $service);
}
public function testNewResumeService()
{
$service = $this->factory->newResumeService();
$this->assertInstanceOf('Aura\Auth\Service\ResumeService', $service);
}
}