Skip to content
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

test(selenium): read config from CONNECTOR_AUTH_FILE_PATH environment variable and fix bugs in UI tests #1225

Merged
merged 36 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
69a7e0e
AkshayaFoiger Apr 29, 2023
e0116c9
Merge branch 'main' of github.com:juspay/hyperswitch
AkshayaFoiger May 4, 2023
262ff45
Merge branch 'main' of github.com:juspay/hyperswitch
AkshayaFoiger May 5, 2023
528119a
Merge branch 'main' of github.com:juspay/hyperswitch
AkshayaFoiger May 10, 2023
cf3ed3c
Merge branch 'main' of github.com:juspay/hyperswitch
AkshayaFoiger May 11, 2023
e1dc085
Merge branch 'main' of github.com:juspay/hyperswitch
AkshayaFoiger May 21, 2023
28977e0
Move ui tests configs auth.toml
jagan-jaya May 8, 2023
608cc80
feat(tests): update connector tests
jagan-jaya May 16, 2023
9479231
fix(tests): update redirection tests
jagan-jaya May 22, 2023
1e069d3
fix(tests): update adyen tests
jagan-jaya May 22, 2023
40d9837
fix clippy warnings
jagan-jaya May 22, 2023
324e4ca
Fix clippy warnings
jagan-jaya May 22, 2023
ca9de65
Merge branch 'ui-tests-v2' of github.com:juspay/hyperswitch
AkshayaFoiger May 22, 2023
4dd3831
Added test to worline and stripe
AkshayaFoiger May 24, 2023
c998ea6
worldline ui testcase
AkshayaFoiger May 24, 2023
195814e
Merge branch 'main' into ui-tests-v2
AkshayaFoiger May 24, 2023
f02c674
stripe_ui and worldline_ui testcases added
AkshayaFoiger May 24, 2023
a6f2833
Move automation configs to different struct
jagan-jaya May 25, 2023
18ed9e4
added payu
AkshayaFoiger May 25, 2023
bb520b0
Merge branch 'ui-tests-v2' of github.com:juspay/hyperswitch into ui-t…
AkshayaFoiger May 25, 2023
3c0edd6
formatted
AkshayaFoiger May 25, 2023
3732869
fix
AkshayaFoiger May 25, 2023
374ddd7
Merge branch 'main' into ui-tests-v2
jagan-jaya May 25, 2023
f94129c
updated
AkshayaFoiger May 26, 2023
d8bacee
Bug fixes
jagan-jaya May 26, 2023
19ffdfe
Merge branch 'ui-tests-v2' of https://github.com/juspay/orca into ui-…
jagan-jaya May 26, 2023
aa62dee
Removed localstorage file
jagan-jaya May 26, 2023
169b0e8
Merge branch 'main' into ui-tests-v2
jagan-jaya May 26, 2023
0b83aa0
Update stripe klarna tests
jagan-jaya May 26, 2023
d363bd2
Add support to run minimal tests
jagan-jaya May 29, 2023
3f812e4
Merge branch 'main' into ui-tests-v2
SanchithHegde May 29, 2023
47c7737
Merge branch 'main' into ui-tests-v2
jagan-jaya May 30, 2023
9311c6d
fix clippy warnings
jagan-jaya May 30, 2023
42242cf
Address review comments
jagan-jaya May 30, 2023
92a3149
Remove env variable usages
jagan-jaya May 31, 2023
e6e62c9
Removed unused env vars
jagan-jaya May 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions crates/api_models/src/webhooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub enum IncomingWebhookEvent {
EventNotSupported,
SourceChargeable,
SourceTransactionCreated,
ChargeSucceeded,
RefundFailure,
RefundSuccess,
DisputeOpened,
Expand Down Expand Up @@ -60,7 +59,6 @@ impl From<IncomingWebhookEvent> for WebhookFlow {
IncomingWebhookEvent::EndpointVerification => Self::ReturnResponse,
IncomingWebhookEvent::SourceChargeable
| IncomingWebhookEvent::SourceTransactionCreated => Self::BankTransfer,
IncomingWebhookEvent::ChargeSucceeded => Self::Payment,
}
}
}
Expand Down
24 changes: 22 additions & 2 deletions crates/router/src/connector/nuvei/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ pub struct NuveiPaymentsRequest {
pub checksum: String,
pub billing_address: Option<BillingAddress>,
pub related_transaction_id: Option<String>,
pub url_details: Option<UrlDetails>,
}

#[derive(Debug, Serialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct UrlDetails {
pub success_url: String,
pub failure_url: String,
pub pending_url: String,
}

