Skip to content

Commit 20348b0

Browse files
committed
Add test
1 parent 44cea8e commit 20348b0

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

tests/Unit/Auth/GuardTest.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function test_bind_does_not_rebind_with_configured_user()
5858

5959
$guard = new Guard($ldap, new DomainConfiguration());
6060

61-
$this->assertNull($guard->bind('user', 'pass'));
61+
$guard->bind('user', 'pass');
6262
}
6363

6464
public function test_bind_allows_null_username_and_password()
@@ -69,7 +69,7 @@ public function test_bind_allows_null_username_and_password()
6969

7070
$guard = new Guard($ldap, new DomainConfiguration());
7171

72-
$this->assertNull($guard->bind());
72+
$guard->bind();
7373
}
7474

7575
public function test_bind_always_throws_exception_on_invalid_credentials()
@@ -96,7 +96,7 @@ public function test_bind_as_administrator()
9696
'password' => 'bar',
9797
]));
9898

99-
$this->assertNull($guard->bindAsConfiguredUser());
99+
$guard->bindAsConfiguredUser();
100100
}
101101

102102
public function test_binding_events_are_fired_during_bind()
@@ -231,4 +231,25 @@ public function test_sasl_bind()
231231

232232
$this->assertTrue($ldap->isBound());
233233
}
234+
235+
public function test_tls_is_upgraded_once()
236+
{
237+
$ldap = (new LdapFake())->expect([
238+
LdapFake::operation('bind')->once()->with('admin', 'password')->andReturnResponse(),
239+
LdapFake::operation('startTLS')->once()->andReturnTrue(),
240+
LdapFake::operation('bind')->once()->with('foo', 'bar')->andReturnResponse(1),
241+
]);
242+
243+
$ldap->tls();
244+
245+
$this->assertFalse($ldap->isSecure());
246+
247+
$guard = new Guard($ldap, new DomainConfiguration([
248+
'username' => 'admin',
249+
'password' => 'password',
250+
]));
251+
252+
$this->assertFalse($guard->attempt('foo', 'bar'));
253+
$this->assertTrue($ldap->isSecure());
254+
}
234255
}

0 commit comments

Comments
 (0)