| 13532 |
anikendra |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* BasicAuthenticationTest file
|
|
|
4 |
*
|
|
|
5 |
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
|
|
6 |
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
|
7 |
*
|
|
|
8 |
* Licensed under The MIT License
|
|
|
9 |
* For full copyright and license information, please see the LICENSE.txt
|
|
|
10 |
* Redistributions of files must retain the above copyright notice
|
|
|
11 |
*
|
|
|
12 |
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
|
13 |
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
|
|
|
14 |
* @package Cake.Test.Case.Network.Http
|
|
|
15 |
* @since CakePHP(tm) v 2.0.0
|
|
|
16 |
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
|
|
17 |
*/
|
|
|
18 |
|
|
|
19 |
App::uses('HttpSocket', 'Network/Http');
|
|
|
20 |
App::uses('BasicAuthentication', 'Network/Http');
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* BasicMethodTest class
|
|
|
24 |
*
|
|
|
25 |
* @package Cake.Test.Case.Network.Http
|
|
|
26 |
*/
|
|
|
27 |
class BasicAuthenticationTest extends CakeTestCase {
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* testAuthentication method
|
|
|
31 |
*
|
|
|
32 |
* @return void
|
|
|
33 |
*/
|
|
|
34 |
public function testAuthentication() {
|
|
|
35 |
$http = new HttpSocket();
|
|
|
36 |
$auth = array(
|
|
|
37 |
'method' => 'Basic',
|
|
|
38 |
'user' => 'mark',
|
|
|
39 |
'pass' => 'secret'
|
|
|
40 |
);
|
|
|
41 |
|
|
|
42 |
BasicAuthentication::authentication($http, $auth);
|
|
|
43 |
$this->assertEquals('Basic bWFyazpzZWNyZXQ=', $http->request['header']['Authorization']);
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* testProxyAuthentication method
|
|
|
48 |
*
|
|
|
49 |
* @return void
|
|
|
50 |
*/
|
|
|
51 |
public function testProxyAuthentication() {
|
|
|
52 |
$http = new HttpSocket();
|
|
|
53 |
$proxy = array(
|
|
|
54 |
'method' => 'Basic',
|
|
|
55 |
'user' => 'mark',
|
|
|
56 |
'pass' => 'secret'
|
|
|
57 |
);
|
|
|
58 |
|
|
|
59 |
BasicAuthentication::proxyAuthentication($http, $proxy);
|
|
|
60 |
$this->assertEquals('Basic bWFyazpzZWNyZXQ=', $http->request['header']['Proxy-Authorization']);
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
}
|