#[derive(Debug, Serialize, Default)]
Expand Down Expand Up @@ -676,12 +685,18 @@ impl<F>
capture_method: item.request.capture_method,
..Default::default()
})?;
let return_url = item.request.get_return_url()?;
Ok(Self {
is_rebilling: request_data.is_rebilling,
user_token_id: request_data.user_token_id,
related_transaction_id: request_data.related_transaction_id,
payment_option: request_data.payment_option,
billing_address: request_data.billing_address,
url_details: Some(UrlDetails {
success_url: return_url.clone(),
failure_url: return_url.clone(),
pending_url: return_url,
}),
..request
})
}
Expand Down Expand Up @@ -1017,6 +1032,7 @@ pub enum NuveiTransactionStatus {
Declined,
Error,
Redirect,
Pending,
#[default]
Processing,
}
Expand Down Expand Up @@ -1100,7 +1116,9 @@ fn get_payment_status(response: &NuveiPaymentsResponse) -> enums::AttemptStatus
_ => enums::AttemptStatus::Failure,
}
}
NuveiTransactionStatus::Processing => enums::AttemptStatus::Pending,
NuveiTransactionStatus::Processing | NuveiTransactionStatus::Pending => {
enums::AttemptStatus::Pending
}
NuveiTransactionStatus::Redirect => enums::AttemptStatus::AuthenticationPending,
},
None => match response.status {
Expand Down Expand Up @@ -1253,7 +1271,9 @@ impl From<NuveiTransactionStatus> for enums::RefundStatus {
match item {
NuveiTransactionStatus::Approved => Self::Success,
NuveiTransactionStatus::Declined | NuveiTransactionStatus::Error => Self::Failure,
NuveiTransactionStatus::Processing | NuveiTransactionStatus::Redirect => Self::Pending,
NuveiTransactionStatus::Processing
| NuveiTransactionStatus::Pending
| NuveiTransactionStatus::Redirect => Self::Pending,
}
}
}
Expand Down
14 changes: 5 additions & 9 deletions crates/router/src/connector/stripe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1640,14 +1640,8 @@ impl api::IncomingWebhook for Stripe {

Ok(match details.event_data.event_object.object {
stripe::WebhookEventObjectType::PaymentIntent
| stripe::WebhookEventObjectType::Charge => {
api_models::webhooks::ObjectReferenceId::PaymentId(
api_models::payments::PaymentIdType::ConnectorTransactionId(
details.event_data.event_object.id,
),
)
}
stripe::WebhookEventObjectType::Dispute => {
| stripe::WebhookEventObjectType::Charge
| stripe::WebhookEventObjectType::Dispute => {
api_models::webhooks::ObjectReferenceId::PaymentId(
api_models::payments::PaymentIdType::ConnectorTransactionId(
details
Expand Down Expand Up @@ -1687,7 +1681,9 @@ impl api::IncomingWebhook for Stripe {
stripe::WebhookEventType::SourceChargeable => {
api::IncomingWebhookEvent::SourceChargeable
}
stripe::WebhookEventType::ChargeSucceeded => api::IncomingWebhookEvent::ChargeSucceeded,
stripe::WebhookEventType::ChargeSucceeded => {
api::IncomingWebhookEvent::PaymentIntentSuccess
}
stripe::WebhookEventType::DisputeCreated => api::IncomingWebhookEvent::DisputeOpened,
stripe::WebhookEventType::DisputeClosed => api::IncomingWebhookEvent::DisputeCancelled,
stripe::WebhookEventType::DisputeUpdated => api::IncomingWebhookEvent::try_from(
Expand Down
12 changes: 6 additions & 6 deletions crates/router/src/connector/stripe/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1399,11 +1399,11 @@ pub struct PaymentIntentResponse {
pub id: String,
pub object: String,
pub amount: i64,
pub amount_received: i64,
pub amount_capturable: i64,
pub amount_received: Option<i64>,
pub amount_capturable: Option<i64>,
pub currency: String,
pub status: StripePaymentStatus,
pub client_secret: Secret<String>,
pub client_secret: Option<Secret<String>>,
pub created: i32,
pub customer: Option<String>,
pub payment_method: Option<String>,
Expand Down Expand Up @@ -1519,7 +1519,7 @@ impl From<SetupIntentResponse> for PaymentIntentResponse {
id: value.id,
object: value.object,
status: value.status,
client_secret: value.client_secret,
client_secret: Some(value.client_secret),
customer: value.customer,
description: None,
statement_descriptor: value.statement_descriptor,
Expand Down Expand Up @@ -1619,7 +1619,7 @@ impl<F, T>
connector_metadata,
network_txn_id,
}),
amount_captured: Some(item.response.amount_received),
amount_captured: item.response.amount_received,
..item.data
})
}
Expand Down Expand Up @@ -1707,7 +1707,7 @@ impl<F, T>
Ok(Self {
status: enums::AttemptStatus::from(item.response.status.to_owned()),
response,
amount_captured: Some(item.response.amount_received),
amount_captured: item.response.amount_received,
..item.data
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,35 @@ use crate::{selenium::*, tester};

struct AdyenSeleniumTest;

impl SeleniumTest for AdyenSeleniumTest {}
impl SeleniumTest for AdyenSeleniumTest {
fn get_connector_name(&self) -> String {
"adyen_uk".to_string()
}
}

async fn should_make_adyen_gpay_payment(c: WebDriver) -> Result<(), WebDriverError> {
let conn = AdyenSeleniumTest {};
let pub_key = conn.get_configs().adyen_uk.unwrap().key1;
conn.make_gpay_payment(c,
&format!("{CHEKOUT_BASE_URL}/gpay?gatewayname=adyen&gatewaymerchantid=JuspayDEECOM&amount=70.00&country=US&currency=USD"),
&format!("{CHEKOUT_BASE_URL}/gpay?gatewayname=adyen&gatewaymerchantid={pub_key}&amount=70.00&country=US&currency=USD"),
vec![
Event::Assert(Assert::IsPresent("succeeded")),
Event::Assert(Assert::IsPresent("processing")),
]).await?;
Ok(())
}

async fn should_make_adyen_gpay_mandate_payment(c: WebDriver) -> Result<(), WebDriverError> {
let conn = AdyenSeleniumTest {};
let pub_key = conn.get_configs().adyen_uk.unwrap().key1;
conn.make_gpay_payment(c,
&format!("{CHEKOUT_BASE_URL}/gpay?gatewayname=adyen&gatewaymerchantid=JuspayDEECOM&amount=70.00&country=US&currency=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=7000&mandate_data[mandate_type][multi_use][currency]=USD"),
&format!("{CHEKOUT_BASE_URL}/gpay?gatewayname=adyen&gatewaymerchantid={pub_key}&amount=70.00&country=US&currency=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=7000&mandate_data[mandate_type][multi_use][currency]=USD"),
vec![
Event::Assert(Assert::IsPresent("succeeded")),
Event::Assert(Assert::IsPresent("processing")),
Event::Assert(Assert::IsPresent("Mandate ID")),
Event::Assert(Assert::IsPresent("man_")),// mandate id starting with man_
Event::Trigger(Trigger::Click(By::Id("pm-mandate-btn"))),
Event::Trigger(Trigger::Click(By::Css("#pm-mandate-btn a"))),
Event::Trigger(Trigger::Click(By::Id("pay-with-mandate-btn"))),
Event::Assert(Assert::IsPresent("succeeded")),
Event::Assert(Assert::IsPresent("processing")),
]).await?;
Ok(())
}
Expand All @@ -36,15 +42,16 @@ async fn should_make_adyen_gpay_zero_dollar_mandate_payment(
c: WebDriver,
) -> Result<(), WebDriverError> {
let conn = AdyenSeleniumTest {};
let pub_key = conn.get_configs().adyen_uk.unwrap().key1;
conn.make_gpay_payment(c,
&format!("{CHEKOUT_BASE_URL}/gpay?gatewayname=adyen&gatewaymerchantid=JuspayDEECOM&amount=0.00&country=US&currency=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=700&mandate_data[mandate_type][multi_use][currency]=USD"),
&format!("{CHEKOUT_BASE_URL}/gpay?gatewayname=adyen&gatewaymerchantid={pub_key}&amount=0.00&country=US&currency=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=700&mandate_data[mandate_type][multi_use][currency]=USD"),
vec![
Event::Assert(Assert::IsPresent("succeeded")),
Event::Assert(Assert::IsPresent("processing")),
Event::Assert(Assert::IsPresent("Mandate ID")),
Event::Assert(Assert::IsPresent("man_")),// mandate id starting with man_
Event::Trigger(Trigger::Click(By::Id("pm-mandate-btn"))),
Event::Trigger(Trigger::Click(By::Css("#pm-mandate-btn a"))),
Event::Trigger(Trigger::Click(By::Id("pay-with-mandate-btn"))),
Event::Assert(Assert::IsPresent("succeeded")),
Event::Assert(Assert::IsPresent("processing")),
]).await?;
Ok(())
}
Expand All @@ -67,12 +74,12 @@ async fn should_make_adyen_klarna_mandate_payment(c: WebDriver) -> Result<(), We
]
),
Event::Trigger(Trigger::SwitchTab(Position::Prev)),
Event::Assert(Assert::IsPresent("succeeded")),
Event::Assert(Assert::IsPresent("processing")),
Event::Assert(Assert::IsPresent("Mandate ID")),
Event::Assert(Assert::IsPresent("man_")),// mandate id starting with man_
Event::Trigger(Trigger::Click(By::Id("pm-mandate-btn"))),
Event::Trigger(Trigger::Click(By::Css("#pm-mandate-btn a"))),
Event::Trigger(Trigger::Click(By::Id("pay-with-mandate-btn"))),
Event::Assert(Assert::IsPresent("succeeded")),
Event::Assert(Assert::IsPresent("processing")),
]).await?;
Ok(())
}
Expand Down
43 changes: 32 additions & 11 deletions crates/router/tests/connectors/connector_auth.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::env;

use router::types::ConnectorAuthType;
use serde::Deserialize;
use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Clone)]
pub(crate) struct ConnectorAuthentication {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ConnectorAuthentication {
pub aci: Option<BodyKey>,
pub adyen: Option<BodyKey>,
pub adyen_uk: Option<BodyKey>,
pub airwallex: Option<BodyKey>,
pub authorizedotnet: Option<BodyKey>,
pub bambora: Option<BodyKey>,
Expand Down Expand Up @@ -35,10 +36,13 @@ pub(crate) struct ConnectorAuthentication {
pub rapyd: Option<BodyKey>,
pub shift4: Option<HeaderKey>,
pub stripe: Option<HeaderKey>,
pub stripe_au: Option<HeaderKey>,
pub stripe_uk: Option<HeaderKey>,
pub trustpay: Option<SignatureKey>,
pub worldpay: Option<BodyKey>,
pub worldline: Option<SignatureKey>,
pub zen: Option<HeaderKey>,
pub automation_configs: Option<AutomationConfigs>,
}

impl ConnectorAuthentication {
Expand All @@ -55,8 +59,8 @@ impl ConnectorAuthentication {
}
}

#[derive(Debug, Deserialize, Clone)]
pub(crate) struct HeaderKey {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct HeaderKey {
pub api_key: String,
}

Expand All @@ -68,8 +72,8 @@ impl From<HeaderKey> for ConnectorAuthType {
}
}

#[derive(Debug, Deserialize, Clone)]
pub(crate) struct BodyKey {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct BodyKey {
pub api_key: String,
pub key1: String,
}
Expand All @@ -83,8 +87,8 @@ impl From<BodyKey> for ConnectorAuthType {
}
}

#[derive(Debug, Deserialize, Clone)]
pub(crate) struct SignatureKey {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct SignatureKey {
pub api_key: String,
pub key1: String,
pub api_secret: String,
Expand All @@ -100,8 +104,8 @@ impl From<SignatureKey> for ConnectorAuthType {
}
}

#[derive(Debug, Deserialize, Clone)]
pub(crate) struct MultiAuthKey {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct MultiAuthKey {
pub api_key: String,
pub key1: String,
pub api_secret: String,
Expand All @@ -118,3 +122,20 @@ impl From<MultiAuthKey> for ConnectorAuthType {
}
}
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct AutomationConfigs {
pub hs_base_url: Option<String>,
pub hs_api_key: Option<String>,
pub hs_test_browser: Option<String>,
pub chrome_profile_path: Option<String>,
pub firefox_profile_path: Option<String>,
pub pypl_email: Option<String>,
pub pypl_pass: Option<String>,
pub gmail_email: Option<String>,
pub gmail_pass: Option<String>,
pub configs_url: Option<String>,
pub stripe_pub_key: Option<String>,
pub testcases_path: Option<String>,
pub run_minimum_steps: Option<bool>,
}
4 changes: 3 additions & 1 deletion crates/router/tests/connectors/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

mod aci;
mod adyen;
mod adyen_ui;
mod adyen_uk_ui;
mod airwallex;
mod authorizedotnet;
mod bambora;
Expand Down Expand Up @@ -35,6 +35,7 @@ mod opennode;
mod payeezy;
mod paypal;
mod payu;
mod payu_ui;
mod rapyd;
mod selenium;
mod shift4;
Expand All @@ -43,5 +44,6 @@ mod stripe_ui;
mod trustpay;
mod utils;
mod worldline;
mod worldline_ui;
mod worldpay;
mod zen;
Loading