Skip to content

Commit

Permalink
Merge pull request #5 from chadicus/develop
Browse files Browse the repository at this point in the history
Change namespace of project
  • Loading branch information
chadicus committed Sep 21, 2017
2 parents 854a6f3 + d068f07 commit c7bd33e
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 30 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"php-coveralls/php-coveralls": "^1.0"
},
"autoload": {
"psr-4": { "Chadicus\\Hmac\\" : "src" }
"psr-4": { "Chadicus\\Psr\\Http\\ServerMiddleware\\" : "src" }
},
"autoload-dev": {
"psr-4": { "ChadicusTest\\Hmac\\" : "tests" }
"psr-4": { "ChadicusTest\\Psr\\Http\\ServerMiddleware\\" : "tests" }
}
}
2 changes: 1 addition & 1 deletion src/AuthenticationException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Chadicus\Hmac;
namespace Chadicus\Psr\Http\ServerMiddleware;

/**
* Exception to throw when authentication fails.
Expand Down
7 changes: 6 additions & 1 deletion src/Hmac/AuthorizationHeaderExtractor.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

namespace Chadicus\Hmac;
namespace Chadicus\Psr\Http\ServerMiddleware\Hmac;

use Chadicus\Psr\Http\ServerMiddleware\AuthenticationException;
use Chadicus\Psr\Http\ServerMiddleware\Token;
use Chadicus\Psr\Http\ServerMiddleware\TokenExtractorInterface;
use Psr\Http\Message\ServerRequestInterface;

/**
* Token extractor to obtain a token from an authorization header.
Expand Down
4 changes: 3 additions & 1 deletion src/Hmac/TokenValidator.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

namespace Chadicus\Hmac;
namespace Chadicus\Psr\Http\ServerMiddleware\Hmac;

use Chadicus\Psr\Http\ServerMiddleware\Token;
use Chadicus\Psr\Http\ServerMiddleware\TokenValidatorInterface;
use Psr\Http\Message\ServerRequestInterface;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/KeyProviderInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Chadicus\Hmac;
namespace Chadicus\Psr\Http\ServerMiddleware;

/**
* Interface for private key repositories.
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Chadicus\Hmac;
namespace Chadicus\Psr\Http\ServerMiddleware;

use ArrayAccess;
use Psr\Http\Message\ServerRequestInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Token.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Chadicus\Hmac;
namespace Chadicus\Psr\Http\ServerMiddleware;

/**
* Immutable hmac authentication token.
Expand Down
2 changes: 1 addition & 1 deletion src/TokenExtractorInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Chadicus\Hmac;
namespace Chadicus\Psr\Http\ServerMiddleware;

use Psr\Http\Message\ServerRequestInterface;

Expand Down
2 changes: 1 addition & 1 deletion src/TokenValidatorInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Chadicus\Hmac;
namespace Chadicus\Psr\Http\ServerMiddleware;

use Psr\Http\Message\ServerRequestInterface;

Expand Down
6 changes: 3 additions & 3 deletions tests/AuthenticationExceptionTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace ChadicusTest\Hmac;
namespace ChadicusTest\Psr\Http\ServerMiddleware;

use Chadicus\Hmac\AuthenticationException;
use Chadicus\Psr\Http\ServerMiddleware\AuthenticationException;

/**
* @coversDefaultClass \Chadicus\Hmac\AuthenticationException
* @coversDefaultClass \Chadicus\Psr\Http\ServerMiddleware\AuthenticationException
* @covers ::__construct
*/
final class AuthenticationExceptionTest extends \PHPUnit\Framework\TestCase
Expand Down
31 changes: 17 additions & 14 deletions tests/MiddlewareTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<?php

namespace ChadicusTest\Hmac;
namespace ChadicusTest\Psr\Http\ServerMiddleware;

use ArrayObject;
use Chadicus\Hmac;
use Chadicus\Psr\Http\ServerMiddleware\AuthenticationException;
use Chadicus\Psr\Http\ServerMiddleware\Middleware;
use Chadicus\Psr\Http\ServerMiddleware\Token;
use Chadicus\Psr\Http\ServerMiddleware;
use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequest;

