diff --git a/.github/scripts/run_ui_tests.sh b/.github/scripts/run_ui_tests.sh index 17cc79bc7c..5c7a0200dd 100644 --- a/.github/scripts/run_ui_tests.sh +++ b/.github/scripts/run_ui_tests.sh @@ -37,6 +37,6 @@ done IN="$INPUT" 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 cat tests/test_results.log \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 0d6070a128..8adfa95d7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -446,9 +446,9 @@ dependencies = [ [[package]] name = "async-channel" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", "event-listener", @@ -4733,14 +4733,25 @@ dependencies = [ name = "test_utils" version = "0.1.0" dependencies = [ + "actix-http", + "actix-web", "api_models", + "async-trait", + "awc", "clap", + "derive_deref", "masking", - "router", + "rand 0.8.5", "serde", "serde_json", "serde_path_to_error", + "serde_urlencoded", + "serial_test", + "thirtyfour", + "time 0.3.22", + "tokio", "toml 0.7.4", + "uuid", ] [[package]] diff --git a/connector-template/test.rs b/connector-template/test.rs index 008e3d50dc..5bbf761dea 100644 --- a/connector-template/test.rs +++ b/connector-template/test.rs @@ -21,10 +21,10 @@ impl utils::Connector for {{project-name | downcase | pascal_case}}Test { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .{{project-name | downcase}} - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration").into(), ) } diff --git a/crates/router/tests/connectors/aci.rs b/crates/router/tests/connectors/aci.rs index d82c3eff6f..e75553b23b 100644 --- a/crates/router/tests/connectors/aci.rs +++ b/crates/router/tests/connectors/aci.rs @@ -11,7 +11,7 @@ use router::{ }; use tokio::sync::oneshot; -use crate::connector_auth::ConnectorAuthentication; +use crate::{connector_auth::ConnectorAuthentication, utils}; fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData { let auth = ConnectorAuthentication::new() @@ -28,7 +28,7 @@ fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData { status: enums::AttemptStatus::default(), auth_type: enums::AuthenticationType::NoThreeDs, 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()), return_url: None, request: types::PaymentsAuthorizeData { @@ -105,7 +105,7 @@ fn construct_refund_router_data() -> types::RefundsRouterData { status: enums::AttemptStatus::default(), payment_method: enums::PaymentMethod::Card, 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()), return_url: None, request: types::RefundsData { diff --git a/crates/router/tests/connectors/adyen.rs b/crates/router/tests/connectors/adyen.rs index 886069e3c4..68d641e5ec 100644 --- a/crates/router/tests/connectors/adyen.rs +++ b/crates/router/tests/connectors/adyen.rs @@ -32,10 +32,11 @@ impl utils::Connector for AdyenTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .adyen_uk - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/airwallex.rs b/crates/router/tests/connectors/airwallex.rs index 014c030827..7d9070a94d 100644 --- a/crates/router/tests/connectors/airwallex.rs +++ b/crates/router/tests/connectors/airwallex.rs @@ -25,10 +25,11 @@ impl Connector for AirwallexTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .airwallex - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/authorizedotnet.rs b/crates/router/tests/connectors/authorizedotnet.rs index 1e409e68f5..125851d0be 100644 --- a/crates/router/tests/connectors/authorizedotnet.rs +++ b/crates/router/tests/connectors/authorizedotnet.rs @@ -22,10 +22,11 @@ impl utils::Connector for AuthorizedotnetTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .authorizedotnet - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/bambora.rs b/crates/router/tests/connectors/bambora.rs index ed9c7c221a..a6dd7d17b0 100644 --- a/crates/router/tests/connectors/bambora.rs +++ b/crates/router/tests/connectors/bambora.rs @@ -23,10 +23,11 @@ impl utils::Connector for BamboraTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .bambora - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/bitpay.rs b/crates/router/tests/connectors/bitpay.rs index 615582b751..1eaf1580f0 100644 --- a/crates/router/tests/connectors/bitpay.rs +++ b/crates/router/tests/connectors/bitpay.rs @@ -21,10 +21,11 @@ impl utils::Connector for BitpayTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .bitpay - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/bluesnap.rs b/crates/router/tests/connectors/bluesnap.rs index 78e12cfb5a..ea3fe9a1fe 100644 --- a/crates/router/tests/connectors/bluesnap.rs +++ b/crates/router/tests/connectors/bluesnap.rs @@ -25,10 +25,11 @@ impl utils::Connector for BluesnapTest { } fn get_auth_token(&self) -> ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .bluesnap - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/boku.rs b/crates/router/tests/connectors/boku.rs index c5e450803e..132852f904 100644 --- a/crates/router/tests/connectors/boku.rs +++ b/crates/router/tests/connectors/boku.rs @@ -18,10 +18,11 @@ impl utils::Connector for BokuTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .boku - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/cashtocode.rs b/crates/router/tests/connectors/cashtocode.rs index e07e54c54b..c78134a1d6 100644 --- a/crates/router/tests/connectors/cashtocode.rs +++ b/crates/router/tests/connectors/cashtocode.rs @@ -20,10 +20,11 @@ impl utils::Connector for CashtocodeTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .cashtocode - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/checkout.rs b/crates/router/tests/connectors/checkout.rs index bd11a43236..18d6d6d2dd 100644 --- a/crates/router/tests/connectors/checkout.rs +++ b/crates/router/tests/connectors/checkout.rs @@ -19,10 +19,11 @@ impl utils::Connector for CheckoutTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .checkout - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/coinbase.rs b/crates/router/tests/connectors/coinbase.rs index e811f4935b..dc677c6e31 100644 --- a/crates/router/tests/connectors/coinbase.rs +++ b/crates/router/tests/connectors/coinbase.rs @@ -22,10 +22,11 @@ impl utils::Connector for CoinbaseTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .coinbase - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/cryptopay.rs b/crates/router/tests/connectors/cryptopay.rs index 597e394e70..d862841599 100644 --- a/crates/router/tests/connectors/cryptopay.rs +++ b/crates/router/tests/connectors/cryptopay.rs @@ -21,10 +21,11 @@ impl utils::Connector for CryptopayTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .cryptopay - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/cybersource.rs b/crates/router/tests/connectors/cybersource.rs index 438c7f8b94..bcc5aaa2a2 100644 --- a/crates/router/tests/connectors/cybersource.rs +++ b/crates/router/tests/connectors/cybersource.rs @@ -23,10 +23,11 @@ impl utils::Connector for Cybersource { } } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .cybersource - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } fn get_name(&self) -> String { diff --git a/crates/router/tests/connectors/dlocal.rs b/crates/router/tests/connectors/dlocal.rs index d58e2b6ea6..05d42ef7fe 100644 --- a/crates/router/tests/connectors/dlocal.rs +++ b/crates/router/tests/connectors/dlocal.rs @@ -23,10 +23,11 @@ impl utils::Connector for DlocalTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .dlocal - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/dummyconnector.rs b/crates/router/tests/connectors/dummyconnector.rs index 35e68e99f8..7efaa83295 100644 --- a/crates/router/tests/connectors/dummyconnector.rs +++ b/crates/router/tests/connectors/dummyconnector.rs @@ -21,10 +21,11 @@ impl utils::Connector for DummyConnectorTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .dummyconnector - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/fiserv.rs b/crates/router/tests/connectors/fiserv.rs index 91cbfc334f..532084a746 100644 --- a/crates/router/tests/connectors/fiserv.rs +++ b/crates/router/tests/connectors/fiserv.rs @@ -23,10 +23,11 @@ impl utils::Connector for FiservTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .fiserv - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/forte.rs b/crates/router/tests/connectors/forte.rs index 6028f44117..456c7a7e14 100644 --- a/crates/router/tests/connectors/forte.rs +++ b/crates/router/tests/connectors/forte.rs @@ -23,10 +23,11 @@ impl utils::Connector for ForteTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .forte - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/globalpay.rs b/crates/router/tests/connectors/globalpay.rs index 598b66eda0..39e0ed58f4 100644 --- a/crates/router/tests/connectors/globalpay.rs +++ b/crates/router/tests/connectors/globalpay.rs @@ -23,10 +23,11 @@ impl Connector for Globalpay { } fn get_auth_token(&self) -> ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .globalpay - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/globepay.rs b/crates/router/tests/connectors/globepay.rs index 54d9c3eaf8..607abac738 100644 --- a/crates/router/tests/connectors/globepay.rs +++ b/crates/router/tests/connectors/globepay.rs @@ -20,10 +20,11 @@ impl utils::Connector for GlobepayTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .globepay - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/iatapay.rs b/crates/router/tests/connectors/iatapay.rs index 8d318a4fa5..c1f4492bce 100644 --- a/crates/router/tests/connectors/iatapay.rs +++ b/crates/router/tests/connectors/iatapay.rs @@ -22,10 +22,11 @@ impl Connector for IatapayTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .iatapay - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rs index 07fb516205..5fa7ebdb2c 100644 --- a/crates/router/tests/connectors/main.rs +++ b/crates/router/tests/connectors/main.rs @@ -7,22 +7,15 @@ use test_utils::connector_auth; mod aci; -mod aci_ui; mod adyen; -mod adyen_uk_ui; mod airwallex; -mod airwallex_ui; mod authorizedotnet; -mod authorizedotnet_ui; mod bambora; -mod bambora_ui; mod bitpay; mod bluesnap; -mod bluesnap_ui; mod boku; mod cashtocode; mod checkout; -mod checkout_ui; mod coinbase; mod cryptopay; mod cybersource; @@ -32,43 +25,29 @@ mod dummyconnector; mod fiserv; mod forte; mod globalpay; -mod globalpay_ui; mod globepay; mod iatapay; mod mollie; -mod mollie_ui; mod multisafepay; -mod multisafepay_ui; mod nexinets; -mod nexinets_ui; mod nmi; mod noon; -mod noon_ui; mod nuvei; -mod nuvei_ui; mod opayo; mod opennode; mod payeezy; mod payme; mod paypal; -mod paypal_ui; mod payu; -mod payu_ui; mod powertranz; mod rapyd; -mod selenium; mod shift4; -mod shift4_ui; mod stax; mod stripe; -mod stripe_ui; mod trustpay; -mod trustpay_3ds_ui; mod tsys; mod utils; mod wise; mod worldline; -mod worldline_ui; mod worldpay; mod zen; -mod zen_ui; diff --git a/crates/router/tests/connectors/mollie.rs b/crates/router/tests/connectors/mollie.rs index e52736fd5b..e5a1f090d3 100644 --- a/crates/router/tests/connectors/mollie.rs +++ b/crates/router/tests/connectors/mollie.rs @@ -19,10 +19,11 @@ impl utils::Connector for MollieTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .mollie - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/multisafepay.rs b/crates/router/tests/connectors/multisafepay.rs index 53517d0158..a5d9dda922 100644 --- a/crates/router/tests/connectors/multisafepay.rs +++ b/crates/router/tests/connectors/multisafepay.rs @@ -21,10 +21,11 @@ impl utils::Connector for MultisafepayTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .multisafepay - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/nexinets.rs b/crates/router/tests/connectors/nexinets.rs index 662ce7ebbd..21380c27a6 100644 --- a/crates/router/tests/connectors/nexinets.rs +++ b/crates/router/tests/connectors/nexinets.rs @@ -24,10 +24,11 @@ impl utils::Connector for NexinetsTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .nexinets - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/nmi.rs b/crates/router/tests/connectors/nmi.rs index 0727ef8da3..42301dc3a2 100644 --- a/crates/router/tests/connectors/nmi.rs +++ b/crates/router/tests/connectors/nmi.rs @@ -20,10 +20,11 @@ impl utils::Connector for NmiTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .nmi - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/noon.rs b/crates/router/tests/connectors/noon.rs index c426d977c3..01a38fcd78 100644 --- a/crates/router/tests/connectors/noon.rs +++ b/crates/router/tests/connectors/noon.rs @@ -25,10 +25,11 @@ impl utils::Connector for NoonTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .noon - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/nuvei.rs b/crates/router/tests/connectors/nuvei.rs index 564ca5c4ca..d0f8fbaa93 100644 --- a/crates/router/tests/connectors/nuvei.rs +++ b/crates/router/tests/connectors/nuvei.rs @@ -26,10 +26,11 @@ impl utils::Connector for NuveiTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .nuvei - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/opayo.rs b/crates/router/tests/connectors/opayo.rs index fa3e8a44dd..23b1098e27 100644 --- a/crates/router/tests/connectors/opayo.rs +++ b/crates/router/tests/connectors/opayo.rs @@ -22,10 +22,11 @@ impl utils::Connector for OpayoTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .opayo - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/opennode.rs b/crates/router/tests/connectors/opennode.rs index 8d43d6dcc7..79fadf3e13 100644 --- a/crates/router/tests/connectors/opennode.rs +++ b/crates/router/tests/connectors/opennode.rs @@ -21,10 +21,11 @@ impl utils::Connector for OpennodeTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .opennode - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/payeezy.rs b/crates/router/tests/connectors/payeezy.rs index 7fa14bdf93..66d81a6770 100644 --- a/crates/router/tests/connectors/payeezy.rs +++ b/crates/router/tests/connectors/payeezy.rs @@ -28,10 +28,11 @@ impl utils::Connector for PayeezyTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .payeezy - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/payme.rs b/crates/router/tests/connectors/payme.rs index ad3b7d8cf7..67e7919caf 100644 --- a/crates/router/tests/connectors/payme.rs +++ b/crates/router/tests/connectors/payme.rs @@ -24,10 +24,11 @@ impl utils::Connector for PaymeTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .payme - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/paypal.rs b/crates/router/tests/connectors/paypal.rs index b177ed4efb..7a6d1b4866 100644 --- a/crates/router/tests/connectors/paypal.rs +++ b/crates/router/tests/connectors/paypal.rs @@ -21,10 +21,11 @@ impl Connector for PaypalTest { } fn get_auth_token(&self) -> ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .paypal - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/payu.rs b/crates/router/tests/connectors/payu.rs index ad3b1ed920..f1030092a4 100644 --- a/crates/router/tests/connectors/payu.rs +++ b/crates/router/tests/connectors/payu.rs @@ -18,10 +18,11 @@ impl Connector for Payu { } fn get_auth_token(&self) -> ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .payu - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/powertranz.rs b/crates/router/tests/connectors/powertranz.rs index acd95cfd11..0f9ce943a4 100644 --- a/crates/router/tests/connectors/powertranz.rs +++ b/crates/router/tests/connectors/powertranz.rs @@ -20,10 +20,11 @@ impl utils::Connector for PowertranzTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .powertranz - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/rapyd.rs b/crates/router/tests/connectors/rapyd.rs index 662e8b5073..4ca7148a9c 100644 --- a/crates/router/tests/connectors/rapyd.rs +++ b/crates/router/tests/connectors/rapyd.rs @@ -23,10 +23,11 @@ impl utils::Connector for Rapyd { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .rapyd - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/shift4.rs b/crates/router/tests/connectors/shift4.rs index 945911e31a..e236d2ad9d 100644 --- a/crates/router/tests/connectors/shift4.rs +++ b/crates/router/tests/connectors/shift4.rs @@ -22,10 +22,11 @@ impl utils::Connector for Shift4Test { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .shift4 - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/stax.rs b/crates/router/tests/connectors/stax.rs index ebf57d53bb..98527d91f3 100644 --- a/crates/router/tests/connectors/stax.rs +++ b/crates/router/tests/connectors/stax.rs @@ -20,10 +20,11 @@ impl utils::Connector for StaxTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .stax - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/stripe.rs b/crates/router/tests/connectors/stripe.rs index 64f545d22c..5e0c1dae36 100644 --- a/crates/router/tests/connectors/stripe.rs +++ b/crates/router/tests/connectors/stripe.rs @@ -21,10 +21,11 @@ impl utils::Connector for Stripe { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .stripe - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/trustpay.rs b/crates/router/tests/connectors/trustpay.rs index 7ce38336da..cefc0f5ab1 100644 --- a/crates/router/tests/connectors/trustpay.rs +++ b/crates/router/tests/connectors/trustpay.rs @@ -22,10 +22,11 @@ impl utils::Connector for TrustpayTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .trustpay - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/tsys.rs b/crates/router/tests/connectors/tsys.rs index 51112b4724..51d0575a7a 100644 --- a/crates/router/tests/connectors/tsys.rs +++ b/crates/router/tests/connectors/tsys.rs @@ -23,10 +23,11 @@ impl utils::Connector for TsysTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .tsys - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs index 1bffcb36fa..929240ff96 100644 --- a/crates/router/tests/connectors/utils.rs +++ b/crates/router/tests/connectors/utils.rs @@ -11,6 +11,7 @@ use router::{ routes, services, types::{self, api, storage::enums, AccessToken, PaymentAddress, RouterData}, }; +use test_utils::connector_auth::ConnectorAuthType; use tokio::sync::oneshot; use wiremock::{Mock, MockServer}; @@ -994,3 +995,33 @@ pub fn get_connector_metadata( _ => 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, + } +} diff --git a/crates/router/tests/connectors/wise.rs b/crates/router/tests/connectors/wise.rs index 1857a79065..fad3a73caf 100644 --- a/crates/router/tests/connectors/wise.rs +++ b/crates/router/tests/connectors/wise.rs @@ -29,10 +29,11 @@ impl utils::Connector for WiseTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .wise - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/worldline.rs b/crates/router/tests/connectors/worldline.rs index 164240dabf..ac717ecb2a 100644 --- a/crates/router/tests/connectors/worldline.rs +++ b/crates/router/tests/connectors/worldline.rs @@ -26,10 +26,11 @@ impl utils::Connector for WorldlineTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( ConnectorAuthentication::new() .worldline - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/worldpay.rs b/crates/router/tests/connectors/worldpay.rs index 48f87d9c76..a7e0f19af7 100644 --- a/crates/router/tests/connectors/worldpay.rs +++ b/crates/router/tests/connectors/worldpay.rs @@ -27,10 +27,11 @@ impl utils::Connector for Worldpay { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .worldpay - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/router/tests/connectors/zen.rs b/crates/router/tests/connectors/zen.rs index d79c0f4ebf..5a73b0befa 100644 --- a/crates/router/tests/connectors/zen.rs +++ b/crates/router/tests/connectors/zen.rs @@ -25,10 +25,11 @@ impl utils::Connector for ZenTest { } fn get_auth_token(&self) -> types::ConnectorAuthType { - types::ConnectorAuthType::from( + utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .zen - .expect("Missing connector authentication configuration"), + .expect("Missing connector authentication configuration") + .into(), ) } diff --git a/crates/test_utils/Cargo.toml b/crates/test_utils/Cargo.toml index 35c58c8efc..7044bc0279 100644 --- a/crates/test_utils/Cargo.toml +++ b/crates/test_utils/Cargo.toml @@ -13,13 +13,24 @@ dummy_connector = ["api_models/dummy_connector"] payouts = [] [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_json = "1.0.96" serde_path_to_error = "0.1.11" 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 -router = { version = "0.2.0", path = "../router" } api_models = { version = "0.1.0", path = "../api_models", features = ["errors"] } masking = { version = "0.1.0", path = "../masking" } diff --git a/crates/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rs index 5f97dc08ad..c19c1ffea8 100644 --- a/crates/test_utils/src/connector_auth.rs +++ b/crates/test_utils/src/connector_auth.rs @@ -1,7 +1,6 @@ use std::{collections::HashMap, env}; use masking::Secret; -use router::types::ConnectorAuthType; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize, Clone)] @@ -289,3 +288,28 @@ pub struct AutomationConfigs { pub adyen_bancontact_username: Option, pub adyen_bancontact_pass: Option, } + +#[derive(Default, Debug, Clone, serde::Deserialize)] +#[serde(tag = "auth_type")] +pub enum ConnectorAuthType { + HeaderKey { + api_key: Secret, + }, + BodyKey { + api_key: Secret, + key1: Secret, + }, + SignatureKey { + api_key: Secret, + key1: Secret, + api_secret: Secret, + }, + MultiAuthKey { + api_key: Secret, + key1: Secret, + api_secret: Secret, + key2: Secret, + }, + #[default] + NoKey, +} diff --git a/crates/test_utils/src/main.rs b/crates/test_utils/src/main.rs index dac0854925..f6b56bffcf 100644 --- a/crates/test_utils/src/main.rs +++ b/crates/test_utils/src/main.rs @@ -5,8 +5,7 @@ use std::{ use clap::{arg, command, Parser}; use masking::PeekInterface; -use router::types::ConnectorAuthType; -use test_utils::connector_auth::ConnectorAuthenticationMap; +use test_utils::connector_auth::{ConnectorAuthType, ConnectorAuthenticationMap}; // 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 diff --git a/crates/router/tests/connectors/aci_ui.rs b/crates/test_utils/tests/connectors/aci_ui.rs similarity index 100% rename from crates/router/tests/connectors/aci_ui.rs rename to crates/test_utils/tests/connectors/aci_ui.rs diff --git a/crates/router/tests/connectors/adyen_uk_ui.rs b/crates/test_utils/tests/connectors/adyen_uk_ui.rs similarity index 100% rename from crates/router/tests/connectors/adyen_uk_ui.rs rename to crates/test_utils/tests/connectors/adyen_uk_ui.rs diff --git a/crates/router/tests/connectors/airwallex_ui.rs b/crates/test_utils/tests/connectors/airwallex_ui.rs similarity index 100% rename from crates/router/tests/connectors/airwallex_ui.rs rename to crates/test_utils/tests/connectors/airwallex_ui.rs diff --git a/crates/router/tests/connectors/authorizedotnet_ui.rs b/crates/test_utils/tests/connectors/authorizedotnet_ui.rs similarity index 100% rename from crates/router/tests/connectors/authorizedotnet_ui.rs rename to crates/test_utils/tests/connectors/authorizedotnet_ui.rs diff --git a/crates/router/tests/connectors/bambora_ui.rs b/crates/test_utils/tests/connectors/bambora_ui.rs similarity index 100% rename from crates/router/tests/connectors/bambora_ui.rs rename to crates/test_utils/tests/connectors/bambora_ui.rs diff --git a/crates/router/tests/connectors/bluesnap_ui.rs b/crates/test_utils/tests/connectors/bluesnap_ui.rs similarity index 100% rename from crates/router/tests/connectors/bluesnap_ui.rs rename to crates/test_utils/tests/connectors/bluesnap_ui.rs diff --git a/crates/router/tests/connectors/checkout_ui.rs b/crates/test_utils/tests/connectors/checkout_ui.rs similarity index 100% rename from crates/router/tests/connectors/checkout_ui.rs rename to crates/test_utils/tests/connectors/checkout_ui.rs diff --git a/crates/router/tests/connectors/globalpay_ui.rs b/crates/test_utils/tests/connectors/globalpay_ui.rs similarity index 100% rename from crates/router/tests/connectors/globalpay_ui.rs rename to crates/test_utils/tests/connectors/globalpay_ui.rs diff --git a/crates/test_utils/tests/connectors/main.rs b/crates/test_utils/tests/connectors/main.rs new file mode 100644 index 0000000000..10e19b94bd --- /dev/null +++ b/crates/test_utils/tests/connectors/main.rs @@ -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; diff --git a/crates/router/tests/connectors/mollie_ui.rs b/crates/test_utils/tests/connectors/mollie_ui.rs similarity index 100% rename from crates/router/tests/connectors/mollie_ui.rs rename to crates/test_utils/tests/connectors/mollie_ui.rs diff --git a/crates/router/tests/connectors/multisafepay_ui.rs b/crates/test_utils/tests/connectors/multisafepay_ui.rs similarity index 100% rename from crates/router/tests/connectors/multisafepay_ui.rs rename to crates/test_utils/tests/connectors/multisafepay_ui.rs diff --git a/crates/router/tests/connectors/nexinets_ui.rs b/crates/test_utils/tests/connectors/nexinets_ui.rs similarity index 100% rename from crates/router/tests/connectors/nexinets_ui.rs rename to crates/test_utils/tests/connectors/nexinets_ui.rs diff --git a/crates/router/tests/connectors/noon_ui.rs b/crates/test_utils/tests/connectors/noon_ui.rs similarity index 100% rename from crates/router/tests/connectors/noon_ui.rs rename to crates/test_utils/tests/connectors/noon_ui.rs diff --git a/crates/router/tests/connectors/nuvei_ui.rs b/crates/test_utils/tests/connectors/nuvei_ui.rs similarity index 100% rename from crates/router/tests/connectors/nuvei_ui.rs rename to crates/test_utils/tests/connectors/nuvei_ui.rs diff --git a/crates/router/tests/connectors/paypal_ui.rs b/crates/test_utils/tests/connectors/paypal_ui.rs similarity index 100% rename from crates/router/tests/connectors/paypal_ui.rs rename to crates/test_utils/tests/connectors/paypal_ui.rs diff --git a/crates/router/tests/connectors/payu_ui.rs b/crates/test_utils/tests/connectors/payu_ui.rs similarity index 100% rename from crates/router/tests/connectors/payu_ui.rs rename to crates/test_utils/tests/connectors/payu_ui.rs diff --git a/crates/router/tests/connectors/selenium.rs b/crates/test_utils/tests/connectors/selenium.rs similarity index 99% rename from crates/router/tests/connectors/selenium.rs rename to crates/test_utils/tests/connectors/selenium.rs index 0f25cc3c9d..3a2b07c42c 100644 --- a/crates/router/tests/connectors/selenium.rs +++ b/crates/test_utils/tests/connectors/selenium.rs @@ -1,3 +1,10 @@ +#![allow( + clippy::expect_used, + clippy::panic, + clippy::unwrap_in_result, + clippy::missing_panics_doc, + clippy::unwrap_used +)] use std::{ collections::{HashMap, HashSet}, env, @@ -8,10 +15,9 @@ use std::{ use async_trait::async_trait; use serde_json::json; +use test_utils::connector_auth; use thirtyfour::{components::SelectElement, prelude::*, WebDriver}; -use crate::connector_auth; - #[derive(Clone)] pub enum Event<'a> { RunIf(Assert<'a>, Vec>), @@ -729,7 +735,6 @@ pub fn should_ignore_test(name: &str) -> bool { .clone(); let tests_to_ignore: HashSet = 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 file_match = format!("{}::*", <&str>::clone(&modules[1])); let module_name = modules[1..3].join("::"); @@ -741,6 +746,7 @@ pub fn get_browser() -> String { "firefox".to_string() } +// based on the browser settings build profile info pub fn make_capabilities(browser: &str) -> Capabilities { match browser { "firefox" => { diff --git a/crates/router/tests/connectors/shift4_ui.rs b/crates/test_utils/tests/connectors/shift4_ui.rs similarity index 100% rename from crates/router/tests/connectors/shift4_ui.rs rename to crates/test_utils/tests/connectors/shift4_ui.rs diff --git a/crates/router/tests/connectors/stripe_ui.rs b/crates/test_utils/tests/connectors/stripe_ui.rs similarity index 100% rename from crates/router/tests/connectors/stripe_ui.rs rename to crates/test_utils/tests/connectors/stripe_ui.rs diff --git a/crates/router/tests/connectors/trustpay_3ds_ui.rs b/crates/test_utils/tests/connectors/trustpay_3ds_ui.rs similarity index 100% rename from crates/router/tests/connectors/trustpay_3ds_ui.rs rename to crates/test_utils/tests/connectors/trustpay_3ds_ui.rs diff --git a/crates/router/tests/connectors/worldline_ui.rs b/crates/test_utils/tests/connectors/worldline_ui.rs similarity index 100% rename from crates/router/tests/connectors/worldline_ui.rs rename to crates/test_utils/tests/connectors/worldline_ui.rs diff --git a/crates/router/tests/connectors/zen_ui.rs b/crates/test_utils/tests/connectors/zen_ui.rs similarity index 100% rename from crates/router/tests/connectors/zen_ui.rs rename to crates/test_utils/tests/connectors/zen_ui.rs diff --git a/crates/test_utils/tests/sample_auth.toml b/crates/test_utils/tests/sample_auth.toml new file mode 100644 index 0000000000..0ae7c40d42 --- /dev/null +++ b/crates/test_utils/tests/sample_auth.toml @@ -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" \ No newline at end of file