@@ -88,11 +88,10 @@ public function test_can_change_passwords()
8888
8989 public function test_set_options ()
9090 {
91- $ ldap = (new LdapFake ())
92- ->expect ([
93- LdapFake::operation ('setOption ' )->once ()->with (1 , 'value ' )->andReturnTrue (),
94- LdapFake::operation ('setOption ' )->once ()->with (2 , 'value ' )->andReturnTrue (),
95- ]);
91+ $ ldap = (new LdapFake ())->expect ([
92+ LdapFake::operation ('setOption ' )->once ()->with (1 , 'value ' )->andReturnTrue (),
93+ LdapFake::operation ('setOption ' )->once ()->with (2 , 'value ' )->andReturnTrue (),
94+ ]);
9695
9796 $ ldap ->setOptions ([1 => 'value ' , 2 => 'value ' ]);
9897 }
@@ -105,4 +104,50 @@ public function test_get_detailed_error_returns_null_when_error_number_is_zero()
105104
106105 $ this ->assertNull ($ ldap ->getDetailedError ());
107106 }
107+
108+ public function test_is_secure_after_binding_with_an_ssl_connection ()
109+ {
110+ $ ldap = (new LdapFake ())->expect ([
111+ LdapFake::operation ('bind ' )->once ()->andReturnResponse (),
112+ ]);
113+
114+ $ ldap ->ssl ();
115+
116+ $ this ->assertFalse ($ ldap ->isSecure ());
117+
118+ $ ldap ->bind ('foo ' , 'bar ' );
119+
120+ $ this ->assertTrue ($ ldap ->isSecure ());
121+ }
122+
123+ public function test_is_secure_after_starting_tls ()
124+ {
125+ $ ldap = (new LdapFake ())->expect ([
126+ LdapFake::operation ('startTLS ' )->once ()->andReturnTrue (),
127+ ]);
128+
129+ $ this ->assertFalse ($ ldap ->isSecure ());
130+
131+ $ ldap ->startTLS ();
132+
133+ $ this ->assertTrue ($ ldap ->isSecure ());
134+ }
135+
136+ public function test_is_secure_after_starting_tls_but_failing_bind ()
137+ {
138+ $ ldap = (new LdapFake ())->expect ([
139+ LdapFake::operation ('startTLS ' )->once ()->andReturnTrue (),
140+ LdapFake::operation ('bind ' )->once ()->andReturnResponse (1 ),
141+ ]);
142+
143+ $ this ->assertFalse ($ ldap ->isSecure ());
144+
145+ $ ldap ->startTLS ();
146+
147+ $ this ->assertTrue ($ ldap ->isSecure ());
148+
149+ $ ldap ->bind ('foo ' , 'bar ' );
150+
151+ $ this ->assertTrue ($ ldap ->isSecure ());
152+ }
108153}
0 commit comments