-
Notifications
You must be signed in to change notification settings - Fork 5
Add steps and basic tests for response headers #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8b92ce0
Add steps and basic tests for response headers
danielbachhuber 8aa1ebf
Drop periods from these steps
danielbachhuber aac4abf
Fix typo in cache value
danielbachhuber 8a55da1
Add trailing captures to statement; tweak statements
danielbachhuber d4009cc
Be more precise with this statement
danielbachhuber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,66 @@ | ||
| <?php | ||
|
|
||
| namespace PantheonSystems\PantheonWordPressUpstreamTests\Behat; | ||
|
|
||
| use Behat\MinkExtension\Context\RawMinkContext; | ||
|
|
||
| class ResponseHeader extends RawMinkContext { | ||
|
|
||
| /** | ||
| * Checks, that current page response header is equal to specified. | ||
| * | ||
| * @Then /^the response header "(?P<name>(?:[^"]|\\")*)" should be "(?P<value>(?:[^"]|\\")*)"$/ | ||
| */ | ||
| public function assertResponseHeader($name, $value) | ||
| { | ||
| $this->assertSession()->responseHeaderEquals($name, $value); | ||
| } | ||
|
|
||
| /** | ||
| * Checks, that current page response header is not equal to specified. | ||
| * | ||
| * @Then /^the response header "(?P<name>(?:[^"]|\\")*)" should not be "(?P<value>(?:[^"]|\\")*)"$/ | ||
| */ | ||
| public function assertResponseHeaderIsNot($name, $value) | ||
| { | ||
| $this->assertSession()->responseHeaderNotEquals($name, $value); | ||
| } | ||
|
|
||
| /** | ||
| * Checks that the current page response header is set | ||
| * | ||
| * @Then /^the response header "(?P<name>(?:[^"]|\\")*)" should exist | ||
| */ | ||
| public function assertResponseHeaderExists($name) { | ||
| $this->assertSession()->responseHeaderMatches($name,'/^.{1,}$/'); | ||
| } | ||
|
|
||
| /** | ||
| * Checks that the current page response header is not set | ||
| * | ||
| * @Then /^the response header "(?P<name>(?:[^"]|\\")*)" should not exist | ||
| */ | ||
| public function assertResponseHeaderNotExists($name) { | ||
| $this->assertSession()->responseHeaderMatches($name,'/^.{0}$/'); | ||
| } | ||
|
|
||
| /** | ||
| * Checks, that current page response header contains specified value. | ||
| * | ||
| * @Then /^the response header "(?P<name>(?:[^"]|\\")*)" should contain "(?P<value>(?:[^"]|\\")*)"$/ | ||
| */ | ||
| public function assertResponseHeaderContains($name, $value) | ||
| { | ||
| $this->assertSession()->responseHeaderContains($name, $value); | ||
| } | ||
| /** | ||
| * Checks, that current page response header does not contain specified value. | ||
| * | ||
| * @Then /^the response header "(?P<name>(?:[^"]|\\")*)" should not contain "(?P<value>(?:[^"]|\\")*)"$/ | ||
| */ | ||
| public function assertResponseHeaderNotContains($name, $value) | ||
| { | ||
| $this->assertSession()->responseHeaderNotContains($name, $value); | ||
| } | ||
|
|
||
| } |
This file contains hidden or 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,13 @@ | ||
| Feature: Verify various Pantheon features as a logged-out user | ||
|
|
||
| Scenario: Cache-Control should default to TTL=600 | ||
| When I go to "/" | ||
| Then the response header "Cache-Control" should exist | ||
| And the response header "Cache-Control" should contain "max-age=600" | ||
|
|
||
| Scenario: Cache-Control should have "nocache" for logged-in users | ||
| Given I log in as an admin | ||
|
|
||
| When I go to "/" | ||
| And the response header "Cache-Control" should contain "no-cache" | ||
| And the response header "Cache-Control" should not contain "max-age=600" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to test only max-age and not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily. I've made it more precise in d4009cc