Skip to content

Commit

Permalink
update basic auth
Browse files Browse the repository at this point in the history
  • Loading branch information
JanHuang committed Feb 10, 2017
1 parent 8799d1f commit 7cd053c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 55 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
"fastd/swoole": "~1.0.0",
"fastd/testing": "~0.1.0",
"fastd/middleware": "~1.0.0",
"fastd/basic-authenticate": "~0.1.0",
"catfan/Medoo": "~1.1.0",
"symfony/cache": "~3.2",
"symfony/console": "^3.2",
"monolog/monolog": "~1.0",
"tuupola/slim-basic-auth": "^2.2"
"monolog/monolog": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "^5.0"
Expand Down
44 changes: 0 additions & 44 deletions src/Auth/BasicAuthenticationMiddleware.php

This file was deleted.

6 changes: 5 additions & 1 deletion tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function testModel()

$response = $app->handleRequest($this->createRequest('GET', '/model'));

// echo $response->getBody();
echo $response->getBody();
}

public function testAuth()
Expand All @@ -99,6 +99,8 @@ public function testAuth()

$response = $app->handleRequest($this->createRequest('GET', '/auth'));

echo $response->getBody();

$this->assertEquals(json_encode([
'msg' => 'not allow access',
'code' => 401
Expand All @@ -109,6 +111,8 @@ public function testAuth()
'PHP_AUTH_PW' => 'bar'
]));

echo $response->getBody();

$this->assertEquals(json_encode([
'foo' => 'bar'
]), (string) $response->getBody());
Expand Down
25 changes: 17 additions & 8 deletions tests/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,27 @@
* Http middleware
*/
'middleware' => [
'basic.auth' => \FastD\Auth\BasicAuthenticationMiddleware::class
'basic.auth' => new FastD\BasicAuthenticate\HttpBasicAuthentication([
'authenticator' => [
'class' => \FastD\BasicAuthenticate\PhpAuthenticator::class,
'params' => [
'foo' => 'bar'
]
],
'response' => [
'class' => \FastD\Http\JsonResponse::class,
'data' => [
'msg' => 'not allow access',
'code' => 401
]
]
])
],

/**
* HTTP basic auth
* User custom configure
*/
'basic.auth' => [
'secure' => false, // https
'users' => [
'foo' => 'bar'
]
],
'config' => include __DIR__ . '/config.php',

/**
* Database config
Expand Down
12 changes: 12 additions & 0 deletions tests/config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
/**
* @author jan huang <[email protected]>
* @copyright 2016
*
* @link https://www.github.com/janhuang
* @link http://www.fast-d.cn/
*/

return [

];

0 comments on commit 7cd053c

Please sign in to comment.