-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3917 from HungDV2022/unittest_JwksController
JwksController::initialize() & index() ユニットテスト調整
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
plugins/baser-core/tests/TestCase/Controller/Api/Admin/JwksControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* baserCMS : Based Website Development Project <https://basercms.net> | ||
* Copyright (c) NPO baser foundation <https://baserfoundation.org/> | ||
* | ||
* @copyright Copyright (c) NPO baser foundation | ||
* @link https://basercms.net baserCMS Project | ||
* @since 5.0.0 | ||
* @license https://basercms.net/license/index.html MIT License | ||
*/ | ||
|
||
namespace BaserCore\Test\TestCase\Controller\Api\Admin; | ||
|
||
use BaserCore\Controller\Api\Admin\JwksController; | ||
use BaserCore\TestSuite\BcTestCase; | ||
use BaserCore\Utility\BcContainerTrait; | ||
use Cake\TestSuite\IntegrationTestTrait; | ||
|
||
/** | ||
* JwksControllerTest Test Case | ||
*/ | ||
class JwksControllerTest extends BcTestCase | ||
{ | ||
|
||
/** | ||
* Trait | ||
*/ | ||
use IntegrationTestTrait; | ||
use BcContainerTrait; | ||
|
||
/** | ||
* set up | ||
*/ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
/** | ||
* test initialize | ||
* | ||
* @return void | ||
*/ | ||
public function testInitialize() | ||
{ | ||
$controller = new JwksController($this->getRequest()); | ||
$this->assertEquals(['index'], $controller->Authentication->getUnauthenticatedActions()); | ||
} | ||
|
||
/** | ||
* test index | ||
*/ | ||
public function testIndex() | ||
{ | ||
$this->get('/baser/api/admin/baser-core/jwks/index.json'); | ||
//ステータスを確認 | ||
$this->assertResponseCode(200); | ||
//戻り値確認 | ||
$vars = $this->_controller->viewBuilder()->getVars(); | ||
$this->assertArrayHasKey('kid', $vars['keys']['keys'][0]); | ||
$this->assertArrayHasKey('kty', $vars['keys']['keys'][0]); | ||
$this->assertArrayHasKey('alg', $vars['keys']['keys'][0]); | ||
$this->assertArrayHasKey('use', $vars['keys']['keys'][0]); | ||
$this->assertArrayHasKey('e', $vars['keys']['keys'][0]); | ||
$this->assertArrayHasKey('n', $vars['keys']['keys'][0]); | ||
} | ||
} |