File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,14 @@ public function hasBasicAuth()
133133 return isset ($ this ->password ) && isset ($ this ->username );
134134 }
135135
136+ /**
137+ * @return bool Is this request setup for digest auth?
138+ */
139+ public function hasDigestAuth ()
140+ {
141+ return isset ($ this ->password ) && isset ($ this ->username ) && $ this ->additional_curl_opts ['CURLOPT_HTTPAUTH ' ] = CURLAUTH_DIGEST ;
142+ }
143+
136144 /**
137145 * If the response is a 301 or 302 redirect, automatically
138146 * send off another request to that location
@@ -221,6 +229,24 @@ public function authenticateWithBasic($username, $password)
221229 return $ this ->basicAuth ($ username , $ password );
222230 }
223231
232+ /**
233+ * User Digest Auth.
234+ * @return Request this
235+ * @param string $username
236+ * @param string $password
237+ */
238+ public function digestAuth ($ username , $ password )
239+ {
240+ $ this ->addOnCurlOption (CURLOPT_HTTPAUTH , CURLAUTH_DIGEST );
241+ return $ this ->basicAuth ($ username , $ password );
242+ }
243+
244+ // @alias of digestAuth
245+ public function authenticateWithDigest ($ username , $ password )
246+ {
247+ return $ this ->digestAuth ($ username , $ password );
248+ }
249+
224250 /**
225251 * @return is this request setup for client side cert?
226252 */
Original file line number Diff line number Diff line change @@ -216,6 +216,19 @@ function testAuthSetup()
216216 $ this ->assertTrue ($ r ->hasBasicAuth ());
217217 }
218218
219+ function testDigestAuthSetup ()
220+ {
221+ $ username = 'nathan ' ;
222+ $ password = 'opensesame ' ;
223+
224+ $ r = Request::get ('http://example.com/ ' )
225+ ->authenticateWithDigest ($ username , $ password );
226+
227+ $ this ->assertEquals ($ username , $ r ->username );
228+ $ this ->assertEquals ($ password , $ r ->password );
229+ $ this ->assertTrue ($ r ->hasDigestAuth ());
230+ }
231+
219232 function testJsonResponseParse ()
220233 {
221234 $ req = Request::init ()->sendsAndExpects (Mime::JSON );
You can’t perform that action at this time.
0 commit comments