refactor(ui_tests): move ui_tests to test_utils crate to reduce development time (#1822)

This commit is contained in:
Jagan
2023-08-01 16:22:51 +05:30
committed by GitHub
parent 8f65819f12
commit 5773faf739
74 changed files with 422 additions and 122 deletions

View File

@ -37,6 +37,6 @@ done
IN="$INPUT" IN="$INPUT"
for i in $(echo $IN | tr "," "\n"); do for i in $(echo $IN | tr "," "\n"); do
cargo test --package router --test connectors -- "${i}_ui::" --test-threads=1 >> tests/test_results.log 2>&1 cargo test --package test_utils --test connectors -- "${i}_ui::" --test-threads=1 >> tests/test_results.log 2>&1
done done
cat tests/test_results.log cat tests/test_results.log

17
Cargo.lock generated
View File

@ -446,9 +446,9 @@ dependencies = [
[[package]] [[package]]
name = "async-channel" name = "async-channel"
version = "1.8.0" version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35"
dependencies = [ dependencies = [
"concurrent-queue", "concurrent-queue",
"event-listener", "event-listener",
@ -4733,14 +4733,25 @@ dependencies = [
name = "test_utils" name = "test_utils"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"actix-http",
"actix-web",
"api_models", "api_models",
"async-trait",
"awc",
"clap", "clap",
"derive_deref",
"masking", "masking",
"router", "rand 0.8.5",
"serde", "serde",
"serde_json", "serde_json",
"serde_path_to_error", "serde_path_to_error",
"serde_urlencoded",
"serial_test",
"thirtyfour",
"time 0.3.22",
"tokio",
"toml 0.7.4", "toml 0.7.4",
"uuid",
] ]
[[package]] [[package]]

View File

@ -21,10 +21,10 @@ impl utils::Connector for {{project-name | downcase | pascal_case}}Test {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.{{project-name | downcase}} .{{project-name | downcase}}
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration").into(),
) )
} }

View File

