mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Changing authentication classes to use suffix Authentication instead of Method.
This commit is contained in:
parent
7e0d34903e
commit
3056fbf680
5 changed files with 18 additions and 18 deletions
|
@ -24,7 +24,7 @@
|
|||
* @package cake
|
||||
* @subpackage cake.cake.libs.http
|
||||
*/
|
||||
class BasicMethod {
|
||||
class BasicAuthentication {
|
||||
|
||||
/**
|
||||
* Authentication
|
|
@ -24,7 +24,7 @@
|
|||
* @package cake
|
||||
* @subpackage cake.cake.libs.http
|
||||
*/
|
||||
class DigestMethod {
|
||||
class DigestAuthentication {
|
||||
|
||||
/**
|
||||
* Authentication
|
|
@ -455,7 +455,7 @@ class HttpSocket extends CakeSocket {
|
|||
return;
|
||||
}
|
||||
}
|
||||
$authClass = Inflector::camelize($this->request['auth']['method']) . 'Method';
|
||||
$authClass = Inflector::camelize($this->request['auth']['method']) . 'Authentication';
|
||||
if (!App::import('Lib', 'http/' . $authClass)) {
|
||||
throw new Exception(__('Unknown authentication method.'));
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
|
||||
App::import('Core', 'HttpSocket');
|
||||
App::import('Lib', 'http/BasicMethod');
|
||||
App::import('Lib', 'http/BasicAuthentication');
|
||||
|
||||
/**
|
||||
* BasicMethodTest class
|
||||
|
@ -42,7 +42,7 @@ class BasicMethodTest extends CakeTestCase {
|
|||
'pass' => 'secret'
|
||||
);
|
||||
|
||||
BasicMethod::authentication($http);
|
||||
BasicAuthentication::authentication($http);
|
||||
$this->assertEqual($http->request['header']['Authorization'], 'Basic bWFyazpzZWNyZXQ=');
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* DigestMethodTest file
|
||||
* DigestAuthenticationTest file
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
|
||||
App::import('Core', 'HttpSocket');
|
||||
App::import('Lib', 'http/DigestMethod');
|
||||
App::import('Lib', 'http/DigestAuthentication');
|
||||
|
||||
class DigestHttpSocket extends HttpSocket {
|
||||
|
||||
|
@ -43,12 +43,12 @@ class DigestHttpSocket extends HttpSocket {
|
|||
}
|
||||
|
||||
/**
|
||||
* DigestMethodTest class
|
||||
* DigestAuthenticationTest class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.http
|
||||
*/
|
||||
class DigestMethodTest extends CakeTestCase {
|
||||
class DigestAuthenticationTest extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* Socket property
|
||||
|
@ -91,7 +91,7 @@ class DigestMethodTest extends CakeTestCase {
|
|||
$this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"';
|
||||
$this->HttpSocket->config['request']['auth'] = array();
|
||||
$this->assertFalse(isset($this->HttpSocket->request['header']['Authorization']));
|
||||
DigestMethod::authentication($this->HttpSocket);
|
||||
DigestAuthentication::authentication($this->HttpSocket);
|
||||
$this->assertTrue(isset($this->HttpSocket->request['header']['Authorization']));
|
||||
$this->assertEqual($this->HttpSocket->config['request']['auth']['realm'], 'The batcave');
|
||||
$this->assertEqual($this->HttpSocket->config['request']['auth']['nonce'], '4cded326c6c51');
|
||||
|
@ -105,7 +105,7 @@ class DigestMethodTest extends CakeTestCase {
|
|||
public function testQop() {
|
||||
$this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"';
|
||||
$this->HttpSocket->config['request']['auth'] = array();
|
||||
DigestMethod::authentication($this->HttpSocket);
|
||||
DigestAuthentication::authentication($this->HttpSocket);
|
||||
$expected = 'Digest username="admin", realm="The batcave", nonce="4cded326c6c51", uri="/", response="da7e2a46b471d77f70a9bb3698c8902b"';
|
||||
$this->assertEqual($expected, $this->HttpSocket->request['header']['Authorization']);
|
||||
$this->assertFalse(isset($this->HttpSocket->config['request']['auth']['qop']));
|
||||
|
@ -113,7 +113,7 @@ class DigestMethodTest extends CakeTestCase {
|
|||
|
||||
$this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",qop="auth"';
|
||||
$this->HttpSocket->config['request']['auth'] = array();
|
||||
DigestMethod::authentication($this->HttpSocket);
|
||||
DigestAuthentication::authentication($this->HttpSocket);
|
||||
$expected = '@Digest username="admin", realm="The batcave", nonce="4cded326c6c51", uri="/", response="[a-z0-9]{32}", qop="auth", nc=00000001, cnonce="[a-z0-9]+"@';
|
||||
$this->assertPattern($expected, $this->HttpSocket->request['header']['Authorization']);
|
||||
$this->assertEqual($this->HttpSocket->config['request']['auth']['qop'], 'auth');
|
||||
|
@ -128,12 +128,12 @@ class DigestMethodTest extends CakeTestCase {
|
|||
public function testOpaque() {
|
||||
$this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"';
|
||||
$this->HttpSocket->config['request']['auth'] = array();
|
||||
DigestMethod::authentication($this->HttpSocket);
|
||||
DigestAuthentication::authentication($this->HttpSocket);
|
||||
$this->assertFalse(strpos($this->HttpSocket->request['header']['Authorization'], 'opaque="d8ea7aa61a1693024c4cc3a516f49b3c"'));
|
||||
|
||||
$this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",opaque="d8ea7aa61a1693024c4cc3a516f49b3c"';
|
||||
$this->HttpSocket->config['request']['auth'] = array();
|
||||
DigestMethod::authentication($this->HttpSocket);
|
||||
DigestAuthentication::authentication($this->HttpSocket);
|
||||
$this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'opaque="d8ea7aa61a1693024c4cc3a516f49b3c"') > 0);
|
||||
}
|
||||
|
||||
|
@ -145,18 +145,18 @@ class DigestMethodTest extends CakeTestCase {
|
|||
public function testMultipleRequest() {
|
||||
$this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",qop="auth"';
|
||||
$this->HttpSocket->config['request']['auth'] = array();
|
||||
DigestMethod::authentication($this->HttpSocket);
|
||||
DigestAuthentication::authentication($this->HttpSocket);
|
||||
$this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000001') > 0);
|
||||
$this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 2);
|
||||
|
||||
DigestMethod::authentication($this->HttpSocket);
|
||||
DigestAuthentication::authentication($this->HttpSocket);
|
||||
$this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000002') > 0);
|
||||
$this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 3);
|
||||
$responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response=');
|
||||
$response = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32);
|
||||
|
||||
$this->HttpSocket->nextHeader = '';
|
||||
DigestMethod::authentication($this->HttpSocket);
|
||||
DigestAuthentication::authentication($this->HttpSocket);
|
||||
$this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000003') > 0);
|
||||
$this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 4);
|
||||
$responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response=');
|
||||
|
@ -173,7 +173,7 @@ class DigestMethodTest extends CakeTestCase {
|
|||
$this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"';
|
||||
$this->HttpSocket->request['uri']['path'] = '/admin';
|
||||
$this->HttpSocket->config['request']['auth'] = array();
|
||||
DigestMethod::authentication($this->HttpSocket);
|
||||
DigestAuthentication::authentication($this->HttpSocket);
|
||||
$responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response=');
|
||||
$response = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32);
|
||||
$this->assertNotEqual($response, 'da7e2a46b471d77f70a9bb3698c8902b');
|
Loading…
Add table
Reference in a new issue