ci(runner): rewrite collection_runner.sh in rust (#1604)

This commit is contained in:
Pa1NarK
2023-07-10 15:02:44 +05:30
committed by GitHub
parent 69454ec55c
commit e09077a75f
17 changed files with 496 additions and 240 deletions

View File

@ -114,6 +114,9 @@ tokio = "1.28.2"
toml = "0.7.4"
wiremock = "0.5"
# First party dev-dependencies
test_utils = { version = "0.1.0", path = "../test_utils" }
[[bin]]
name = "router"
path = "src/bin/router.rs"

View File

@ -1,149 +0,0 @@
use std::env;
use router::types::ConnectorAuthType;
use serde::{Deserialize, Serialize};
#[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>,
pub bitpay: Option<HeaderKey>,
pub bluesnap: Option<BodyKey>,
pub cashtocode: Option<BodyKey>,
pub checkout: Option<SignatureKey>,
pub coinbase: Option<HeaderKey>,
pub cryptopay: Option<BodyKey>,
pub cybersource: Option<SignatureKey>,
pub dlocal: Option<SignatureKey>,
#[cfg(feature = "dummy_connector")]
pub dummyconnector: Option<HeaderKey>,
pub fiserv: Option<SignatureKey>,
pub forte: Option<MultiAuthKey>,
pub globalpay: Option<BodyKey>,
pub globepay: Option<HeaderKey>,
pub iatapay: Option<SignatureKey>,
pub mollie: Option<HeaderKey>,
pub multisafepay: Option<HeaderKey>,
pub nexinets: Option<BodyKey>,
pub noon: Option<SignatureKey>,
pub nmi: Option<HeaderKey>,
pub nuvei: Option<SignatureKey>,
pub opayo: Option<HeaderKey>,
pub opennode: Option<HeaderKey>,
pub payeezy: Option<SignatureKey>,
pub payme: Option<BodyKey>,
pub paypal: Option<BodyKey>,
pub payu: Option<BodyKey>,
pub powertranz: Option<HeaderKey>,
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 {
#[allow(clippy::expect_used)]
pub(crate) fn new() -> Self {
// before running tests
let path = env::var("CONNECTOR_AUTH_FILE_PATH")
.expect("connector authentication file path not set");
toml::from_str(
&std::fs::read_to_string(path).expect("connector authentication config file not found"),
)
.expect("Failed to read connector authentication config file")
}
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct HeaderKey {
pub api_key: String,
}
impl From<HeaderKey> for ConnectorAuthType {
fn from(key: HeaderKey) -> Self {
Self::HeaderKey {
api_key: key.api_key,
}
}
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct BodyKey {
pub api_key: String,
pub key1: String,
}
impl From<BodyKey> for ConnectorAuthType {
fn from(key: BodyKey) -> Self {
Self::BodyKey {
api_key: key.api_key,
key1: key.key1,
}
}
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct SignatureKey {
pub api_key: String,
pub key1: String,
pub api_secret: String,
}
impl From<SignatureKey> for ConnectorAuthType {
fn from(key: SignatureKey) -> Self {
Self::SignatureKey {
api_key: key.api_key,
key1: key.key1,
api_secret: key.api_secret,
}
}
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct MultiAuthKey {
pub api_key: String,
pub key1: String,
pub api_secret: String,
pub key2: String,
}
impl From<MultiAuthKey> for ConnectorAuthType {
fn from(key: MultiAuthKey) -> Self {
Self::MultiAuthKey {
api_key: key.api_key,
key1: key.key1,
api_secret: key.api_secret,
key2: key.key2,
}
}
}
#[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 bluesnap_gateway_merchant_id: Option<String>,
pub globalpay_gateway_merchant_id: Option<String>,
pub run_minimum_steps: Option<bool>,
pub airwallex_merchant_name: Option<String>,
}

View File

@ -3,11 +3,9 @@ use std::str::FromStr;
use cards::CardNumber;
use masking::Secret;
use router::types::{self, api, storage::enums};
use test_utils::connector_auth;
use crate::{
connector_auth,
utils::{self, ConnectorActions},
};
use crate::utils::{self, ConnectorActions};
#[derive(Clone, Copy)]
struct DummyConnectorTest;

View File

@ -4,6 +4,7 @@
clippy::unwrap_in_result,
clippy::unwrap_used
)]
use test_utils::connector_auth;
mod aci;
mod adyen;
@ -20,7 +21,6 @@ mod cashtocode;
mod checkout;
mod checkout_ui;
mod coinbase;
mod connector_auth;
mod cryptopay;
mod cybersource;
mod dlocal;

View File

@ -1,13 +1,8 @@
#![allow(clippy::unwrap_used)]
mod utils;
#[allow(dead_code)]
mod auth {
include!("connectors/connector_auth.rs");
}
use auth::ConnectorAuthentication;
use masking::PeekInterface;
use test_utils::connector_auth::ConnectorAuthentication;
use utils::{mk_service, ApiKey, AppClient, MerchantId, PaymentId, Status};
/// Example of unit test
@ -77,7 +72,7 @@ async fn partial_refund() {
&server,
&merchant_id,
"stripe",
&authentication.checkout.unwrap().api_key,
authentication.checkout.unwrap().api_key.peek(),
)
.await;
@ -143,7 +138,7 @@ async fn exceed_refund() {
&server,
&merchant_id,
"stripe",
&authentication.checkout.unwrap().api_key,
authentication.checkout.unwrap().api_key.peek(),
)
.await;