/** * Test authentication * * @return void */ public function testAuth() { $socket = new MockHttpSocket(); $socket->get('http://*****:*****@example.com/test'); $this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); $socket->configAuth(false); $socket->get('http://example.com/test'); $this->assertFalse(strpos($socket->request['header'], 'Authorization:')); $socket->configAuth('Test', 'mark', 'passwd'); $socket->get('http://example.com/test'); $this->assertTrue(strpos($socket->request['header'], 'Authorization: Test mark.passwd') !== false); $socket->configAuth(false); $socket->request(array('method' => 'GET', 'uri' => 'http://example.com/test', 'auth' => array('method' => 'Basic', 'user' => 'joel', 'pass' => 'hunter2'))); $this->assertEquals($socket->request['auth'], array('Basic' => array('user' => 'joel', 'pass' => 'hunter2'))); $this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic am9lbDpodW50ZXIy') !== false); }
/** * Test authentication * * @return void */ public function testAuth() { $socket = new MockHttpSocket(); $socket->get('http://*****:*****@example.com/test'); $this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); $socket->configAuth(false); $socket->get('http://example.com/test'); $this->assertFalse(strpos($socket->request['header'], 'Authorization:')); $socket->configAuth('Test', 'mark', 'passwd'); $socket->get('http://example.com/test'); $this->assertTrue(strpos($socket->request['header'], 'Authorization: Test mark.passwd') !== false); }