id
stringlengths
11
116
type
stringclasses
1 value
granularity
stringclasses
4 values
content
stringlengths
16
477k
metadata
dict
fn_clm_test_utils_get_connector_name_-5724496128537493567
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/paypal_ui // Implementation of PaypalSeleniumTest for SeleniumTest fn get_connector_name(&self) -> String { "paypal".to_string() }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 28, "total_crates": null }
fn_clm_test_utils_should_make_paypal_paypal_wallet_payment_-5724496128537493567
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/paypal_ui async fn should_make_paypal_paypal_wallet_payment( web_driver: WebDriver, ) -> Result<(), WebDriverError> { let conn = PaypalSeleniumTest {}; conn.make_paypal_payment( web_driver, &format!("{CHECKOUT_BASE_URL}/saved/21"), vec![ Event::Trigger(Trigger::Click(By::Css("#payment-submit-btn"))), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::ContainsAny( Selector::QueryParamStr, vec!["status=processing"], )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_paypal_ideal_payment_-5724496128537493567
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/paypal_ui async fn should_make_paypal_ideal_payment(web_driver: WebDriver) -> Result<(), WebDriverError> { let conn = PaypalSeleniumTest {}; conn.make_redirection_payment( web_driver, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/181"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Click(By::Name("Successful"))), Event::Assert(Assert::IsPresent("processing")), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_paypal_giropay_payment_-5724496128537493567
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/paypal_ui async fn should_make_paypal_giropay_payment(web_driver: WebDriver) -> Result<(), WebDriverError> { let conn = PaypalSeleniumTest {}; conn.make_redirection_payment( web_driver, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/233"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Click(By::Name("Successful"))), Event::Assert(Assert::IsPresent("processing")), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_paypal_eps_payment_-5724496128537493567
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/paypal_ui async fn should_make_paypal_eps_payment(web_driver: WebDriver) -> Result<(), WebDriverError> { let conn = PaypalSeleniumTest {}; conn.make_redirection_payment( web_driver, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/234"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Click(By::Name("Successful"))), Event::Assert(Assert::IsPresent("processing")), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_get_connector_name_3311112261264175069
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/checkout_wh_ui // Implementation of CheckoutSeleniumTest for SeleniumTest fn get_connector_name(&self) -> String { "checkout".to_string() }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 28, "total_crates": null }
fn_clm_test_utils_should_make_webhook_3311112261264175069
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/checkout_wh_ui async fn should_make_webhook(web_driver: WebDriver) -> Result<(), WebDriverError> { let conn = CheckoutSeleniumTest {}; conn.make_webhook_test( web_driver, &format!("{CHECKOUT_BASE_URL}/saved/18"), vec![ Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Sleep(8)), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::ContainsAny( Selector::QueryParamStr, vec!["status=succeeded", "status=processing"], )), ], 10, "succeeded", ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_webhook_test_3311112261264175069
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/checkout_wh_ui fn should_make_webhook_test() { tester!(should_make_webhook); }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 0, "total_crates": null }
fn_clm_test_utils_get_connector_name_-5270897743254050819
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/shift4_ui // Implementation of Shift4SeleniumTest for SeleniumTest fn get_connector_name(&self) -> String { "shift4".to_string() }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 28, "total_crates": null }
fn_clm_test_utils_should_make_3ds_payment_-5270897743254050819
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/shift4_ui async fn should_make_3ds_payment(c: WebDriver) -> Result<(), WebDriverError> { let conn = Shift4SeleniumTest {}; conn.make_redirection_payment( c, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/37"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Click(By::ClassName("btn-success"))), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::Contains( Selector::QueryParamStr, "status=succeeded", )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_giropay_payment_-5270897743254050819
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/shift4_ui async fn should_make_giropay_payment(c: WebDriver) -> Result<(), WebDriverError> { let conn = Shift4SeleniumTest {}; conn.make_redirection_payment( c, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/39"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Click(By::ClassName("btn-success"))), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::Contains( Selector::QueryParamStr, "status=succeeded", )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_ideal_payment_-5270897743254050819
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/shift4_ui async fn should_make_ideal_payment(c: WebDriver) -> Result<(), WebDriverError> { let conn = Shift4SeleniumTest {}; conn.make_redirection_payment( c, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/42"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Click(By::ClassName("btn-success"))), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::Contains( Selector::QueryParamStr, "status=succeeded", )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_sofort_payment_-5270897743254050819
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/shift4_ui async fn should_make_sofort_payment(c: WebDriver) -> Result<(), WebDriverError> { let conn = Shift4SeleniumTest {}; conn.make_redirection_payment( c, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/43"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Click(By::ClassName("btn-success"))), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::Contains( Selector::QueryParamStr, "status=succeeded", )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_get_connector_name_-6104544998918903047
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/bluesnap_ui // Implementation of BluesnapSeleniumTest for SeleniumTest fn get_connector_name(&self) -> String { "bluesnap".to_string() }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 28, "total_crates": null }
fn_clm_test_utils_should_make_gpay_payment_-6104544998918903047
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/bluesnap_ui async fn should_make_gpay_payment(driver: WebDriver) -> Result<(), WebDriverError> { let conn = BluesnapSeleniumTest {}; let pub_key = conn .get_configs() .automation_configs .unwrap() .bluesnap_gateway_merchant_id .unwrap(); conn.make_gpay_payment(driver, &format!("{CHECKOUT_BASE_URL}/gpay?gatewayname=bluesnap&gatewaymerchantid={pub_key}&amount=11.00&country=US&currency=USD"), vec![ Event::Assert(Assert::IsPresent("succeeded")), ]).await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 4, "total_crates": null }
fn_clm_test_utils_should_make_3ds_payment_-6104544998918903047
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/bluesnap_ui async fn should_make_3ds_payment(driver: WebDriver) -> Result<(), WebDriverError> { let conn = BluesnapSeleniumTest {}; conn.make_redirection_payment( driver, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/200"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::RunIf( Assert::IsElePresent(By::Id("Cardinal-CCA-IFrame")), vec![ Event::Trigger(Trigger::SwitchFrame(By::Id("Cardinal-CCA-IFrame"))), Event::Assert(Assert::IsPresent("Enter your code below")), Event::Trigger(Trigger::SendKeys(By::Name("challengeDataEntry"), "1234")), Event::Trigger(Trigger::Click(By::ClassName("button.primary"))), ], ), Event::Trigger(Trigger::Sleep(10)), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::Contains( Selector::QueryParamStr, "status=succeeded", )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_3ds_payment_test_-6104544998918903047
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/bluesnap_ui fn should_make_3ds_payment_test() { tester!(should_make_3ds_payment); }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 0, "total_crates": null }
fn_clm_test_utils_should_make_gpay_payment_test_-6104544998918903047
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/bluesnap_ui fn should_make_gpay_payment_test() { tester!(should_make_gpay_payment); }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 0, "total_crates": null }
fn_clm_test_utils_get_connector_name_-3148588395234208451
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/nuvei_ui // Implementation of NuveiSeleniumTest for SeleniumTest fn get_connector_name(&self) -> String { "nuvei".to_string() }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 28, "total_crates": null }
fn_clm_test_utils_should_make_nuvei_3ds_payment_-3148588395234208451
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/nuvei_ui async fn should_make_nuvei_3ds_payment(c: WebDriver) -> Result<(), WebDriverError> { let conn = NuveiSeleniumTest {}; conn.make_redirection_payment(c, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/card?cname=CL-BRW1&ccnum=4000027891380961&expmonth=10&expyear=25&cvv=123&amount=200&country=US&currency=USD"))), Event::Assert(Assert::IsPresent("Expiry Year")), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Query(By::ClassName("title"))), Event::Assert(Assert::Eq(Selector::Title, "ThreeDS ACS Emulator - Challenge Page")), Event::Trigger(Trigger::Click(By::Id("btn1"))), Event::Trigger(Trigger::Click(By::Id("btn5"))), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::Contains(Selector::QueryParamStr, "status=succeeded")), ]).await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_nuvei_3ds_mandate_payment_-3148588395234208451
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/nuvei_ui async fn should_make_nuvei_3ds_mandate_payment(c: WebDriver) -> Result<(), WebDriverError> { let conn = NuveiSeleniumTest {}; conn.make_redirection_payment(c, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/card?cname=CL-BRW1&ccnum=4000027891380961&expmonth=10&expyear=25&cvv=123&amount=200&country=US&currency=USD&setup_future_usage=off_session&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]=in%20sit&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&mandate_data[mandate_type][multi_use][start_date]=2022-09-10T00:00:00Z&mandate_data[mandate_type][multi_use][end_date]=2023-09-10T00:00:00Z&mandate_data[mandate_type][multi_use][metadata][frequency]=13&return_url={CHECKOUT_BASE_URL}/payments"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Query(By::ClassName("title"))), Event::Assert(Assert::Eq(Selector::Title, "ThreeDS ACS Emulator - Challenge Page")), Event::Trigger(Trigger::Click(By::Id("btn1"))), Event::Trigger(Trigger::Click(By::Id("btn5"))), Event::Assert(Assert::IsPresent("succeeded")), Event::Assert(Assert::IsPresent("man_")),//mandate id prefix is present ]).await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_nuvei_gpay_payment_-3148588395234208451
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/nuvei_ui async fn should_make_nuvei_gpay_payment(c: WebDriver) -> Result<(), WebDriverError> { let conn = NuveiSeleniumTest {}; conn.make_gpay_payment(c, &format!("{CHECKOUT_BASE_URL}/gpay?gatewayname=nuveidigital&gatewaymerchantid=googletest&amount=10.00&country=IN&currency=USD"), vec![ Event::Assert(Assert::IsPresent("succeeded")), ]).await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_nuvei_pypl_payment_-3148588395234208451
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/nuvei_ui async fn should_make_nuvei_pypl_payment(c: WebDriver) -> Result<(), WebDriverError> { let conn = NuveiSeleniumTest {}; conn.make_paypal_payment( c, &format!("{CHECKOUT_BASE_URL}/saved/5"), vec![ Event::Trigger(Trigger::Click(By::Id("payment-submit-btn"))), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::ContainsAny( Selector::QueryParamStr, vec!["status=succeeded"], )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_get_connector_name_-1139470203466080039
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/stripe_ui // Implementation of StripeSeleniumTest for SeleniumTest fn get_connector_name(&self) -> String { "stripe".to_string() }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 28, "total_crates": null }
fn_clm_test_utils_should_make_gpay_payment_-1139470203466080039
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/stripe_ui async fn should_make_gpay_payment(c: WebDriver) -> Result<(), WebDriverError> { let conn = StripeSeleniumTest {}; let pub_key = conn .get_configs() .automation_configs .unwrap() .stripe_pub_key .unwrap(); conn.make_gpay_payment(c, &format!("{CHECKOUT_BASE_URL}/gpay?gatewayname=stripe&gpaycustomfields[stripe:version]=2018-10-31&gpaycustomfields[stripe:publishableKey]={pub_key}&amount=70.00&country=US&currency=USD"), vec![ Event::Assert(Assert::IsPresent("succeeded")), ]).await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 4, "total_crates": null }
fn_clm_test_utils_should_make_gpay_mandate_payment_-1139470203466080039
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/stripe_ui async fn should_make_gpay_mandate_payment(c: WebDriver) -> Result<(), WebDriverError> { let conn = StripeSeleniumTest {}; let pub_key = conn .get_configs() .automation_configs .unwrap() .stripe_pub_key .unwrap(); conn.make_gpay_payment(c, &format!("{CHECKOUT_BASE_URL}/gpay?gatewayname=stripe&gpaycustomfields[stripe:version]=2018-10-31&gpaycustomfields[stripe:publishableKey]={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]=700&mandate_data[mandate_type][multi_use][currency]=USD"), vec![ Event::Assert(Assert::IsPresent("succeeded")), Event::Assert(Assert::IsPresent("Mandate ID")), Event::Assert(Assert::IsPresent("man_")),// mandate id starting with man_ Event::Trigger(Trigger::Click(By::Css("#pm-mandate-btn a"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Assert(Assert::IsPresent("succeeded")), ]).await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 4, "total_crates": null }
fn_clm_test_utils_should_make_stripe_klarna_payment_-1139470203466080039
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/stripe_ui async fn should_make_stripe_klarna_payment(c: WebDriver) -> Result<(), WebDriverError> { let conn = StripeSeleniumTest {}; conn.make_redirection_payment( c, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/19"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::SwitchFrame(By::Id("klarna-apf-iframe"))), Event::RunIf( Assert::IsPresent("Let’s verify your phone"), vec![ Event::Trigger(Trigger::SendKeys(By::Id("phone"), "9123456789")), Event::Trigger(Trigger::Click(By::Id("onContinue"))), Event::Trigger(Trigger::SendKeys(By::Id("otp_field"), "123456")), ], ), Event::RunIf( Assert::IsPresent("We've updated our Shopping terms"), vec![Event::Trigger(Trigger::Click(By::Css( "button[data-testid='kaf-button']", )))], ), Event::RunIf( Assert::IsPresent("Pick a plan"), vec![Event::Trigger(Trigger::Click(By::Css( "button[data-testid='pick-plan']", )))], ), Event::Trigger(Trigger::Click(By::Css( "button[data-testid='confirm-and-pay']", ))), Event::RunIf( Assert::IsPresent("Fewer clicks"), vec![Event::Trigger(Trigger::Click(By::Css( "button[data-testid='SmoothCheckoutPopUp:skip']", )))], ), Event::Trigger(Trigger::SwitchTab(Position::Prev)), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::Contains( Selector::QueryParamStr, "status=succeeded", )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 4, "total_crates": null }
fn_clm_test_utils_ould_make_afterpay_payment(c_-1139470203466080039
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/stripe_ui ync fn should_make_afterpay_payment(c: WebDriver) -> Result<(), WebDriverError> { let conn = StripeSeleniumTest {}; conn.make_redirection_payment( c, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/22"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Click(By::Css( "a[class='common-Button common-Button--default']", ))), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::Contains( Selector::QueryParamStr, "status=succeeded", )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 4, "total_crates": null }
fn_clm_test_utils_get_connector_name_1757885151709467177
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/nexinets_ui // Implementation of NexinetsSeleniumTest for SeleniumTest fn get_connector_name(&self) -> String { "nexinets".to_string() }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 28, "total_crates": null }
fn_clm_test_utils_should_make_paypal_payment_1757885151709467177
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/nexinets_ui async fn should_make_paypal_payment(web_driver: WebDriver) -> Result<(), WebDriverError> { let conn = NexinetsSeleniumTest {}; conn.make_redirection_payment( web_driver, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/220"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Click(By::Css( "a.btn.btn-primary.btn-block.margin-bottm-15", ))), Event::Assert(Assert::ContainsAny( Selector::QueryParamStr, vec!["status=succeeded", "status=processing"], )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_3ds_card_payment_1757885151709467177
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/nexinets_ui async fn should_make_3ds_card_payment(web_driver: WebDriver) -> Result<(), WebDriverError> { let conn = NexinetsSeleniumTest {}; conn.make_redirection_payment( web_driver, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/221"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::SwitchFrame(By::Id("threeDSCReqIframe"))), Event::Trigger(Trigger::SendKeys(By::Id("otp"), "1234")), Event::Trigger(Trigger::Click(By::Css("button#sendOtp"))), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::ContainsAny( Selector::QueryParamStr, vec!["status=succeeded", "status=processing"], )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_ideal_payment_1757885151709467177
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/nexinets_ui async fn should_make_ideal_payment(web_driver: WebDriver) -> Result<(), WebDriverError> { let conn = NexinetsSeleniumTest {}; conn.make_redirection_payment( web_driver, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/222"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Click(By::Css( "a.btn.btn-primary.btn-block.margin-bottm-15", ))), Event::Assert(Assert::ContainsAny( Selector::QueryParamStr, vec!["status=succeeded", "status=processing"], )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_paypal_payment_test_1757885151709467177
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/nexinets_ui fn should_make_paypal_payment_test() { tester!(should_make_paypal_payment); }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 0, "total_crates": null }
fn_clm_test_utils_get_connector_name_-3910700106607404100
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/checkout_ui // Implementation of CheckoutSeleniumTest for SeleniumTest fn get_connector_name(&self) -> String { "checkout".to_string() }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 28, "total_crates": null }
fn_clm_test_utils_should_make_frictionless_3ds_payment_-3910700106607404100
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/checkout_ui async fn should_make_frictionless_3ds_payment(c: WebDriver) -> Result<(), WebDriverError> { let mycon = CheckoutSeleniumTest {}; mycon .make_redirection_payment( c, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/18"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Assert(Assert::IsPresent("Google Search")), Event::Trigger(Trigger::Sleep(5)), //url gets updated only after some time, so need this timeout to solve the issue Event::Assert(Assert::ContainsAny( Selector::QueryParamStr, vec!["status=succeeded", "status=processing"], )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_3ds_payment_-3910700106607404100
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/checkout_ui async fn should_make_3ds_payment(c: WebDriver) -> Result<(), WebDriverError> { let mycon = CheckoutSeleniumTest {}; mycon .make_redirection_payment( c, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/20"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Sleep(5)), //url gets updated only after some time, so need this timeout to solve the issue Event::Trigger(Trigger::SwitchFrame(By::Name("cko-3ds2-iframe"))), Event::Trigger(Trigger::SendKeys(By::Id("password"), "Checkout1!")), Event::Trigger(Trigger::Click(By::Id("txtButton"))), Event::Trigger(Trigger::Sleep(2)), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::ContainsAny( Selector::QueryParamStr, vec!["status=succeeded", "status=processing"], )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_gpay_payment_-3910700106607404100
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/checkout_ui async fn should_make_gpay_payment(c: WebDriver) -> Result<(), WebDriverError> { let mycon = CheckoutSeleniumTest {}; mycon .make_redirection_payment( c, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/73"))), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Sleep(10)), //url gets updated only after some time, so need this timeout to solve the issue Event::Trigger(Trigger::SwitchFrame(By::Name("cko-3ds2-iframe"))), Event::Trigger(Trigger::SendKeys(By::Id("password"), "Checkout1!")), Event::Trigger(Trigger::Click(By::Id("txtButton"))), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::ContainsAny( Selector::QueryParamStr, vec!["status=succeeded", "status=processing"], )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_frictionless_3ds_payment_test_-3910700106607404100
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/checkout_ui fn should_make_frictionless_3ds_payment_test() { tester!(should_make_frictionless_3ds_payment); }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 0, "total_crates": null }
fn_clm_test_utils_get_connector_name_3621354900837031761
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/trustpay_3ds_ui // Implementation of TrustpaySeleniumTest for SeleniumTest fn get_connector_name(&self) -> String { "trustpay_3ds".to_string() }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 28, "total_crates": null }
fn_clm_test_utils_should_make_trustpay_3ds_payment_3621354900837031761
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/trustpay_3ds_ui async fn should_make_trustpay_3ds_payment(web_driver: WebDriver) -> Result<(), WebDriverError> { let conn = TrustpaySeleniumTest {}; conn.make_redirection_payment( web_driver, vec![ Event::Trigger(Trigger::Goto(&format!("{CHECKOUT_BASE_URL}/saved/206"))), Event::Trigger(Trigger::Sleep(1)), Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Trigger(Trigger::Click(By::Css( "button.btn.btn-lg.btn-primary.btn-block", ))), Event::Assert(Assert::IsPresent("Google")), Event::Assert(Assert::Contains( Selector::QueryParamStr, "status=succeeded", )), ], ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_trustpay_3ds_payment_test_3621354900837031761
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/trustpay_3ds_ui fn should_make_trustpay_3ds_payment_test() { tester!(should_make_trustpay_3ds_payment); }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 0, "total_crates": null }
fn_clm_test_utils_get_connector_name_7269031417477040166
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/adyen_uk_wh_ui // Implementation of AdyenSeleniumTest for SeleniumTest fn get_connector_name(&self) -> String { "adyen_uk".to_string() }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 28, "total_crates": null }
fn_clm_test_utils_should_make_webhook_7269031417477040166
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/adyen_uk_wh_ui async fn should_make_webhook(web_driver: WebDriver) -> Result<(), WebDriverError> { let conn = AdyenSeleniumTest {}; conn.make_webhook_test( web_driver, &format!("{CHECKOUT_BASE_URL}/saved/104"), vec![ Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))), Event::Assert(Assert::IsPresent("succeeded")), ], 10, "succeeded", ) .await?; Ok(()) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_test_utils_should_make_webhook_test_7269031417477040166
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/tests/connectors/adyen_uk_wh_ui fn should_make_webhook_test() { tester!(should_make_webhook); }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 0, "total_crates": null }
fn_clm_test_utils_new_-657450263411127929
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/src/connector_auth // Implementation of None for ConnectorAuthenticationMap pub fn new() -> Self { // Do `export CONNECTOR_AUTH_FILE_PATH="/hyperswitch/crates/router/tests/connectors/sample_auth.toml"` // before running tests in shell let path = env::var("CONNECTOR_AUTH_FILE_PATH") .expect("connector authentication file path not set"); // Read the file contents to a JsonString let contents = &std::fs::read_to_string(path).expect("Failed to read connector authentication file"); // Deserialize the JsonString to a HashMap let auth_config: HashMap<String, toml::Value> = toml::from_str(contents).expect("Failed to deserialize TOML file"); // auth_config contains the data in below given format: // { // "connector_name": Table( // { // "api_key": String( // "API_Key", // ), // "api_secret": String( // "Secret key", // ), // "key1": String( // "key1", // ), // "key2": String( // "key2", // ), // }, // ), // "connector_name": Table( // ... // } // auth_map refines and extracts required information let auth_map = auth_config .into_iter() .map(|(connector_name, config)| { let auth_type = match config { toml::Value::Table(mut table) => { if let Some(auth_key_map_value) = table.remove("auth_key_map") { // This is a CurrencyAuthKey if let toml::Value::Table(auth_key_map_table) = auth_key_map_value { let mut parsed_auth_map = HashMap::new(); for (currency, val) in auth_key_map_table { if let Ok(currency_enum) = currency.parse::<common_enums::Currency>() { parsed_auth_map .insert(currency_enum, Secret::new(val.to_string())); } } ConnectorAuthType::CurrencyAuthKey { auth_key_map: parsed_auth_map, } } else { ConnectorAuthType::NoKey } } else { match ( table.get("api_key"), table.get("key1"), table.get("api_secret"), table.get("key2"), ) { (Some(api_key), None, None, None) => ConnectorAuthType::HeaderKey { api_key: Secret::new( api_key.as_str().unwrap_or_default().to_string(), ), }, (Some(api_key), Some(key1), None, None) => { ConnectorAuthType::BodyKey { api_key: Secret::new( api_key.as_str().unwrap_or_default().to_string(), ), key1: Secret::new( key1.as_str().unwrap_or_default().to_string(), ), } } (Some(api_key), Some(key1), Some(api_secret), None) => { ConnectorAuthType::SignatureKey { api_key: Secret::new( api_key.as_str().unwrap_or_default().to_string(), ), key1: Secret::new( key1.as_str().unwrap_or_default().to_string(), ), api_secret: Secret::new( api_secret.as_str().unwrap_or_default().to_string(), ), } } (Some(api_key), Some(key1), Some(api_secret), Some(key2)) => { ConnectorAuthType::MultiAuthKey { api_key: Secret::new( api_key.as_str().unwrap_or_default().to_string(), ), key1: Secret::new( key1.as_str().unwrap_or_default().to_string(), ), api_secret: Secret::new( api_secret.as_str().unwrap_or_default().to_string(), ), key2: Secret::new( key2.as_str().unwrap_or_default().to_string(), ), } } _ => ConnectorAuthType::NoKey, } } } _ => ConnectorAuthType::NoKey, }; (connector_name, auth_type) }) .collect(); Self(auth_map) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14575, "total_crates": null }
fn_clm_test_utils_default_-657450263411127929
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/src/connector_auth // Implementation of ConnectorAuthenticationMap for Default fn default() -> Self { Self::new() }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 7705, "total_crates": null }
fn_clm_test_utils_from_-657450263411127929
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/src/connector_auth // Implementation of ConnectorAuthType for From<CurrencyAuthKey> fn from(key: CurrencyAuthKey) -> Self { let mut auth_map = HashMap::new(); for (currency, auth_data) in key.auth_key_map { if let Ok(currency_enum) = currency.parse::<common_enums::Currency>() { auth_map.insert(currency_enum, Secret::new(auth_data.to_string())); } } Self::CurrencyAuthKey { auth_key_map: auth_map, } }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2608, "total_crates": null }
fn_clm_test_utils_inner_-657450263411127929
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/src/connector_auth // Implementation of None for ConnectorAuthenticationMap pub fn inner(&self) -> &HashMap<String, ConnectorAuthType> { &self.0 }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 45, "total_crates": null }
fn_clm_test_utils_generate_newman_command_for_connector_-5044256837976064307
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/src/newman_runner pub fn generate_newman_command_for_connector() -> Result<ReturnArgs> { let args = Args::parse(); let connector_name = args .connector_name .with_context(|| "invalid parameters: connector/module name not found in arguments")?; let base_url = args.base_url; let admin_api_key = args.admin_api_key; let collection_path = get_collection_path(&connector_name); let collection_dir_path = get_dir_path(&connector_name); let auth_map = ConnectorAuthenticationMap::new(); let inner_map = auth_map.inner(); /* Newman runner Certificate keys are added through secrets in CI, so there's no need to explicitly pass it as arguments. It can be overridden by explicitly passing certificates as arguments. If the collection requires certificates (Stripe collection for example) during the merchant connector account create step, then Stripe's certificates will be passed implicitly (for now). If any other connector requires certificates to be passed, that has to be passed explicitly for now. */ let mut newman_command = Command::new("newman"); newman_command.args(["run", &collection_path]); newman_command.args(["--env-var", &format!("admin_api_key={admin_api_key}")]); newman_command.args(["--env-var", &format!("baseUrl={base_url}")]); let custom_header_exist = check_for_custom_headers(args.custom_headers, &collection_dir_path); // validation of connector is needed here as a work around to the limitation of the fork of newman that Hyperswitch uses let (connector_name, modified_collection_file_paths) = check_connector_for_dynamic_amount(&connector_name); if let Some(auth_type) = inner_map.get(connector_name) { match auth_type { ConnectorAuthType::HeaderKey { api_key } => { newman_command.args([ "--env-var", &format!("connector_api_key={}", api_key.peek()), ]); } ConnectorAuthType::BodyKey { api_key, key1 } => { newman_command.args([ "--env-var", &format!("connector_api_key={}", api_key.peek()), "--env-var", &format!("connector_key1={}", key1.peek()), ]); } ConnectorAuthType::SignatureKey { api_key, key1, api_secret, } => { newman_command.args([ "--env-var", &format!("connector_api_key={}", api_key.peek()), "--env-var", &format!("connector_key1={}", key1.peek()), "--env-var", &format!("connector_api_secret={}", api_secret.peek()), ]); } ConnectorAuthType::MultiAuthKey { api_key, key1, key2, api_secret, } => { newman_command.args([ "--env-var", &format!("connector_api_key={}", api_key.peek()), "--env-var", &format!("connector_key1={}", key1.peek()), "--env-var", &format!("connector_key2={}", key2.peek()), "--env-var", &format!("connector_api_secret={}", api_secret.peek()), ]); } // Handle other ConnectorAuthType variants _ => { eprintln!("Invalid authentication type."); } } } else { eprintln!("Connector not found."); } // Add additional environment variables if present if let Ok(gateway_merchant_id) = env::var("GATEWAY_MERCHANT_ID") { newman_command.args([ "--env-var", &format!("gateway_merchant_id={gateway_merchant_id}"), ]); } if let Ok(gpay_certificate) = env::var("GPAY_CERTIFICATE") { newman_command.args(["--env-var", &format!("certificate={gpay_certificate}")]); } if let Ok(gpay_certificate_keys) = env::var("GPAY_CERTIFICATE_KEYS") { newman_command.args([ "--env-var", &format!("certificate_keys={gpay_certificate_keys}"), ]); } if let Ok(merchant_api_key) = env::var("MERCHANT_API_KEY") { newman_command.args(["--env-var", &format!("merchant_api_key={merchant_api_key}")]); } newman_command.args([ "--delay-request", format!("{}", &args.delay_request).as_str(), ]); newman_command.arg("--color").arg("on"); // Add flags for running specific folders if let Some(folders) = &args.folders { let folder_names: Vec<String> = folders.split(',').map(|s| s.trim().to_string()).collect(); for folder_name in folder_names { if !folder_name.contains("QuickStart") { // This is a quick fix, "QuickStart" is intentional to have merchant account and API keys set up // This will be replaced by a more robust and efficient account creation or reuse existing old account newman_command.args(["--folder", "QuickStart"]); } newman_command.args(["--folder", &folder_name]); } } if args.verbose { newman_command.arg("--verbose"); } Ok(ReturnArgs { newman_command, modified_file_paths: vec![modified_collection_file_paths, custom_header_exist], collection_path, }) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 92, "total_crates": null }
fn_clm_test_utils_generate_newman_command_for_users_-5044256837976064307
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/src/newman_runner pub fn generate_newman_command_for_users() -> Result<ReturnArgs> { let args = Args::parse(); let base_url = args.base_url; let admin_api_key = args.admin_api_key; let path = env::var("CONNECTOR_AUTH_FILE_PATH") .with_context(|| "connector authentication file path not set")?; let authentication: ConnectorAuthentication = toml::from_str( &fs::read_to_string(path) .with_context(|| "connector authentication config file not found")?, ) .with_context(|| "connector authentication file path not set")?; let users_configs = authentication .users .with_context(|| "user configs not found in authentication file")?; let collection_path = get_collection_path("users"); let mut newman_command = Command::new("newman"); newman_command.args(["run", &collection_path]); newman_command.args(["--env-var", &format!("admin_api_key={admin_api_key}")]); newman_command.args(["--env-var", &format!("baseUrl={base_url}")]); newman_command.args([ "--env-var", &format!("user_email={}", users_configs.user_email), ]); newman_command.args([ "--env-var", &format!( "user_base_email_for_signup={}", users_configs.user_base_email_for_signup ), ]); newman_command.args([ "--env-var", &format!( "user_domain_for_signup={}", users_configs.user_domain_for_signup ), ]); newman_command.args([ "--env-var", &format!("user_password={}", users_configs.user_password), ]); newman_command.args([ "--env-var", &format!("wrong_password={}", users_configs.wrong_password), ]); newman_command.args([ "--delay-request", format!("{}", &args.delay_request).as_str(), ]); newman_command.arg("--color").arg("on"); if args.verbose { newman_command.arg("--verbose"); } Ok(ReturnArgs { newman_command, modified_file_paths: vec![], collection_path, }) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 59, "total_crates": null }
fn_clm_test_utils_export_collection_-5044256837976064307
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/src/newman_runner pub fn export_collection(connector_name: &str, collection_dir_path: String) { let collection_path = get_collection_path(connector_name); let mut newman_command = Command::new("newman"); newman_command.args([ "dir-import".to_owned(), collection_dir_path, "-o".to_owned(), collection_path.clone(), ]); match newman_command.spawn().and_then(|mut child| child.wait()) { Ok(exit_status) => { if exit_status.success() { println!("Conversion of collection from directory structure to json successful!"); } else { eprintln!("Conversion of collection from directory structure to json failed!"); exit(exit_status.code().unwrap_or(1)); } } Err(err) => { eprintln!("Failed to execute dir-import: {err:?}"); exit(1); } } }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 44, "total_crates": null }
fn_clm_test_utils_remove_quotes_for_integer_values_-5044256837976064307
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/src/newman_runner pub fn remove_quotes_for_integer_values( connector_name: &str, ) -> Result<(&str, Option<String>), io::Error> { let collection_path = get_collection_path(connector_name); let collection_dir_path = get_dir_path(connector_name); let values_to_replace = [ "amount", "another_random_number", "capture_amount", "random_number", "refund_amount", ]; export_collection(connector_name, collection_dir_path); let mut contents = fs::read_to_string(&collection_path)?; for value_to_replace in values_to_replace { if let Ok(re) = Regex::new(&format!( r#"\\"(?P<field>\{{\{{{value_to_replace}\}}\}})\\""#, )) { contents = re.replace_all(&contents, "$field").to_string(); } else { eprintln!("Regex validation failed."); } let mut file = OpenOptions::new() .write(true) .truncate(true) .open(&collection_path)?; file.write_all(contents.as_bytes())?; } Ok((connector_name, Some(collection_path))) }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 39, "total_crates": null }
fn_clm_test_utils_generate_runner_-5044256837976064307
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/src/newman_runner pub fn generate_runner() -> Result<ReturnArgs> { let args = Args::parse(); match args.get_module_name() { Some(Module::Users) => generate_newman_command_for_users(), Some(Module::Connector) => generate_newman_command_for_connector(), // Running connector tests when no module is passed to keep the previous test behavior same None => generate_newman_command_for_connector(), } }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 23, "total_crates": null }
fn_clm_test_utils_main_7981842094559467717
clm
function
// Repository: hyperswitch // Crate: test_utils // Module: crates/test_utils/src/main fn main() -> Result<()> { let mut runner = newman_runner::generate_runner()?; // Execute the newman command let output = runner.newman_command.spawn(); let mut child = match output { Ok(child) => child, Err(err) => { eprintln!("Failed to execute command: {err}"); exit(1); } }; let status = child.wait(); // Filter out None values leaving behind Some(Path) let paths: Vec<String> = runner.modified_file_paths.into_iter().flatten().collect(); if !paths.is_empty() { let git_status = Command::new("git").arg("restore").args(&paths).output(); match git_status { Ok(output) if !output.status.success() => { let stderr_str = String::from_utf8_lossy(&output.stderr); eprintln!("Git command failed with error: {stderr_str}"); } Ok(_) => { println!("Git restore successful!"); } Err(e) => { eprintln!("Error running Git: {e}"); } } } let exit_code = match status { Ok(exit_status) => { if exit_status.success() { println!("Command executed successfully!"); exit_status.code().unwrap_or(0) } else { eprintln!("Command failed with exit code: {:?}", exit_status.code()); exit_status.code().unwrap_or(1) } } Err(err) => { eprintln!("Failed to wait for command execution: {err}"); exit(1); } }; exit(exit_code); }
{ "crate": "test_utils", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 42, "total_crates": null }
fn_clm_euclid_wasm_get_valid_connectors_for_rule_3423730560392697629
clm
function
// Repository: hyperswitch // Crate: euclid_wasm // Module: crates/euclid_wasm/src/lib pub fn get_valid_connectors_for_rule(rule: JsValue) -> JsResult { let seed_data = SEED_DATA.get().ok_or("Data not seeded").err_to_js()?; let rule: ast::Rule<ConnectorSelection> = serde_wasm_bindgen::from_value(rule)?; let dir_rule = ast::lowering::lower_rule(rule).err_to_js()?; let mut valid_connectors: Vec<(ast::ConnectorChoice, dir::DirValue)> = seed_data .connectors .iter() .cloned() .map(|choice| (choice.clone(), dir::DirValue::Connector(Box::new(choice)))) .collect(); let mut invalid_connectors: HashSet<ast::ConnectorChoice> = HashSet::new(); let mut ctx_manager = state_machine::RuleContextManager::new(&dir_rule, &[]); let dummy_meta = HashMap::new(); // For every conjunctive context in the Rule, verify validity of all still-valid connectors // using the knowledge graph while let Some(ctx) = ctx_manager.advance_mut().err_to_js()? { // Standalone conjunctive context analysis to ensure the context itself is valid before // checking it against merchant's connectors seed_data .cgraph .perform_context_analysis( ctx, &mut hyperswitch_constraint_graph::Memoization::new(), None, ) .err_to_js()?; // Update conjunctive context and run analysis on all of merchant's connectors. for (conn, choice) in &valid_connectors { if invalid_connectors.contains(conn) { continue; } let ctx_val = dssa::types::ContextValue::assertion(choice, &dummy_meta); ctx.push(ctx_val); let analysis_result = seed_data.cgraph.perform_context_analysis( ctx, &mut hyperswitch_constraint_graph::Memoization::new(), None, ); if analysis_result.is_err() { invalid_connectors.insert(conn.clone()); } ctx.pop(); } } valid_connectors.retain(|(k, _)| !invalid_connectors.contains(k)); let valid_connectors: Vec<ast::ConnectorChoice> = valid_connectors.into_iter().map(|c| c.0).collect(); Ok(serde_wasm_bindgen::to_value(&valid_connectors)?) }
{ "crate": "euclid_wasm", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 82, "total_crates": null }
fn_clm_euclid_wasm_get_valid_webhook_status_3423730560392697629
clm
function
// Repository: hyperswitch // Crate: euclid_wasm // Module: crates/euclid_wasm/src/lib pub fn get_valid_webhook_status(key: &str) -> JsResult { let event_class = EventClass::from_str(key) .map_err(|_| "Invalid webhook event type received".to_string()) .err_to_js()?; match event_class { EventClass::Payments => { let statuses: Vec<IntentStatus> = IntentStatus::iter() .filter(|intent_status| Into::<Option<EventType>>::into(*intent_status).is_some()) .collect(); Ok(serde_wasm_bindgen::to_value(&statuses)?) } EventClass::Refunds => { let statuses: Vec<RefundStatus> = RefundStatus::iter() .filter(|status| Into::<Option<EventType>>::into(*status).is_some()) .collect(); Ok(serde_wasm_bindgen::to_value(&statuses)?) } EventClass::Disputes => { let statuses: Vec<DisputeStatus> = DisputeStatus::iter().collect(); Ok(serde_wasm_bindgen::to_value(&statuses)?) } EventClass::Mandates => { let statuses: Vec<MandateStatus> = MandateStatus::iter() .filter(|status| Into::<Option<EventType>>::into(*status).is_some()) .collect(); Ok(serde_wasm_bindgen::to_value(&statuses)?) } #[cfg(feature = "payouts")] EventClass::Payouts => { let statuses: Vec<PayoutStatus> = PayoutStatus::iter() .filter(|status| Into::<Option<EventType>>::into(*status).is_some()) .collect(); Ok(serde_wasm_bindgen::to_value(&statuses)?) } } }
{ "crate": "euclid_wasm", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 72, "total_crates": null }
fn_clm_euclid_wasm_seed_knowledge_graph_3423730560392697629
clm
function
// Repository: hyperswitch // Crate: euclid_wasm // Module: crates/euclid_wasm/src/lib pub fn seed_knowledge_graph(mcas: JsValue) -> JsResult { let mcas: Vec<api_models::admin::MerchantConnectorResponse> = serde_wasm_bindgen::from_value(mcas)?; let connectors: Vec<ast::ConnectorChoice> = mcas .iter() .map(|mca| { Ok::<_, strum::ParseError>(ast::ConnectorChoice { connector: RoutableConnectors::from_str(&mca.connector_name)?, }) }) .collect::<Result<_, _>>() .map_err(|_| "invalid connector name received") .err_to_js()?; let pm_filter = kgraph_utils::types::PaymentMethodFilters(HashMap::new()); let config = kgraph_utils::types::CountryCurrencyFilter { connector_configs: HashMap::new(), default_configs: Some(pm_filter), }; let mca_graph = kgraph_utils::mca::make_mca_graph(mcas, &config).err_to_js()?; let analysis_graph = hyperswitch_constraint_graph::ConstraintGraph::combine( &mca_graph, &dssa::truth::ANALYSIS_GRAPH, ) .err_to_js()?; SEED_DATA .set(SeedData { cgraph: analysis_graph, connectors, }) .map_err(|_| "Knowledge Graph has been already seeded".to_string()) .err_to_js()?; Ok(JsValue::NULL) }
{ "crate": "euclid_wasm", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 44, "total_crates": null }
fn_clm_euclid_wasm_get_description_category_3423730560392697629
clm
function
// Repository: hyperswitch // Crate: euclid_wasm // Module: crates/euclid_wasm/src/lib pub fn get_description_category() -> JsResult { let keys = dir::DirKeyKind::VARIANTS .iter() .copied() .filter(|s| s != &"Connector") .collect::<Vec<&'static str>>(); let mut category: HashMap<Option<&str>, Vec<types::Details<'_>>> = HashMap::new(); for key in keys { let dir_key = dir::DirKeyKind::from_str(key).map_err(|_| "Invalid key received".to_string())?; let details = types::Details { description: dir_key.get_detailed_message(), kind: dir_key.clone(), }; category .entry(dir_key.get_str("Category")) .and_modify(|val| val.push(details.clone())) .or_insert(vec![details]); } Ok(serde_wasm_bindgen::to_value(&category)?) }
{ "crate": "euclid_wasm", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 42, "total_crates": null }
fn_clm_euclid_wasm_get_payout_description_category_3423730560392697629
clm
function
// Repository: hyperswitch // Crate: euclid_wasm // Module: crates/euclid_wasm/src/lib pub fn get_payout_description_category() -> JsResult { let keys = dir::PayoutDirKeyKind::VARIANTS.to_vec(); let mut category: HashMap<Option<&str>, Vec<types::PayoutDetails<'_>>> = HashMap::new(); for key in keys { let dir_key = dir::PayoutDirKeyKind::from_str(key).map_err(|_| "Invalid key received".to_string())?; let details = types::PayoutDetails { description: dir_key.get_detailed_message(), kind: dir_key.clone(), }; category .entry(dir_key.get_str("Category")) .and_modify(|val| val.push(details.clone())) .or_insert(vec![details]); } Ok(serde_wasm_bindgen::to_value(&category)?) }
{ "crate": "euclid_wasm", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 38, "total_crates": null }
fn_clm_euclid_wasm_err_to_js_-1852616437027491232
clm
function
// Repository: hyperswitch // Crate: euclid_wasm // Module: crates/euclid_wasm/src/utils // Implementation of Result<T, E> for JsResultExt<T> fn err_to_js(self) -> Result<T, JsValue> { match self { Ok(t) => Ok(t), Err(e) => Err(serde_wasm_bindgen::to_value(&e)?), } }
{ "crate": "euclid_wasm", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 55, "total_crates": null }
fn_clm_common_types_get_network_token_webhook_details_-8610773245413521147
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/callback_mapper // Inherent implementation for CallbackMapperData /// Retrieves the details of the network token webhook type from callback mapper data. pub fn get_network_token_webhook_details( &self, ) -> (id_type::MerchantId, String, id_type::CustomerId) { match self { Self::NetworkTokenWebhook { merchant_id, payment_method_id, customer_id, } => ( merchant_id.clone(), payment_method_id.clone(), customer_id.clone(), ), } }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 27, "total_crates": null }
fn_clm_common_types_from_-6350272133135219892
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/payment_methods // Implementation of RequestPaymentMethodTypes for From<RequestPaymentMethodTypesV1> fn from(value: RequestPaymentMethodTypesV1) -> Self { Self { payment_method_subtype: value.payment_method_type, payment_experience: value.payment_experience, card_networks: value.card_networks, accepted_currencies: value.accepted_currencies, accepted_countries: value.accepted_countries, minimum_amount: value.minimum_amount, maximum_amount: value.maximum_amount, recurring_enabled: value.recurring_enabled, installment_payment_enabled: value.installment_payment_enabled, } }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_common_types_build_-6350272133135219892
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/payment_methods // Implementation of PaymentMethodsEnabled for Queryable<Jsonb, DB> fn build(row: Self::Row) -> deserialize::Result<Self> { Ok(row) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 572, "total_crates": null }
fn_clm_common_types_get_payment_method_type_-6350272133135219892
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/payment_methods // Inherent implementation for RequestPaymentMethodTypes ///Get payment_method_subtype pub fn get_payment_method_type(&self) -> Option<common_enums::PaymentMethodType> { Some(self.payment_method_subtype) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 129, "total_crates": null }
fn_clm_common_types_to_sql_-6350272133135219892
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/payment_methods // Implementation of PaymentMethodsEnabled for ToSql<Json, diesel::pg::Pg> fn to_sql<'b>( &'b self, out: &mut diesel::serialize::Output<'b, '_, diesel::pg::Pg>, ) -> diesel::serialize::Result { let value = serde_json::to_value(self)?; // the function `reborrow` only works in case of `Pg` backend. But, in case of other backends // please refer to the diesel migration blog: // https://github.com/Diesel-rs/Diesel/blob/master/guide_drafts/migration_guide.md#changed-tosql-implementations <serde_json::Value as ToSql<Json, diesel::pg::Pg>>::to_sql(&value, &mut out.reborrow()) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 104, "total_crates": null }
fn_clm_common_types_from_sql_-6350272133135219892
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/payment_methods // Implementation of PaymentMethodsEnabled for FromSql<Json, diesel::pg::Pg> fn from_sql(bytes: <diesel::pg::Pg as Backend>::RawValue<'_>) -> deserialize::Result<Self> { let helper: PaymentMethodsEnabledHelper = serde_json::from_slice(bytes.as_bytes()) .map_err(|e| Box::new(diesel::result::Error::DeserializationError(Box::new(e))))?; Ok(helper.into()) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 64, "total_crates": null }
fn_clm_common_types_new_2867558866318708975
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/payments // Inherent implementation for MerchantCountryCode /// Creates a new `MerchantCountryCode` instance from a string. pub fn new(country_code: String) -> Self { Self(country_code) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14465, "total_crates": null }
fn_clm_common_types_to_sql_2867558866318708975
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/payments // Implementation of MerchantCountryCode for diesel::serialize::ToSql<Text, diesel::pg::Pg> fn to_sql<'b>( &'b self, out: &mut diesel::serialize::Output<'b, '_, diesel::pg::Pg>, ) -> diesel::serialize::Result { <String as diesel::serialize::ToSql<Text, diesel::pg::Pg>>::to_sql(&self.0, out) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 100, "total_crates": null }
fn_clm_common_types_from_sql_2867558866318708975
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/payments // Implementation of MerchantCountryCode for diesel::deserialize::FromSql<Text, diesel::pg::Pg> fn from_sql(bytes: diesel::pg::PgValue<'_>) -> diesel::deserialize::Result<Self> { let s = <String as diesel::deserialize::FromSql<Text, diesel::pg::Pg>>::from_sql(bytes)?; Ok(Self(s)) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 54, "total_crates": null }
fn_clm_common_types_get_ip_address_2867558866318708975
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/payments // Inherent implementation for CustomerAcceptance /// Get the IP address pub fn get_ip_address(&self) -> Option<String> { self.online .as_ref() .and_then(|data| data.ip_address.as_ref().map(|ip| ip.peek().to_owned())) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 48, "total_crates": null }
fn_clm_common_types_get_user_agent_2867558866318708975
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/payments // Inherent implementation for CustomerAcceptance /// Get the User Agent pub fn get_user_agent(&self) -> Option<String> { self.online.as_ref().map(|data| data.user_agent.clone()) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 48, "total_crates": null }
fn_clm_common_types_get_retry_feature_data_-766050740462972637
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/domain // Inherent implementation for GsmFeatureData /// Retrieves the retry feature data if it exists. pub fn get_retry_feature_data(&self) -> Option<RetryFeatureData> { match self { Self::Retry(data) => Some(data.clone()), } }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 32, "total_crates": null }
fn_clm_common_types_get_decision_-766050740462972637
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/domain // Implementation of None for RetryFeatureData /// Retrieves the decision to be taken for auto retries flow. pub fn get_decision(&self) -> common_enums::GsmDecision { self.decision }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 27, "total_crates": null }
fn_clm_common_types_is_step_up_possible_-766050740462972637
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/domain // Implementation of None for RetryFeatureData /// Checks if step-up retry is possible. pub fn is_step_up_possible(&self) -> bool { self.step_up_possible }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 24, "total_crates": null }
fn_clm_common_types_is_clear_pan_possible_-766050740462972637
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/domain // Implementation of None for RetryFeatureData /// Checks if retry with PAN is possible. pub fn is_clear_pan_possible(&self) -> bool { self.clear_pan_possible }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 24, "total_crates": null }
fn_clm_common_types_is_alternate_network_possible_-766050740462972637
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/domain // Implementation of None for RetryFeatureData /// Checks if retry with alternate network is possible. pub fn is_alternate_network_possible(&self) -> bool { self.alternate_network_possible }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 18, "total_crates": null }
fn_clm_common_types_new_-5623941396354795558
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/primitive_wrappers // Inherent implementation for SafeString /// Creates a new SafeString after XSS and SQL injection validation pub fn new(value: String) -> Result<Self, String> { if contains_potential_xss_or_sqli(&value) { return Err("Input contains potentially malicious content".into()); } Ok(Self(value)) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14469, "total_crates": null }
fn_clm_common_types_default_-5623941396354795558
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/primitive_wrappers // Implementation of DisputePollingIntervalInHours for Default /// Default for `DisputePollingIntervalInHours` is `24` fn default() -> Self { Self(DEFAULT_DISPUTE_POLLING_INTERVAL_IN_HOURS) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 7705, "total_crates": null }
fn_clm_common_types_from_-5623941396354795558
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/primitive_wrappers // Implementation of EnableOvercaptureBool for From<AlwaysEnableOvercaptureBool> fn from(item: AlwaysEnableOvercaptureBool) -> Self { Self(item.is_true()) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2604, "total_crates": null }
fn_clm_common_types_into_inner_-5623941396354795558
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/primitive_wrappers // Inherent implementation for SafeString /// Consumes self and returns the inner String pub fn into_inner(self) -> String { self.0 }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2061, "total_crates": null }
fn_clm_common_types_as_str_-5623941396354795558
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/primitive_wrappers // Inherent implementation for SafeString /// Returns the inner string as a string slice pub fn as_str(&self) -> &str { &self.0 }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 1242, "total_crates": null }
fn_clm_common_types_get_decision_-1815402017101700040
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/three_ds_decision_rule_engine // Inherent implementation for ThreeDSDecisionRule /// Returns the decision pub fn get_decision(&self) -> ThreeDSDecision { self.decision }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 27, "total_crates": null }
fn_clm_common_types_should_force_3ds_challenge_-1815402017101700040
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/three_ds_decision_rule_engine // Inherent implementation for ThreeDSDecision /// Checks if the decision is to mandate a 3DS challenge pub fn should_force_3ds_challenge(self) -> bool { matches!(self, Self::ChallengeRequested) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 21, "total_crates": null }
fn_clm_common_types_new_7220359209668706611
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/customers // Inherent implementation for ConnectorCustomerMap /// Creates a new `ConnectorCustomerMap` from a HashMap pub fn new( map: std::collections::HashMap<common_utils::id_type::MerchantConnectorAccountId, String>, ) -> Self { Self(map) }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14465, "total_crates": null }
fn_clm_common_types_deref_7220359209668706611
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/customers // Implementation of ConnectorCustomerMap for std::ops::Deref fn deref(&self) -> &Self::Target { &self.0 }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 41, "total_crates": null }
fn_clm_common_types_deref_mut_7220359209668706611
clm
function
// Repository: hyperswitch // Crate: common_types // Module: crates/common_types/src/customers // Implementation of ConnectorCustomerMap for std::ops::DerefMut fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
{ "crate": "common_types", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 8, "total_crates": null }
fn_clm_smithy-core_resolve_type_and_generate_shapes_-2288174867210859471
clm
function
// Repository: hyperswitch // Crate: smithy-core // Module: crates/smithy-core/src/types pub fn resolve_type_and_generate_shapes( value_type: &str, shapes: &mut HashMap<String, SmithyShape>, ) -> Result<(String, HashMap<String, SmithyShape>), syn::Error> { let value_type = value_type.trim(); let value_type_span = proc_macro2::Span::call_site(); let mut generated_shapes = HashMap::new(); let target_type = match value_type { "String" | "str" => "smithy.api#String".to_string(), "i8" | "i16" | "i32" | "u8" | "u16" | "u32" => "smithy.api#Integer".to_string(), "i64" | "u64" | "isize" | "usize" => "smithy.api#Long".to_string(), "f32" => "smithy.api#Float".to_string(), "f64" => "smithy.api#Double".to_string(), "bool" => "smithy.api#Boolean".to_string(), "PrimitiveDateTime" | "time::PrimitiveDateTime" => "smithy.api#Timestamp".to_string(), "Amount" | "MinorUnit" => "smithy.api#Long".to_string(), "serde_json::Value" | "Value" | "Object" => "smithy.api#Document".to_string(), "Url" | "url::Url" => "smithy.api#String".to_string(), vt if vt.starts_with("Option<") && vt.ends_with('>') => { let inner_type = extract_generic_inner_type(vt, "Option") .map_err(|e| syn::Error::new(value_type_span, e))?; let (resolved_type, new_shapes) = resolve_type_and_generate_shapes(inner_type, shapes)?; generated_shapes.extend(new_shapes); resolved_type } vt if vt.starts_with("Vec<") && vt.ends_with('>') => { let inner_type = extract_generic_inner_type(vt, "Vec") .map_err(|e| syn::Error::new(value_type_span, e))?; let (inner_smithy_type, new_shapes) = resolve_type_and_generate_shapes(inner_type, shapes)?; generated_shapes.extend(new_shapes); let list_shape_name = format!( "{}List", inner_smithy_type .split("::") .last() .unwrap_or(&inner_smithy_type) .split('#') .next_back() .unwrap_or(&inner_smithy_type) ); if !shapes.contains_key(&list_shape_name) && !generated_shapes.contains_key(&list_shape_name) { let list_shape = SmithyShape::List { member: Box::new(SmithyMember { target: inner_smithy_type, documentation: None, traits: vec![], }), traits: vec![], }; generated_shapes.insert(list_shape_name.clone(), list_shape); } list_shape_name } vt if vt.starts_with("Box<") && vt.ends_with('>') => { let inner_type = extract_generic_inner_type(vt, "Box") .map_err(|e| syn::Error::new(value_type_span, e))?; let (resolved_type, new_shapes) = resolve_type_and_generate_shapes(inner_type, shapes)?; generated_shapes.extend(new_shapes); resolved_type } vt if vt.starts_with("Secret<") && vt.ends_with('>') => { let inner_type = extract_generic_inner_type(vt, "Secret") .map_err(|e| syn::Error::new(value_type_span, e))?; let (resolved_type, new_shapes) = resolve_type_and_generate_shapes(inner_type, shapes)?; generated_shapes.extend(new_shapes); resolved_type } vt if vt.starts_with("HashMap<") && vt.ends_with('>') => { let inner_types = extract_generic_inner_type(vt, "HashMap") .map_err(|e| syn::Error::new(value_type_span, e))?; let (key_type, value_type) = parse_map_types(inner_types).map_err(|e| syn::Error::new(value_type_span, e))?; let (key_smithy_type, key_shapes) = resolve_type_and_generate_shapes(key_type, shapes)?; generated_shapes.extend(key_shapes); let (value_smithy_type, value_shapes) = resolve_type_and_generate_shapes(value_type, shapes)?; generated_shapes.extend(value_shapes); format!( "smithy.api#Map<key: {}, value: {}>", key_smithy_type, value_smithy_type ) } vt if vt.starts_with("BTreeMap<") && vt.ends_with('>') => { let inner_types = extract_generic_inner_type(vt, "BTreeMap") .map_err(|e| syn::Error::new(value_type_span, e))?; let (key_type, value_type) = parse_map_types(inner_types).map_err(|e| syn::Error::new(value_type_span, e))?; let (key_smithy_type, key_shapes) = resolve_type_and_generate_shapes(key_type, shapes)?; generated_shapes.extend(key_shapes); let (value_smithy_type, value_shapes) = resolve_type_and_generate_shapes(value_type, shapes)?; generated_shapes.extend(value_shapes); format!( "smithy.api#Map<key: {}, value: {}>", key_smithy_type, value_smithy_type ) } _ => { if value_type.contains("::") { value_type.replace("::", ".") } else { value_type.to_string() } } }; Ok((target_type, generated_shapes)) }
{ "crate": "smithy-core", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 180, "total_crates": null }
fn_clm_smithy-core_extract_generic_inner_type_-2288174867210859471
clm
function
// Repository: hyperswitch // Crate: smithy-core // Module: crates/smithy-core/src/types fn extract_generic_inner_type<'a>(full_type: &'a str, wrapper: &str) -> Result<&'a str, String> { let expected_start = format!("{}<", wrapper); if !full_type.starts_with(&expected_start) || !full_type.ends_with('>') { return Err(format!("Invalid {} type format: {}", wrapper, full_type)); } let start_idx = expected_start.len(); let end_idx = full_type.len() - 1; if start_idx >= end_idx { return Err(format!("Empty {} type: {}", wrapper, full_type)); } if start_idx >= full_type.len() || end_idx > full_type.len() { return Err(format!( "Invalid index bounds for {} type: {}", wrapper, full_type )); } Ok(full_type .get(start_idx..end_idx) .ok_or_else(|| { format!( "Failed to extract inner type from {}: {}", wrapper, full_type ) })? .trim()) }
{ "crate": "smithy-core", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 36, "total_crates": null }
fn_clm_smithy-core_parse_map_types_-2288174867210859471
clm
function
// Repository: hyperswitch // Crate: smithy-core // Module: crates/smithy-core/src/types fn parse_map_types(inner_types: &str) -> Result<(&str, &str), String> { // Handle nested generics by counting angle brackets let mut bracket_count = 0; let mut comma_pos = None; for (i, ch) in inner_types.char_indices() { match ch { '<' => bracket_count += 1, '>' => bracket_count -= 1, ',' if bracket_count == 0 => { comma_pos = Some(i); break; } _ => {} } } if let Some(pos) = comma_pos { let key_type = inner_types .get(..pos) .ok_or_else(|| format!("Invalid key type bounds in map: {}", inner_types))? .trim(); let value_type = inner_types .get(pos + 1..) .ok_or_else(|| format!("Invalid value type bounds in map: {}", inner_types))? .trim(); if key_type.is_empty() || value_type.is_empty() { return Err(format!("Invalid map type format: {}", inner_types)); } Ok((key_type, value_type)) } else { Err(format!( "Invalid map type format, missing comma: {}", inner_types )) } }
{ "crate": "smithy-core", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 24, "total_crates": null }
fn_clm_smithy-core_new_3183623189033939447
clm
function
// Repository: hyperswitch // Crate: smithy-core // Module: crates/smithy-core/src/generator // Implementation of None for SmithyGenerator pub fn new() -> Self { Self { models: Vec::new() } }
{ "crate": "smithy-core", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14465, "total_crates": null }
fn_clm_smithy-core_default_3183623189033939447
clm
function
// Repository: hyperswitch // Crate: smithy-core // Module: crates/smithy-core/src/generator // Implementation of SmithyGenerator for Default fn default() -> Self { Self::new() }
{ "crate": "smithy-core", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 7705, "total_crates": null }
fn_clm_smithy-core_generate_shape_definition_3183623189033939447
clm
function
// Repository: hyperswitch // Crate: smithy-core // Module: crates/smithy-core/src/generator // Implementation of None for SmithyGenerator fn generate_shape_definition( &self, name: &str, shape: &types::SmithyShape, current_namespace: &str, shape_to_namespace: &HashMap<String, String>, ) -> String { let resolve_target = |target: &str| self.resolve_type(target, current_namespace, shape_to_namespace); match shape { types::SmithyShape::Structure { members, documentation, traits, } => { let mut def = String::new(); if let Some(doc) = documentation { def.push_str(&format!("/// {}\n", doc)); } for smithy_trait in traits { def.push_str(&format!("@{}\n", self.trait_to_string(smithy_trait))); } def.push_str(&format!("structure {} {{\n", name)); for (member_name, member) in members { if let Some(doc) = &member.documentation { def.push_str(&format!(" /// {}\n", doc)); } for smithy_trait in &member.traits { def.push_str(&format!(" @{}\n", self.trait_to_string(smithy_trait))); } let resolved_target = resolve_target(&member.target); def.push_str(&format!(" {}: {}\n", member_name, resolved_target)); } def.push('}'); def } types::SmithyShape::Union { members, documentation, traits, } => { let mut def = String::new(); if let Some(doc) = documentation { def.push_str(&format!("/// {}\n", doc)); } for smithy_trait in traits { def.push_str(&format!("@{}\n", self.trait_to_string(smithy_trait))); } def.push_str(&format!("union {} {{\n", name)); for (member_name, member) in members { if let Some(doc) = &member.documentation { def.push_str(&format!(" /// {}\n", doc)); } for smithy_trait in &member.traits { def.push_str(&format!(" @{}\n", self.trait_to_string(smithy_trait))); } let resolved_target = resolve_target(&member.target); def.push_str(&format!(" {}: {}\n", member_name, resolved_target)); } def.push('}'); def } types::SmithyShape::Enum { values, documentation, traits, } => { let mut def = String::new(); if let Some(doc) = documentation { def.push_str(&format!("/// {}\n", doc)); } for smithy_trait in traits { def.push_str(&format!("@{}\n", self.trait_to_string(smithy_trait))); } def.push_str(&format!("enum {} {{\n", name)); for (value_name, enum_value) in values { if let Some(doc) = &enum_value.documentation { def.push_str(&format!(" /// {}\n", doc)); } def.push_str(&format!(" {}\n", value_name)); } def.push('}'); def } types::SmithyShape::String { traits } => { let mut def = String::new(); for smithy_trait in traits { def.push_str(&format!("@{}\n", self.trait_to_string(smithy_trait))); } def.push_str(&format!("string {}", name)); def } types::SmithyShape::Integer { traits } => { let mut def = String::new(); for smithy_trait in traits { def.push_str(&format!("@{}\n", self.trait_to_string(smithy_trait))); } def.push_str(&format!("integer {}", name)); def } types::SmithyShape::Long { traits } => { let mut def = String::new(); for smithy_trait in traits { def.push_str(&format!("@{}\n", self.trait_to_string(smithy_trait))); } def.push_str(&format!("long {}", name)); def } types::SmithyShape::Boolean { traits } => { let mut def = String::new(); for smithy_trait in traits { def.push_str(&format!("@{}\n", self.trait_to_string(smithy_trait))); } def.push_str(&format!("boolean {}", name)); def } types::SmithyShape::List { member, traits } => { let mut def = String::new(); for smithy_trait in traits { def.push_str(&format!("@{}\n", self.trait_to_string(smithy_trait))); } def.push_str(&format!("list {} {{\n", name)); let resolved_target = resolve_target(&member.target); def.push_str(&format!(" member: {}\n", resolved_target)); def.push('}'); def } } }
{ "crate": "smithy-core", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 99, "total_crates": null }
fn_clm_smithy-core_generate_idl_3183623189033939447
clm
function
// Repository: hyperswitch // Crate: smithy-core // Module: crates/smithy-core/src/generator // Implementation of None for SmithyGenerator pub fn generate_idl(&self, output_dir: &Path) -> Result<(), Box<dyn std::error::Error>> { fs::create_dir_all(output_dir)?; let mut namespace_models: HashMap<String, Vec<&SmithyModel>> = HashMap::new(); let mut shape_to_namespace: HashMap<String, String> = HashMap::new(); // First, build a map of all shape names to their namespaces for model in &self.models { for shape_name in model.shapes.keys() { shape_to_namespace.insert(shape_name.clone(), model.namespace.clone()); } } // Group models by namespace for file generation for model in &self.models { namespace_models .entry(model.namespace.clone()) .or_default() .push(model); } for (namespace, models) in namespace_models { let filename = format!("{}.smithy", namespace.replace('.', "_")); let filepath = output_dir.join(filename); let mut content = String::new(); content.push_str("$version: \"2\"\n\n"); content.push_str(&format!("namespace {}\n\n", namespace)); // Collect all unique shape definitions for the current namespace let mut shapes_in_namespace = HashMap::new(); for model in models { for (shape_name, shape) in &model.shapes { shapes_in_namespace.insert(shape_name.clone(), shape.clone()); } } // Generate definitions for each shape in the namespace for (shape_name, shape) in &shapes_in_namespace { content.push_str(&self.generate_shape_definition( shape_name, shape, &namespace, &shape_to_namespace, )); content.push_str("\n\n"); } fs::write(filepath, content)?; } Ok(()) }
{ "crate": "smithy-core", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 67, "total_crates": null }
fn_clm_smithy-core_add_model_3183623189033939447
clm
function
// Repository: hyperswitch // Crate: smithy-core // Module: crates/smithy-core/src/generator // Implementation of None for SmithyGenerator pub fn add_model(&mut self, model: SmithyModel) { self.models.push(model); }
{ "crate": "smithy-core", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 23, "total_crates": null }
fn_clm_config_importer_main_-942882099380862631
clm
function
// Repository: hyperswitch // Crate: config_importer // Module: crates/config_importer/src/main fn main() -> anyhow::Result<()> { let args = <cli::Args as clap::Parser>::parse(); // Read input TOML file let toml_contents = std::fs::read_to_string(args.input_file).context("Failed to read input file")?; let table = toml_contents .parse::<toml::Table>() .context("Failed to parse TOML file contents")?; // Parse TOML file contents to a `HashMap` of environment variable name and value pairs let env_vars = table .iter() .flat_map(|(key, value)| process_toml_value(&args.prefix, key, value)) .collect::<EnvironmentVariableMap>(); let writer: BufWriter<Box<dyn Write>> = match args.output_file { // Write to file if output file is specified Some(file) => BufWriter::new(Box::new( std::fs::OpenOptions::new() .create(true) .write(true) .truncate(true) .open(file) .context("Failed to open output file")?, )), // Write to stdout otherwise None => BufWriter::new(Box::new(std::io::stdout().lock())), }; // Write environment variables in specified format match args.output_format { cli::OutputFormat::KubernetesJson => { let k8s_env_vars = env_vars .into_iter() .map(|(name, value)| KubernetesEnvironmentVariable { name, value }) .collect::<Vec<_>>(); serde_json::to_writer_pretty(writer, &k8s_env_vars) .context("Failed to serialize environment variables as JSON")? } } Ok(()) }
{ "crate": "config_importer", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 46, "total_crates": null }
fn_clm_config_importer_process_toml_value_-942882099380862631
clm
function
// Repository: hyperswitch // Crate: config_importer // Module: crates/config_importer/src/main fn process_toml_value( prefix: impl std::fmt::Display + Clone, key: impl std::fmt::Display + Clone, value: &toml::Value, ) -> Vec<(String, String)> { let key_with_prefix = format!("{prefix}{ENV_VAR_SEPARATOR}{key}").to_ascii_uppercase(); match value { toml::Value::String(s) => vec![(key_with_prefix, s.to_owned())], toml::Value::Integer(i) => vec![(key_with_prefix, i.to_string())], toml::Value::Float(f) => vec![(key_with_prefix, f.to_string())], toml::Value::Boolean(b) => vec![(key_with_prefix, b.to_string())], toml::Value::Datetime(dt) => vec![(key_with_prefix, dt.to_string())], toml::Value::Array(values) => { if values.is_empty() { return vec![(key_with_prefix, String::new())]; } // This logic does not support / account for arrays of tables or arrays of arrays. let (_processed_keys, processed_values) = values .iter() .flat_map(|v| process_toml_value(prefix.clone(), key.clone(), v)) .unzip::<_, _, Vec<String>, Vec<String>>(); vec![(key_with_prefix, processed_values.join(","))] } toml::Value::Table(map) => map .into_iter() .flat_map(|(k, v)| process_toml_value(key_with_prefix.clone(), k, v)) .collect(), } }
{ "crate": "config_importer", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 33, "total_crates": null }
fn_clm_cards_test_card_expiration_1137796471485611680
clm
function
// Repository: hyperswitch // Crate: cards // Module: crates/cards/tests/basic fn test_card_expiration() { let curr_date = date_time::now(); let curr_year = u16::try_from(curr_date.year()).expect("valid year"); let curr_month = u8::from(curr_date.month()); // no panic let card_exp = CardExpiration::try_from((curr_month, curr_year)).unwrap(); // will panic on unwrap let invalid_card_exp = CardExpiration::try_from((13, curr_year)); assert_eq!(*card_exp.get_month().peek(), curr_month); assert_eq!(*card_exp.get_year().peek(), curr_year); assert!(!card_exp.is_expired().unwrap()); assert!(invalid_card_exp.is_err()); let serialized = serde_json::to_string(&card_exp).unwrap(); let expected_string = format!(r#"{{"month":{},"year":{}}}"#, 3, curr_year); assert_eq!(serialized, expected_string); let derialized = serde_json::from_str::<CardExpiration>(&serialized).unwrap(); assert_eq!(*derialized.get_month().peek(), 3); assert_eq!(*derialized.get_year().peek(), curr_year); let invalid_serialized_string = r#"{"month":13,"year":123}"#; let invalid_deserialization = serde_json::from_str::<CardExpiration>(invalid_serialized_string); assert!(invalid_deserialization.is_err()); }
{ "crate": "cards", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 16, "total_crates": null }
fn_clm_cards_test_card_expiration_year_1137796471485611680
clm
function
// Repository: hyperswitch // Crate: cards // Module: crates/cards/tests/basic fn test_card_expiration_year() { let curr_date = date_time::now(); let curr_year = u16::try_from(curr_date.year()).expect("valid year"); // no panic let card_exp_year = CardExpirationYear::try_from(curr_year).unwrap(); // will panic on unwrap let invalid_card_exp_year = CardExpirationYear::try_from(curr_year - 1); assert_eq!(*card_exp_year.peek(), curr_year); assert!(invalid_card_exp_year.is_err()); let serialized = serde_json::to_string(&card_exp_year).unwrap(); assert_eq!(serialized, curr_year.to_string()); let derialized = serde_json::from_str::<CardExpirationYear>(&serialized).unwrap(); assert_eq!(*derialized.peek(), curr_year); let invalid_deserialization = serde_json::from_str::<CardExpirationYear>("123"); assert!(invalid_deserialization.is_err()); }
{ "crate": "cards", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 12, "total_crates": null }
fn_clm_cards_test_card_expiration_month_1137796471485611680
clm
function
// Repository: hyperswitch // Crate: cards // Module: crates/cards/tests/basic fn test_card_expiration_month() { // no panic let card_exp_month = CardExpirationMonth::try_from(12).unwrap(); // will panic on unwrap let invalid_card_exp_month = CardExpirationMonth::try_from(13); assert_eq!(*card_exp_month.peek(), 12); assert!(invalid_card_exp_month.is_err()); let serialized = serde_json::to_string(&card_exp_month).unwrap(); assert_eq!(serialized, "12"); let derialized = serde_json::from_str::<CardExpirationMonth>(&serialized).unwrap(); assert_eq!(*derialized.peek(), 12); let invalid_deserialization = serde_json::from_str::<CardExpirationMonth>("13"); assert!(invalid_deserialization.is_err()); }
{ "crate": "cards", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 6, "total_crates": null }
fn_clm_cards_test_card_security_code_1137796471485611680
clm
function
// Repository: hyperswitch // Crate: cards // Module: crates/cards/tests/basic fn test_card_security_code() { // no panic let valid_card_security_code = CardSecurityCode::try_from(1234).unwrap(); assert_eq!(*valid_card_security_code.peek(), 1234); let serialized = serde_json::to_string(&valid_card_security_code).unwrap(); assert_eq!(serialized, "1234"); let derialized = serde_json::from_str::<CardSecurityCode>(&serialized).unwrap(); assert_eq!(*derialized.peek(), 1234); let invalid_deserialization = serde_json::from_str::<CardSecurityCode>("00"); assert!(invalid_deserialization.is_err()); }
{ "crate": "cards", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 4, "total_crates": null }