Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
CsrfProtectionMiddlewareを有効化したことによりテストが失敗していたので調整
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed May 5, 2021
1 parent 5f4fde4 commit 50ca3e7
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 80 deletions.
9 changes: 6 additions & 3 deletions plugins/baser-core/config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@

/**
* キャッシュ設定
* ユニットテスト時に重複して設定するとエラーとなるため判定を入れている
*/
if (Configure::read('debug')) {
Configure::write('Cache._bc_env_.duration', '+2 seconds');
if (!Cache::getConfig('_bc_env_')) {
if (Configure::read('debug')) {
Configure::write('Cache._bc_env_.duration', '+2 seconds');
}
Cache::setConfig(Configure::consume('Cache'));
}
Cache::setConfig(Configure::consume('Cache'));

/**
* デフォルトバリデーションプロバイダー
Expand Down
74 changes: 0 additions & 74 deletions plugins/baser-core/src/BcApplication.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function install($name)
$this->setTitle(__d('baser', '新規プラグイン登録'));
$this->setHelp('plugins_install');

if (!$isInstallable || !$this->request->is('post')) {
if (!$isInstallable || !$this->request->is('put')) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ public function testEntry()
$messages = TestEmailTransport::clearMessages();

$this->enableSecurityToken();
$this->enableCsrfToken();

$this->get('/baser/admin/password_requests/entry');
$this->assertResponseOk();


// メールアドレス送信
$this->post('/baser/admin/password_requests/entry', [
'email' => '[email protected]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ public function testAjax_delete_file()
public function testDetachAndInstallAndUninstall(): void
{
$this->enableSecurityToken();
$this->enableCsrfToken();
$this->post('/baser/admin/plugins/detach/BcSample');
$this->assertFlashMessage('プラグインの無効化に失敗しました。');
$this->post('/baser/admin/plugins/detach/BcBlog');
$this->assertFlashMessage('プラグイン「BcBlog」を無効にしました。');

$this->enableSecurityToken();
$this->put('/baser/admin/plugins/install/BcBlog', ['connection' => 'test']);
$this->assertRedirect([
'plugin' => 'BaserCore',
Expand Down Expand Up @@ -161,6 +161,7 @@ public function test_addPermission()
public function testReset_db()
{
$this->enableSecurityToken();
$this->enableCsrfToken();
$this->put('/baser/admin/plugins/reset_db/BcBlog', ['connection' => 'test', 'name' => 'BcBlog']);
$this->assertRedirect([
'plugin' => 'BaserCore',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testIndex_pagination()
public function testAdd()
{
$this->enableSecurityToken();

$this->enableCsrfToken();
$this->get('/baser/admin/user_groups/add');
$this->assertResponseOk();

Expand Down Expand Up @@ -135,6 +135,7 @@ public function testDelete()
public function testCopy()
{
$this->enableSecurityToken();
$this->enableCsrfToken();
$this->post('/baser/admin/user_groups/copy/1');
$this->assertResponseSuccess();
$userGroups = $this->getTableLocator()->get('UserGroups');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function testIndex_pagination()
public function testAdd()
{
$this->enableSecurityToken();
$this->enableCsrfToken();
$data = [
'name' => 'Test_test_Man',
'password_1' => 'Lorem ipsum dolor sit amet',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public function testUpdatePassword()

// 変更後のパスワードでログイン
$this->enableSecurityToken();
$this->enableCsrfToken();
$this->post(Configure::read('BcPrefixAuth.Admin.loginAction'), [
'email' => '[email protected]',
'password' => 'test'
Expand Down

0 comments on commit 50ca3e7

Please sign in to comment.