Skip to content

Commit

Permalink
Merge pull request #6038 from KenTanaka/feature/add_rete_limit_for_entry
Browse files Browse the repository at this point in the history
新規会員登録(入力)画面のスロットリング追加
  • Loading branch information
xuelian311 committed Sep 29, 2023
2 parents 3b0883e + 205f580 commit 1c45058
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test-throttling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
php: [ 8.1 ]
db: [ pgsql ]
method: [ フロント画面ログイン_IP, フロント画面ログイン_会員, 管理画面ログイン_IP, 管理画面ログイン_会員, 会員登録, 問い合わせ, パスワード再発行, 注文確認_非会員購入, 注文確認_会員購入, 注文完了_非会員購入, 注文完了_会員購入, 会員情報編集, 配送先情報_追加, 配送先情報_編集, 配送先情報_削除, order_お届け先追加, order_お届け先変更 ]
method: [ フロント画面ログイン_IP, フロント画面ログイン_会員, 管理画面ログイン_IP, 管理画面ログイン_会員, 会員登録, 問い合わせ, パスワード再発行, 注文確認_非会員購入, 注文確認_会員購入, 注文完了_非会員購入, 注文完了_会員購入, 会員情報編集, 配送先情報_追加, 配送先情報_編集, 配送先情報_削除, order_お届け先追加, order_お届け先変更, 新規会員登録_入力 ]
include:
- db: pgsql
database_url: postgres://postgres:password@127.0.0.1:5432/eccube_db
Expand Down
8 changes: 7 additions & 1 deletion app/config/eccube/packages/prod/eccube_rate_limiter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ eccube:
type: ip
limit: 5
interval: '30 minutes'
entry:
entry: # 存在しているメールアドレスの確認を防止するためのスロットリング
route: entry
method: [ 'POST' ]
type: ip
limit: 25
interval: '30 minutes'
entry_complete: # 不正な会員登録を防止するためのスロットリング
route: entry
method: [ 'POST' ]
params:
Expand Down
29 changes: 24 additions & 5 deletions codeception/_support/Page/Front/EntryPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@

class EntryPage extends AbstractFrontPage
{

private $formData = [];

public function __construct(\AcceptanceTester $I)
{
parent::__construct($I);
}

/**
* @param $I
* @param $id
*
* @return EntryPage
*/
public static function go($I)
{
$page = new self($I);
Expand All @@ -28,11 +37,11 @@ public static function go($I)
return $page;
}

public function 新規会員登録($form = [])
public function フォーム入力($form = [])
{
$this->tester->amOnPage('/entry');
$email = uniqid().microtime(true).'@example.com';

$form += [
'entry[name][name01]' => '',
'entry[name][name02]' => '',
Expand All @@ -49,10 +58,20 @@ public function 新規会員登録($form = [])
'entry[plain_password][second]' => 'password1234',
'entry[user_policy_check]' => '1',
];
$this->tester->submitForm(['css' => '.ec-layoutRole__main form'], $form, ['css' => 'button.ec-blockBtn--action']);
$this->tester->seeInField(['id' => 'entry_email_first'], $form['entry[email][first]']);
$this->tester->click('.ec-registerRole form button.ec-blockBtn--action');
$this->formData = $form;
return $this;
}

public function 同意する()
{
$this->tester->submitForm(['css' => '.ec-layoutRole__main form'], $this->formData, ['css' => 'button.ec-blockBtn--action']);
$this->tester->seeInField(['id' => 'entry_email_first'], $this->formData['entry[email][first]']);
return $this;
}

public function 登録する()
{
$this->tester->click('.ec-registerRole form button.ec-blockBtn--action');
return $this;
}
}
22 changes: 14 additions & 8 deletions codeception/acceptance/EA07BasicinfoCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ public function basicinfo_会員設定_仮会員機能(AcceptanceTester $I)
// 会員登録
$faker = Fixtures::get('faker');
$email = microtime(true).'.'.$faker->safeEmail;
EntryPage::go($I)->新規会員登録([
'entry[email][first]' => $email,
'entry[email][second]' => $email,
]);
EntryPage::go($I)
->フォーム入力([
'entry[email][first]' => $email,
'entry[email][second]' => $email,
])
->同意する()
->登録する();

// 会員ステータスのチェック
$page = CustomerManagePage::go($I);
Expand All @@ -119,10 +122,13 @@ public function basicinfo_会員設定_仮会員機能(AcceptanceTester $I)
// 会員登録
$I->logoutAsMember();
$email = microtime(true).'.'.$faker->safeEmail;
EntryPage::go($I)->新規会員登録([
'entry[email][first]' => $email,
'entry[email][second]' => $email,
]);
EntryPage::go($I)
->フォーム入力([
'entry[email][first]' => $email,
'entry[email][second]' => $email,
])
->同意する()
->登録する();
$I->logoutAsMember();

// 会員ステータスのチェック
Expand Down
32 changes: 28 additions & 4 deletions codeception/acceptance/EF09ThrottlingCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
use Page\Front\ShoppingLoginPage;
use Page\Front\ShoppingNonmemberPage;
use Page\Front\ShoppingPage;
use Page\Front\EntryPage;


/**
* @group throttling
Expand Down Expand Up @@ -138,14 +140,18 @@ public function 会員登録(AcceptanceTester $I)

for ($i = 0; $i < 5; $i++) {
$I->expect('会員登録を行います:'.$i);
\Page\Front\EntryPage::go($I)
->新規会員登録();
EntryPage::go($I)
->フォーム入力()
->同意する()
->登録する();
$I->see('現在、仮会員の状態です。', 'p.ec-reportDescription');
}

$I->expect('試行回数上限を超過します');
\Page\Front\EntryPage::go($I)
->新規会員登録();
EntryPage::go($I)
->フォーム入力()
->同意する()
->登録する();
$I->see('試行回数の上限を超過しました。しばらくお待ちいただき、再度お試しください。', 'p.ec-reportDescription');
}

Expand Down Expand Up @@ -748,4 +754,22 @@ public function order_お届け先変更(AcceptanceTester $I)
$I->wait(1);
$I->see('試行回数の上限を超過しました。しばらくお待ちいただき、再度お試しください。', 'p.ec-reportDescription');
}

public function 新規会員登録_入力(AcceptanceTester $I)
{
$I->wantTo('EF0901-UC01-T18_会員登録_入力');

for ($i = 0; $i < 25; $i++) {
$I->expect('会員登録を行います:'.$i);
EntryPage::go($I)
->フォーム入力()
->登録する();
}

EntryPage::go($I)
->フォーム入力()
->登録する();
$I->see('試行回数の上限を超過しました。しばらくお待ちいただき、再度お試しください。', 'p.ec-reportDescription');
}

}

0 comments on commit 1c45058

Please sign in to comment.