2010-11-09 23:03:43 -02:00
|
|
|
<?php
|
|
|
|
/**
|
2011-10-10 23:18:48 +02:00
|
|
|
* BasicAuthenticationTest file
|
2010-11-09 23:03:43 -02:00
|
|
|
*
|
2012-04-26 19:49:18 -07:00
|
|
|
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
2013-02-08 20:59:49 +09:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2010-11-09 23:03:43 -02:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
2013-02-08 21:22:51 +09:00
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
2010-11-09 23:03:43 -02:00
|
|
|
* Redistributions of files must retain the above copyright notice
|
|
|
|
*
|
2013-02-08 20:59:49 +09:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2012-04-26 19:49:18 -07:00
|
|
|
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
|
2011-07-26 01:46:14 -04:30
|
|
|
* @package Cake.Test.Case.Network.Http
|
2010-11-09 23:03:43 -02:00
|
|
|
* @since CakePHP(tm) v 2.0.0
|
2013-05-31 00:11:14 +02:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
2010-11-09 23:03:43 -02:00
|
|
|
*/
|
|
|
|
|
2011-02-22 00:06:11 -04:30
|
|
|
App::uses('HttpSocket', 'Network/Http');
|
|
|
|
App::uses('BasicAuthentication', 'Network/Http');
|
2010-11-09 23:03:43 -02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* BasicMethodTest class
|
|
|
|
*
|
2011-07-26 01:46:14 -04:30
|
|
|
* @package Cake.Test.Case.Network.Http
|
2010-11-09 23:03:43 -02:00
|
|
|
*/
|
2011-09-12 23:00:35 -04:00
|
|
|
class BasicAuthenticationTest extends CakeTestCase {
|
2010-11-09 23:03:43 -02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* testAuthentication method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testAuthentication() {
|
|
|
|
$http = new HttpSocket();
|
2010-12-03 00:46:11 -02:00
|
|
|
$auth = array(
|
2010-11-09 23:03:43 -02:00
|
|
|
'method' => 'Basic',
|
|
|
|
'user' => 'mark',
|
|
|
|
'pass' => 'secret'
|
|
|
|
);
|
|
|
|
|
2010-12-03 00:46:11 -02:00
|
|
|
BasicAuthentication::authentication($http, $auth);
|
2012-03-22 23:37:12 -07:00
|
|
|
$this->assertEquals('Basic bWFyazpzZWNyZXQ=', $http->request['header']['Authorization']);
|
2010-11-09 23:03:43 -02:00
|
|
|
}
|
|
|
|
|
2010-12-01 14:00:10 -02:00
|
|
|
/**
|
|
|
|
* testProxyAuthentication method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testProxyAuthentication() {
|
|
|
|
$http = new HttpSocket();
|
2010-12-15 01:54:37 -02:00
|
|
|
$proxy = array(
|
2010-12-01 14:00:10 -02:00
|
|
|
'method' => 'Basic',
|
|
|
|
'user' => 'mark',
|
|
|
|
'pass' => 'secret'
|
|
|
|
);
|
|
|
|
|
2010-12-15 01:54:37 -02:00
|
|
|
BasicAuthentication::proxyAuthentication($http, $proxy);
|
2012-03-22 23:37:12 -07:00
|
|
|
$this->assertEquals('Basic bWFyazpzZWNyZXQ=', $http->request['header']['Proxy-Authorization']);
|
2010-12-01 14:00:10 -02:00
|
|
|
}
|
|
|
|
|
2011-09-12 23:00:35 -04:00
|
|
|
}
|