-
Notifications
You must be signed in to change notification settings - Fork 347
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 #1974 from kenjis/add-csrf_auto_token
Add security.csrf_auto_token option to add CSRF token automatically
- Loading branch information
Showing
2 changed files
with
68 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
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 |
---|---|---|
|
@@ -275,4 +275,66 @@ public function test_label_auto_id_false() | |
|
||
\Config::set('form.auto_id', $config); | ||
} | ||
|
||
/** | ||
* Tests Form::open() | ||
* | ||
* @test | ||
*/ | ||
public function test_open() | ||
{ | ||
$form = \Form::forge(__METHOD__); | ||
|
||
$output = $form->open('uri/to/form'); | ||
$expected = '<form action="uri/to/form" accept-charset="utf-8" method="post">'; | ||
$this->assertEquals($expected, $output); | ||
} | ||
|
||
/** | ||
* Tests Form::open() | ||
* | ||
* @test | ||
*/ | ||
public function test_open_auto_csrf_token() | ||
{ | ||
$config = \Config::get('security.csrf_auto_token'); | ||
\Config::set('security.csrf_auto_token', true); | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
$form = \Form::forge(__METHOD__); | ||
|
||
$output = $form->open('uri/to/form'); | ||
$expected = '<form action="uri/to/form" accept-charset="utf-8" method="post">'.PHP_EOL.'<input name="fuel_csrf_token" value="%s" type="hidden" id="form_fuel_csrf_token" />'; | ||
$this->assertStringMatchesFormat($expected, $output); | ||
|
||
\Config::set('security.csrf_auto_token', $config); | ||
} | ||
|
||
/** | ||
* Tests Form::open() | ||
* | ||
* @test | ||
*/ | ||
public function test_open_static() | ||
{ | ||
$output = Form::open('uri/to/form'); | ||
$expected = '<form action="uri/to/form" accept-charset="utf-8" method="post">'; | ||
$this->assertEquals($expected, $output); | ||
} | ||
|
||
/** | ||
* Tests Form::open() | ||
* | ||
* @test | ||
*/ | ||
public function test_open_auto_csrf_token_static() | ||
{ | ||
$config = \Config::get('security.csrf_auto_token'); | ||
\Config::set('security.csrf_auto_token', true); | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
it-can
Contributor
|
||
$output = Form::open('uri/to/form'); | ||
$expected = '<form action="uri/to/form" accept-charset="utf-8" method="post">'.PHP_EOL.'<input name="fuel_csrf_token" value="%s" type="hidden" id="form_fuel_csrf_token" />'; | ||
$this->assertStringMatchesFormat($expected, $output); | ||
|
||
\Config::set('security.csrf_auto_token', $config); | ||
} | ||
} |
Maybe also set (my tests failed because I have a different name here)