Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Undo basic auth workaround for Curl adapter for HTTP client + added t…
Browse files Browse the repository at this point in the history
…ests for authentication
  • Loading branch information
Denis Arh committed Apr 21, 2012
1 parent 78a70ad commit f406054
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/Zend/Http/Client/CurlTest.php
Expand Up @@ -300,7 +300,7 @@ public function testGetCurlHandle()

$this->assertTrue(is_resource($adapter->getHandle()));
}

/**
* @group ZF-9857
*/
Expand All @@ -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.