Skip to content

Commit

Permalink
[Checkout] Add scenario for preventing from a potential XSS attack
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed May 10, 2024
1 parent 3d66fb0 commit 9255540
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@checkout
Feature: Preventing from a potential XSS attack during updating the address in the checkout
In order to keep my information safe
As a Visitor
I want to be protected against the potential XSS attacks

Background:
Given the store operates on a single channel in "United States"
And the store has a product "PHP T-Shirt" priced at "$19.99"
And the store ships everywhere for Free
And I have product "PHP T-Shirt" in the cart
And I am at the checkout addressing step

@ui @javascript @no-api
Scenario: Preventing from a potential XSS attack during updating the address in the checkout
When I specify the email as "john.doe@example.com"
And I specify the billing address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Doe"
And I specify the province name manually as '<img """><script>alert("XSS")</script>">' for billing address
And I complete the addressing step
And I decide to change my address
Then I should be able to update the address without unexpected alert
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,14 @@ public function shouldHaveCountriesToChooseFrom(string ...$countries): void
Assert::same($availableBillingCountries, $countries);
}

/**
* @Then I should be able to update the address without unexpected alert
*/
public function iShouldBeAbleToUpdateTheAddressWithoutUnexpectedAlert(): void
{
$this->addressPage->waitForFormToStopLoading();
}

/**
* @return AddressInterface
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Sylius/Behat/Page/Shop/Checkout/AddressPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ public function getAvailableBillingCountries(): array
return $this->getOptionsFromSelect($this->getElement('billing_country'));
}

public function waitForFormToStopLoading(): void
{
JQueryHelper::waitForFormToStopLoading($this->getDocument());
}

protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
Expand Down
2 changes: 2 additions & 0 deletions src/Sylius/Behat/Page/Shop/Checkout/AddressPageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,6 @@ public function getAvailableBillingCountries(): array;
public function isDifferentShippingAddressChecked(): bool;

public function isShippingAddressVisible(): bool;

public function waitForFormToStopLoading(): void;
}

0 comments on commit 9255540

Please sign in to comment.