Permalink
Browse files

Undo basic auth workaround for Curl adapter for HTTP client + added t…

…ests for authentication
  • Loading branch information...
1 parent 78a70ad commit f40605463679ecc8befad6673be2638c518e7a6d Denis Arh committed Apr 21, 2012
Showing with 23 additions and 1 deletion.
  1. +23 −1 tests/Zend/Http/Client/CurlTest.php
@@ -300,7 +300,7 @@ public function testGetCurlHandle()
$this->assertTrue(is_resource($adapter->getHandle()));
}
-
+
/**
* @group ZF-9857
*/
@@ -313,4 +313,26 @@ public function testHeadRequest()
$this->client->send();
$this->assertEquals('', $this->client->getResponse()->getBody());
}
+
+ public function testAuthorizeHeader()
+ {
+ // We just need someone to talk to
+ $this->client->setUri($this->baseuri. 'testHttpAuth.php');
+ $adapter = new Adapter\Curl();
+ $this->client->setAdapter($adapter);
+
+ $uid = 'alice';
+ $pwd = 'secret';
+
+ $hash = base64_encode($uid . ':' . $pwd);
+ $header = 'Authorization: Basic ' . $hash;
+
+ $this->client->setAuth($uid, $pwd);
+ $res = $this->client->send();
+
+ $curlInfo = curl_getinfo($adapter->getHandle());
+ $this->assertArrayHasKey('request_header', $curlInfo, 'Expecting request_header in curl_getinfo() return value');
+
+ $this->assertContains($header, $curlInfo['request_header'], 'Expecting valid basic authorization header');
+ }
}

0 comments on commit f406054

Please sign in to comment.