@ -11,7 +11,7 @@ use router::{
}; };
use tokio::sync::oneshot; use tokio::sync::oneshot;
use crate::connector_auth::ConnectorAuthentication; use crate::{connector_auth::ConnectorAuthentication, utils};
fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData { fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData {
let auth = ConnectorAuthentication::new() let auth = ConnectorAuthentication::new()
@ -28,7 +28,7 @@ fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData {
status: enums::AttemptStatus::default(), status: enums::AttemptStatus::default(),
auth_type: enums::AuthenticationType::NoThreeDs, auth_type: enums::AuthenticationType::NoThreeDs,
payment_method: enums::PaymentMethod::Card, payment_method: enums::PaymentMethod::Card,
connector_auth_type: auth.into(), connector_auth_type: utils::to_connector_auth_type(auth.into()),
description: Some("This is a test".to_string()), description: Some("This is a test".to_string()),
return_url: None, return_url: None,
request: types::PaymentsAuthorizeData { request: types::PaymentsAuthorizeData {
@ -105,7 +105,7 @@ fn construct_refund_router_data<F>() -> types::RefundsRouterData<F> {
status: enums::AttemptStatus::default(), status: enums::AttemptStatus::default(),
payment_method: enums::PaymentMethod::Card, payment_method: enums::PaymentMethod::Card,
auth_type: enums::AuthenticationType::NoThreeDs, auth_type: enums::AuthenticationType::NoThreeDs,
connector_auth_type: auth.into(), connector_auth_type: utils::to_connector_auth_type(auth.into()),
description: Some("This is a test".to_string()), description: Some("This is a test".to_string()),
return_url: None, return_url: None,
request: types::RefundsData { request: types::RefundsData {

View File

@ -32,10 +32,11 @@ impl utils::Connector for AdyenTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.adyen_uk .adyen_uk
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -25,10 +25,11 @@ impl Connector for AirwallexTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.airwallex .airwallex
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -22,10 +22,11 @@ impl utils::Connector for AuthorizedotnetTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.authorizedotnet .authorizedotnet
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -23,10 +23,11 @@ impl utils::Connector for BamboraTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.bambora .bambora
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -21,10 +21,11 @@ impl utils::Connector for BitpayTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.bitpay .bitpay
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -25,10 +25,11 @@ impl utils::Connector for BluesnapTest {
} }
fn get_auth_token(&self) -> ConnectorAuthType { fn get_auth_token(&self) -> ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.bluesnap .bluesnap
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -18,10 +18,11 @@ impl utils::Connector for BokuTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.boku .boku
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -20,10 +20,11 @@ impl utils::Connector for CashtocodeTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.cashtocode .cashtocode
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -19,10 +19,11 @@ impl utils::Connector for CheckoutTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.checkout .checkout
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -22,10 +22,11 @@ impl utils::Connector for CoinbaseTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.coinbase .coinbase
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -21,10 +21,11 @@ impl utils::Connector for CryptopayTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.cryptopay .cryptopay
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -23,10 +23,11 @@ impl utils::Connector for Cybersource {
} }
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.cybersource .cybersource
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }
fn get_name(&self) -> String { fn get_name(&self) -> String {

View File

@ -23,10 +23,11 @@ impl utils::Connector for DlocalTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.dlocal .dlocal
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -21,10 +21,11 @@ impl utils::Connector for DummyConnectorTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.dummyconnector .dummyconnector
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -23,10 +23,11 @@ impl utils::Connector for FiservTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.fiserv .fiserv
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -23,10 +23,11 @@ impl utils::Connector for ForteTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.forte .forte
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -23,10 +23,11 @@ impl Connector for Globalpay {
} }
fn get_auth_token(&self) -> ConnectorAuthType { fn get_auth_token(&self) -> ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.globalpay .globalpay
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -20,10 +20,11 @@ impl utils::Connector for GlobepayTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.globepay .globepay
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -22,10 +22,11 @@ impl Connector for IatapayTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.iatapay .iatapay
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -7,22 +7,15 @@
use test_utils::connector_auth; use test_utils::connector_auth;
mod aci; mod aci;
mod aci_ui;
mod adyen; mod adyen;
mod adyen_uk_ui;
mod airwallex; mod airwallex;
mod airwallex_ui;
mod authorizedotnet; mod authorizedotnet;
mod authorizedotnet_ui;
mod bambora; mod bambora;
mod bambora_ui;
mod bitpay; mod bitpay;
mod bluesnap; mod bluesnap;
mod bluesnap_ui;
mod boku; mod boku;
mod cashtocode; mod cashtocode;
mod checkout; mod checkout;
mod checkout_ui;
mod coinbase; mod coinbase;
mod cryptopay; mod cryptopay;
mod cybersource; mod cybersource;
@ -32,43 +25,29 @@ mod dummyconnector;
mod fiserv; mod fiserv;
mod forte; mod forte;
mod globalpay; mod globalpay;
mod globalpay_ui;
mod globepay; mod globepay;
mod iatapay; mod iatapay;
mod mollie; mod mollie;
mod mollie_ui;
mod multisafepay; mod multisafepay;
mod multisafepay_ui;
mod nexinets; mod nexinets;
mod nexinets_ui;
mod nmi; mod nmi;
mod noon; mod noon;
mod noon_ui;
mod nuvei; mod nuvei;
mod nuvei_ui;
mod opayo; mod opayo;
mod opennode; mod opennode;
mod payeezy; mod payeezy;
mod payme; mod payme;
mod paypal; mod paypal;
mod paypal_ui;
mod payu; mod payu;
mod payu_ui;
mod powertranz; mod powertranz;
mod rapyd; mod rapyd;
mod selenium;
mod shift4; mod shift4;
mod shift4_ui;
mod stax; mod stax;
mod stripe; mod stripe;
mod stripe_ui;
mod trustpay; mod trustpay;
mod trustpay_3ds_ui;
mod tsys; mod tsys;
mod utils; mod utils;
mod wise; mod wise;
mod worldline; mod worldline;
mod worldline_ui;
mod worldpay; mod worldpay;
mod zen; mod zen;
mod zen_ui;

View File

@ -19,10 +19,11 @@ impl utils::Connector for MollieTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.mollie .mollie
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -21,10 +21,11 @@ impl utils::Connector for MultisafepayTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.multisafepay .multisafepay
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -24,10 +24,11 @@ impl utils::Connector for NexinetsTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.nexinets .nexinets
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -20,10 +20,11 @@ impl utils::Connector for NmiTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.nmi .nmi
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -25,10 +25,11 @@ impl utils::Connector for NoonTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.noon .noon
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -26,10 +26,11 @@ impl utils::Connector for NuveiTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.nuvei .nuvei
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -22,10 +22,11 @@ impl utils::Connector for OpayoTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.opayo .opayo
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -21,10 +21,11 @@ impl utils::Connector for OpennodeTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.opennode .opennode
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -28,10 +28,11 @@ impl utils::Connector for PayeezyTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.payeezy .payeezy
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -24,10 +24,11 @@ impl utils::Connector for PaymeTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.payme .payme
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -21,10 +21,11 @@ impl Connector for PaypalTest {
} }
fn get_auth_token(&self) -> ConnectorAuthType { fn get_auth_token(&self) -> ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.paypal .paypal
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -18,10 +18,11 @@ impl Connector for Payu {
} }
fn get_auth_token(&self) -> ConnectorAuthType { fn get_auth_token(&self) -> ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.payu .payu
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -20,10 +20,11 @@ impl utils::Connector for PowertranzTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.powertranz .powertranz
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -23,10 +23,11 @@ impl utils::Connector for Rapyd {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.rapyd .rapyd
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -22,10 +22,11 @@ impl utils::Connector for Shift4Test {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.shift4 .shift4
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -20,10 +20,11 @@ impl utils::Connector for StaxTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.stax .stax
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -21,10 +21,11 @@ impl utils::Connector for Stripe {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.stripe .stripe
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -22,10 +22,11 @@ impl utils::Connector for TrustpayTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.trustpay .trustpay
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -23,10 +23,11 @@ impl utils::Connector for TsysTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.tsys .tsys
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -11,6 +11,7 @@ use router::{
routes, services, routes, services,
types::{self, api, storage::enums, AccessToken, PaymentAddress, RouterData}, types::{self, api, storage::enums, AccessToken, PaymentAddress, RouterData},
}; };
use test_utils::connector_auth::ConnectorAuthType;
use tokio::sync::oneshot; use tokio::sync::oneshot;
use wiremock::{Mock, MockServer}; use wiremock::{Mock, MockServer};
@ -994,3 +995,33 @@ pub fn get_connector_metadata(
_ => None, _ => None,
} }
} }
pub fn to_connector_auth_type(auth_type: ConnectorAuthType) -> types::ConnectorAuthType {
match auth_type {
ConnectorAuthType::HeaderKey { api_key } => types::ConnectorAuthType::HeaderKey { api_key },
ConnectorAuthType::BodyKey { api_key, key1 } => {
types::ConnectorAuthType::BodyKey { api_key, key1 }
}
ConnectorAuthType::SignatureKey {
api_key,
key1,
api_secret,
} => types::ConnectorAuthType::SignatureKey {
api_key,
key1,
api_secret,
},
ConnectorAuthType::MultiAuthKey {
api_key,
key1,
api_secret,
key2,
} => types::ConnectorAuthType::MultiAuthKey {
api_key,
key1,
api_secret,
key2,
},
_ => types::ConnectorAuthType::NoKey,
}
}

View File

@ -29,10 +29,11 @@ impl utils::Connector for WiseTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.wise .wise
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -26,10 +26,11 @@ impl utils::Connector for WorldlineTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
ConnectorAuthentication::new() ConnectorAuthentication::new()
.worldline .worldline
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -27,10 +27,11 @@ impl utils::Connector for Worldpay {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.worldpay .worldpay
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -25,10 +25,11 @@ impl utils::Connector for ZenTest {
} }
fn get_auth_token(&self) -> types::ConnectorAuthType { fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::from( utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new() connector_auth::ConnectorAuthentication::new()
.zen .zen
.expect("Missing connector authentication configuration"), .expect("Missing connector authentication configuration")
.into(),
) )
} }

View File

@ -13,13 +13,24 @@ dummy_connector = ["api_models/dummy_connector"]
payouts = [] payouts = []
[dependencies] [dependencies]
clap = { version = "4.3.2", default-features = false, features = ["derive"] } async-trait = "0.1.68"
actix-web = "4.3.1"
clap = { version = "4.3.2", default-features = false, features = ["std", "derive", "help", "usage"] }
serde = { version = "1.0.163", features = ["derive"] } serde = { version = "1.0.163", features = ["derive"] }
serde_json = "1.0.96" serde_json = "1.0.96"
serde_path_to_error = "0.1.11" serde_path_to_error = "0.1.11"
toml = "0.7.4" toml = "0.7.4"
serial_test = "2.0.0"
serde_urlencoded = "0.7.1"
actix-http = "3.3.1"
awc = { version = "3.1.1", features = ["rustls"] }
derive_deref = "1.1.1"
rand = "0.8.5"
thirtyfour = "0.31.0"
time = { version = "0.3.21", features = ["macros"] }
tokio = "1.28.2"
uuid = { version = "1.3.3", features = ["serde", "v4"] }
# First party crates # First party crates
router = { version = "0.2.0", path = "../router" }
api_models = { version = "0.1.0", path = "../api_models", features = ["errors"] } api_models = { version = "0.1.0", path = "../api_models", features = ["errors"] }
masking = { version = "0.1.0", path = "../masking" } masking = { version = "0.1.0", path = "../masking" }

View File

@ -1,7 +1,6 @@
use std::{collections::HashMap, env}; use std::{collections::HashMap, env};
use masking::Secret; use masking::Secret;
use router::types::ConnectorAuthType;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]
@ -289,3 +288,28 @@ pub struct AutomationConfigs {
pub adyen_bancontact_username: Option<String>, pub adyen_bancontact_username: Option<String>,
pub adyen_bancontact_pass: Option<String>, pub adyen_bancontact_pass: Option<String>,
} }
#[derive(Default, Debug, Clone, serde::Deserialize)]
#[serde(tag = "auth_type")]
pub enum ConnectorAuthType {
HeaderKey {
api_key: Secret<String>,
},
BodyKey {
api_key: Secret<String>,
key1: Secret<String>,
},
SignatureKey {
api_key: Secret<String>,
key1: Secret<String>,
api_secret: Secret<String>,
},
MultiAuthKey {
api_key: Secret<String>,
key1: Secret<String>,
api_secret: Secret<String>,
key2: Secret<String>,
},
#[default]
NoKey,
}

View File

@ -5,8 +5,7 @@ use std::{
use clap::{arg, command, Parser}; use clap::{arg, command, Parser};
use masking::PeekInterface; use masking::PeekInterface;
use router::types::ConnectorAuthType; use test_utils::connector_auth::{ConnectorAuthType, ConnectorAuthenticationMap};
use test_utils::connector_auth::ConnectorAuthenticationMap;
// Just by the name of the connector, this function generates the name of the collection // Just by the name of the connector, this function generates the name of the collection
// Example: CONNECTOR_NAME="stripe" -> OUTPUT: postman/stripe.postman_collection.json // Example: CONNECTOR_NAME="stripe" -> OUTPUT: postman/stripe.postman_collection.json

View File

@ -0,0 +1,27 @@
#![allow(
clippy::expect_used,
clippy::panic,
clippy::unwrap_in_result,
clippy::unwrap_used
)]
mod aci_ui;
mod adyen_uk_ui;
mod airwallex_ui;
mod authorizedotnet_ui;
mod bambora_ui;
mod bluesnap_ui;
mod checkout_ui;
mod globalpay_ui;
mod mollie_ui;
mod multisafepay_ui;
mod nexinets_ui;
mod noon_ui;
mod nuvei_ui;
mod paypal_ui;
mod payu_ui;
mod selenium;
mod shift4_ui;
mod stripe_ui;
mod trustpay_3ds_ui;
mod worldline_ui;
mod zen_ui;

View File

@ -1,3 +1,10 @@
#![allow(
clippy::expect_used,
clippy::panic,
clippy::unwrap_in_result,
clippy::missing_panics_doc,
clippy::unwrap_used
)]
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
env, env,
@ -8,10 +15,9 @@ use std::{
use async_trait::async_trait; use async_trait::async_trait;
use serde_json::json; use serde_json::json;
use test_utils::connector_auth;
use thirtyfour::{components::SelectElement, prelude::*, WebDriver}; use thirtyfour::{components::SelectElement, prelude::*, WebDriver};
use crate::connector_auth;
#[derive(Clone)] #[derive(Clone)]
pub enum Event<'a> { pub enum Event<'a> {
RunIf(Assert<'a>, Vec<Event<'a>>), RunIf(Assert<'a>, Vec<Event<'a>>),
@ -729,7 +735,6 @@ pub fn should_ignore_test(name: &str) -> bool {
.clone(); .clone();
let tests_to_ignore: HashSet<String> = let tests_to_ignore: HashSet<String> =
serde_json::from_value(conf).unwrap_or_else(|_| HashSet::new()); serde_json::from_value(conf).unwrap_or_else(|_| HashSet::new());
// let tests_to_ignore = conf.automation_configs.unwrap().tests_to_ignore.unwrap_or_else(|| HashSet::new());
let modules: Vec<_> = name.split("::").collect(); let modules: Vec<_> = name.split("::").collect();
let file_match = format!("{}::*", <&str>::clone(&modules[1])); let file_match = format!("{}::*", <&str>::clone(&modules[1]));
let module_name = modules[1..3].join("::"); let module_name = modules[1..3].join("::");
@ -741,6 +746,7 @@ pub fn get_browser() -> String {
"firefox".to_string() "firefox".to_string()
} }
// based on the browser settings build profile info
pub fn make_capabilities(browser: &str) -> Capabilities { pub fn make_capabilities(browser: &str) -> Capabilities {
match browser { match browser {
"firefox" => { "firefox" => {

View File

@ -0,0 +1,170 @@
# Copy this file and rename it as `auth.toml`
# Each of the connector's section is optional
[aci]
api_key = "Bearer MyApiKey"
key1 = "MyEntityId"
[adyen]
api_key = "Bearer MyApiKey"
key1 = "MerchantId"
api_secret = "Secondary key"
[authorizedotnet]
api_key = "MyMerchantName"
key1 = "MyTransactionKey"
[checkout]
api_key = "PublicKey"
api_secret = "SecretKey"
key1 = "MyProcessingChannelId"
[cybersource]
api_key = "Bearer MyApiKey"
key1 = "Merchant id"
api_secret = "Secret key"
[shift4]
api_key = "Bearer MyApiKey"
[worldpay]
api_key = "api_key"
key1 = "key1"
[payu]
api_key = "Bearer MyApiKey"
key1 = "MerchantPosId"
[globalpay]
api_key = "api_key"
key1 = "key1"
[rapyd]
api_key = "access_key"
key1 = "secret_key"
[fiserv]
api_key = "MyApiKey"
key1 = "MerchantID"
api_secret = "MySecretKey"
[worldline]
key1 = "Merchant Id"
api_key = "API Key"
api_secret = "API Secret Key"
[multisafepay]
api_key = "API Key"
[dlocal]
key1 = "key1"
api_key = "api_key"
api_secret = "secret"
[bambora]
api_key = "api_key"
key1 = "key1"
[nmi]
api_key = "NMI API Key"
[nuvei]
api_key = "api_key"
key1 = "key1"
api_secret = "secret"
[paypal]
api_key = "api_key"
key1 = "key1"
[mollie]
api_key = "API Key"
[forte]
api_key = "api_key"
key1 = "key1"
key2 = "key2"
api_secret = "api_secret"
[coinbase]
api_key = "API Key"
[opennode]
api_key = "API Key"
[nexinets]
api_key = "api_key"
key1 = "key1"
[payeezy]
api_key = "api_key"
key1 = "key1"
api_secret = "secret"
[bitpay]
api_key = "API Key"
[iatapay]
key1 = "key1"
api_key = "api_key"
api_secret = "secrect"
[dummyconnector]
api_key = "API Key"
[noon]
api_key = "Application API KEY"
api_secret = "Application Identifier"
key1 = "Business Identifier"
[opayo]
api_key="API Key"
[wise]
api_key = "API Key"
key1 = "Profile ID"
[automation_configs]
hs_base_url="http://localhost:8080"
hs_test_browser="firefox"
chrome_profile_path=""
firefox_profile_path=""
pypl_email=""
pypl_pass=""
gmail_email=""
gmail_pass=""
[payme]
# Open api key
api_key="seller payme id"
key1="payme client key"
[cryptopay]
api_key = "api_key"
key1 = "key1"
[cashtocode]
api_key="Classic PMT API Key"
key1 = "Evoucher PMT API Key"
[tsys]
api_key="device id"
key1 = "transaction key"
api_secret = "developer id"
[globepay]
api_key = "Partner code"
key1 = "Credential code"
[powertranz]
api_key="PowerTranz-PowerTranzPassword"
key1 = "PowerTranz-PowerTranzId"
[stax]
api_key="API Key"
[boku]
api_key="API Key"
key1 = "transaction key"