/**
* @coversDefaultClass \Chadicus\Hmac\Middleware
* @coversDefaultClass \Chadicus\Psr\Http\ServerMiddleware\Middleware
* @covers ::__construct
*/
final class MiddlewareTest extends \PHPUnit\Framework\TestCase
Expand All @@ -29,20 +32,20 @@ public function invoke()
$time = time();
$signature = md5("{$privateKey}{$nonce}{$time}{$publicKey}");

$token = new Hmac\Token($publicKey, $signature, $nonce, $time);
$token = new Token($publicKey, $signature, $nonce, $time);

$provider = $this->getMockBuilder('\\Chadicus\\Hmac\\KeyProviderInterface')->getMock();
$provider = $this->getMockBuilder('\\Chadicus\\Psr\\Http\\ServerMiddleware\\KeyProviderInterface')->getMock();
$provider->method('findPrivateKey')->willReturn($privateKey);

$extractor = $this->getMockBuilder('\\Chadicus\\Hmac\\TokenExtractorInterface')->getMock();
$extractor = $this->getMockBuilder('\\Chadicus\\Psr\\Http\\ServerMiddleware\\TokenExtractorInterface')->getMock();
$extractor->method('extract')->willReturn($token);

$validator = $this->getMockBuilder('\\Chadicus\\Hmac\\TokenValidatorInterface')->getMock();
$validator = $this->getMockBuilder('\\Chadicus\\Psr\\Http\\ServerMiddleware\\TokenValidatorInterface')->getMock();
$validator->method('validate')->willReturn(true);

$container = new ArrayObject();

$middleware = new Hmac\Middleware($provider, $extractor, $validator, $container);
$middleware = new Middleware($provider, $extractor, $validator, $container);

$headers = [
'X-Hmac-Auth' => ["{$publicKey}:{$signature}:{$nonce}:{$time}"],
Expand Down Expand Up @@ -77,22 +80,22 @@ public function invokeExceptionThrown()
$time = time();
$signature = md5("{$privateKey}{$nonce}{$time}{$publicKey}");

$token = new Hmac\Token($publicKey, $signature, $nonce, $time);
$token = new Token($publicKey, $signature, $nonce, $time);

$provider = $this->getMockBuilder('\\Chadicus\\Hmac\\KeyProviderInterface')->getMock();
$provider = $this->getMockBuilder('\\Chadicus\\Psr\\Http\\ServerMiddleware\\KeyProviderInterface')->getMock();
$provider->method('findPrivateKey')->willReturn($privateKey);

$extractor = $this->getMockBuilder('\\Chadicus\\Hmac\\TokenExtractorInterface')->getMock();
$extractor = $this->getMockBuilder('\\Chadicus\\Psr\\Http\\ServerMiddleware\\TokenExtractorInterface')->getMock();
$extractor->method('extract')->willReturn($token);

$exception = new Hmac\AuthenticationException(400, 'Bad Request');
$exception = new AuthenticationException(400, 'Bad Request');

$validator = $this->getMockBuilder('\\Chadicus\\Hmac\\TokenValidatorInterface')->getMock();
$validator = $this->getMockBuilder('\\Chadicus\\Psr\\Http\\ServerMiddleware\\TokenValidatorInterface')->getMock();
$validator->method('validate')->will($this->throwException($exception));

$container = new ArrayObject();

$middleware = new Hmac\Middleware($provider, $extractor, $validator, $container);
$middleware = new Middleware($provider, $extractor, $validator, $container);

$headers = [
'X-Hmac-Auth' => ["{$publicKey}:{$signature}:{$nonce}:{$time}"],
Expand Down
6 changes: 3 additions & 3 deletions tests/TokenTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace ChadicusTest\Hmac;
namespace ChadicusTest\Psr\Http\ServerMiddleware;

use Chadicus\Hmac\Token;
use Chadicus\Psr\Http\ServerMiddleware\Token;

/**
* @coversDefaultClass \Chadicus\Hmac\Token
* @coversDefaultClass \Chadicus\Psr\Http\ServerMiddleware\Token
* @covers ::__construct
*/
final class TokenTest extends \PHPUnit\Framework\TestCase
Expand Down

0 comments on commit c7bd33e

Please sign in to comment.