Skip to content
Permalink
Browse files

Renamed setAuthConfig to configAuth, and setProxyConfig to configProxy.

  • Loading branch information...
jrbasso committed Dec 13, 2010
1 parent d332f06 commit c20b5d70538638273d79edf2ae14c9d2ebbcb581
Showing with 8 additions and 8 deletions.
  1. +3 −3 cake/libs/http_socket.php
  2. +5 −5 cake/tests/cases/libs/http_socket.test.php
@@ -181,7 +181,7 @@ public function __construct($config = array()) {
* @param string $pass Password for authentication
* @return void
*/
public function setAuthConfig($method, $user = null, $pass = null) {
public function configAuth($method, $user = null, $pass = null) {
if (empty($method)) {
$this->_auth = array();
return;
@@ -203,7 +203,7 @@ public function setAuthConfig($method, $user = null, $pass = null) {
* @param string $pass Password to proxy authentication
* @return void
*/
public function setProxyConfig($host, $port = 3128, $method = null, $user = null, $pass = null) {
public function configProxy($host, $port = 3128, $method = null, $user = null, $pass = null) {
if (empty($host)) {
$this->_proxy = array();
return;
@@ -310,7 +310,7 @@ public function &request($request = array()) {
}
if (isset($this->request['uri']['user'], $this->request['uri']['pass'])) {
$this->setAuthConfig('Basic', $this->request['uri']['user'], $this->request['uri']['pass']);
$this->configAuth('Basic', $this->request['uri']['user'], $this->request['uri']['pass']);
}
$this->_setAuth();
$this->request['auth'] = $this->_auth;
@@ -715,7 +715,7 @@ public function testProxy() {
$this->Socket->expects($this->any())->method('connect')->will($this->returnValue(true));
$this->Socket->expects($this->any())->method('read')->will($this->returnValue(false));
$this->Socket->setProxyConfig('proxy.server', 123);
$this->Socket->configProxy('proxy.server', 123);
$expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n\r\n";
$this->Socket->request('http://www.cakephp.org/');
$this->assertEqual($this->Socket->request['raw'], $expected);
@@ -745,7 +745,7 @@ public function testProxy() {
$this->assertEqual($this->Socket->request['proxy'], $expected);
$expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nProxy-Authorization: Test mark.secret\r\n\r\n";
$this->Socket->setProxyConfig('proxy.server', 123, 'Test', 'mark', 'secret');
$this->Socket->configProxy('proxy.server', 123, 'Test', 'mark', 'secret');
$this->Socket->request('http://www.cakephp.org/');
$this->assertEqual($this->Socket->request['raw'], $expected);
$this->assertEqual($this->Socket->config['host'], 'proxy.server');
@@ -759,7 +759,7 @@ public function testProxy() {
);
$this->assertEqual($this->Socket->request['proxy'], $expected);
$this->Socket->setAuthConfig('Test', 'login', 'passwd');
$this->Socket->configAuth('Test', 'login', 'passwd');
$expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nProxy-Authorization: Test mark.secret\r\nAuthorization: Test login.passwd\r\n\r\n";
$this->Socket->request('http://www.cakephp.org/');
$this->assertEqual($this->Socket->request['raw'], $expected);
@@ -879,11 +879,11 @@ public function testAuth() {
$socket->get('http://mark:secret@example.com/test');
$this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false);
$socket->setAuthConfig(false);
$socket->configAuth(false);
$socket->get('http://example.com/test');
$this->assertFalse(strpos($socket->request['header'], 'Authorization:'));
$socket->setAuthConfig('Test', 'mark', 'passwd');
$socket->configAuth('Test', 'mark', 'passwd');
$socket->get('http://example.com/test');
$this->assertTrue(strpos($socket->request['header'], 'Authorization: Test mark.passwd') !== false);
}

0 comments on commit c20b5d7

Please sign in to comment.
You can’t perform that action at this time.