Skip to content

Commit

Permalink
Merge pull request 3scale-qe#795 from dhlavac/billing_update
Browse files Browse the repository at this point in the history
Extended Stripe tests of 3ds challenge testing
  • Loading branch information
dhlavac authored Feb 7, 2024
2 parents fb4e858 + e17900d commit 3fc8690
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
22 changes: 13 additions & 9 deletions testsuite/tests/ui/billing/stripe/test_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@
import pytest


@pytest.mark.parametrize(
"cc_number, verify_3ds",
[
("4000002500003155", True),
("4242424242424242", False),
@pytest.fixture(
scope="module",
autouse=True,
params=[
pytest.param(("4000002500003155", True), id="EU card, 3ds verification required"),
pytest.param(("4242424242424242", False), id="US card, no verification"),
pytest.param(("4000002030000002", False), id="EU card, no verification"),
],
)
# pylint: disable=too-many-arguments
def test_3ds_challenge(custom_card, cc_number, verify_3ds, stripe, invoice, account):
def card_setup(request, custom_card):
"""Card setup"""
custom_card(request.param[0], verify_3ds=request.param[1])


def test_3ds_challenge(stripe, invoice, account):
"""
Tests basic billing scenario for Stripe gateway:
- Add CC details for an account
- Complete 3DS challenge if it's supported
- Trigger billing via UI
- Trigger billing via API
"""
custom_card(cc_number, verify_3ds)

charged = invoice.charge()
stripe.assert_payment(charged, account)
13 changes: 4 additions & 9 deletions testsuite/ui/views/devel/settings/stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def add(self, credit_card, postal):
self.cc_details.cardnumber.fill(credit_card.number)
self.cc_details.expiration.fill(f"{credit_card.exp_month}{credit_card.exp_year}")
self.cc_details.cvc.fill(credit_card.cvc)
self.cc_details.postal.fill(postal)
if self.cc_details.postal.is_displayed:
self.cc_details.postal.fill(postal)
self.submit_btn.click()

@property
Expand All @@ -80,17 +81,11 @@ class challenge_frame(View): # pylint: disable=invalid-name
"""Nested IFrame"""

FRAME = ".//iframe[@id='challengeFrame']"

@View.nested
class acs_frame(View): # pylint: disable=invalid-name
"""Nested IFrame that contains OTP elements"""

FRAME = ".//iframe[@name='acsFrame']"
complete_auth = GenericLocatorWidget(".//button[@id='test-source-authorize-3ds']")
complete_auth = GenericLocatorWidget(".//button[@id='test-source-authorize-3ds']")

def complete_auth(self):
"""Completes the authentication"""
self.browser.element(self.challenge_frame.acs_frame.complete_auth).submit()
self.browser.element(self.challenge_frame.complete_auth).submit()
self.browser.selenium.switch_to.default_content()
self.browser.wait_for_element("//*[normalize-space(.)='Credit card number']", timeout=20)

Expand Down

0 comments on commit 3fc8690

Please sign in to comment.