id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
connector-service_snippet_1061119781833247450_75_15
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs #[test] fn test_three_decimal_currencies() { // Test currencies that should have 3 decimal places assert_eq!( Currency::BHD .number_of_digits_after_decimal_point() .unwrap(), 3 ); assert_eq!( Currency::JOD .number_of_digits_after_decimal_point() .unwrap(), 3 );
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_75_30
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs #[test] fn test_three_decimal_currencies() { // Test currencies that should have 3 decimal places assert_eq!( Currency::BHD .number_of_digits_after_decimal_point() .unwrap(), 3 ); assert_eq!( Currency::JOD .number_of_digits_after_decimal_point() .unwrap(), 3 ); assert_eq!( Currency::KWD .number_of_digits_after_decimal_point() .unwrap(), 3 ); assert_eq!( Currency::OMR .number_of_digits_after_decimal_point() .unwrap(), 3 ); assert_eq!( Currency::TND .number_of_digits_after_decimal_point()
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_75_50
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs #[test] fn test_three_decimal_currencies() { // Test currencies that should have 3 decimal places assert_eq!( Currency::BHD .number_of_digits_after_decimal_point() .unwrap(), 3 ); assert_eq!( Currency::JOD .number_of_digits_after_decimal_point() .unwrap(), 3 ); assert_eq!( Currency::KWD .number_of_digits_after_decimal_point() .unwrap(), 3 ); assert_eq!( Currency::OMR .number_of_digits_after_decimal_point() .unwrap(), 3 ); assert_eq!( Currency::TND .number_of_digits_after_decimal_point() .unwrap(), 3 ); } #[test] fn test_four_decimal_currencies() { // Test currencies that should have 4 decimal places assert_eq!( Currency::CLF .number_of_digits_after_decimal_point() .unwrap(), 4 ); } #[test] fn test_currency_classification_completeness() { // Test that all currencies in the enum are properly classified let mut tested_currencies = 0;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_100_15
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs 3 ); assert_eq!( Currency::TND .number_of_digits_after_decimal_point() .unwrap(), 3 ); } #[test] fn test_four_decimal_currencies() { // Test currencies that should have 4 decimal places assert_eq!( Currency::CLF
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_100_30
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs 3 ); assert_eq!( Currency::TND .number_of_digits_after_decimal_point() .unwrap(), 3 ); } #[test] fn test_four_decimal_currencies() { // Test currencies that should have 4 decimal places assert_eq!( Currency::CLF .number_of_digits_after_decimal_point() .unwrap(), 4 ); } #[test] fn test_currency_classification_completeness() { // Test that all currencies in the enum are properly classified let mut tested_currencies = 0; let mut successful_classifications = 0; // We'll iterate through some key currencies to verify they're all classified let test_currencies = vec![ Currency::USD,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_100_50
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs 3 ); assert_eq!( Currency::TND .number_of_digits_after_decimal_point() .unwrap(), 3 ); } #[test] fn test_four_decimal_currencies() { // Test currencies that should have 4 decimal places assert_eq!( Currency::CLF .number_of_digits_after_decimal_point() .unwrap(), 4 ); } #[test] fn test_currency_classification_completeness() { // Test that all currencies in the enum are properly classified let mut tested_currencies = 0; let mut successful_classifications = 0; // We'll iterate through some key currencies to verify they're all classified let test_currencies = vec![ Currency::USD, Currency::EUR, Currency::GBP, Currency::JPY, Currency::KRW, Currency::BHD, Currency::JOD, Currency::CLF, Currency::CNY, Currency::INR, Currency::CAD, Currency::AUD, Currency::CHF, Currency::SEK, Currency::NOK, Currency::DKK, Currency::PLN, Currency::CZK, Currency::HUF, Currency::RUB, ];
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_125_15
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs let mut successful_classifications = 0; // We'll iterate through some key currencies to verify they're all classified let test_currencies = vec![ Currency::USD, Currency::EUR, Currency::GBP, Currency::JPY, Currency::KRW, Currency::BHD, Currency::JOD, Currency::CLF, Currency::CNY, Currency::INR, Currency::CAD,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_125_30
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs let mut successful_classifications = 0; // We'll iterate through some key currencies to verify they're all classified let test_currencies = vec![ Currency::USD, Currency::EUR, Currency::GBP, Currency::JPY, Currency::KRW, Currency::BHD, Currency::JOD, Currency::CLF, Currency::CNY, Currency::INR, Currency::CAD, Currency::AUD, Currency::CHF, Currency::SEK, Currency::NOK, Currency::DKK, Currency::PLN, Currency::CZK, Currency::HUF, Currency::RUB, ]; let mut failed_currencies = Vec::new(); for currency in test_currencies { tested_currencies += 1;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_125_50
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs let mut successful_classifications = 0; // We'll iterate through some key currencies to verify they're all classified let test_currencies = vec![ Currency::USD, Currency::EUR, Currency::GBP, Currency::JPY, Currency::KRW, Currency::BHD, Currency::JOD, Currency::CLF, Currency::CNY, Currency::INR, Currency::CAD, Currency::AUD, Currency::CHF, Currency::SEK, Currency::NOK, Currency::DKK, Currency::PLN, Currency::CZK, Currency::HUF, Currency::RUB, ]; let mut failed_currencies = Vec::new(); for currency in test_currencies { tested_currencies += 1; match currency.number_of_digits_after_decimal_point() { Ok(_) => successful_classifications += 1, Err(_) => { failed_currencies.push(currency); println!("❌ Currency {currency:?} not properly classified"); } } } // Fail the test if any currencies failed assert!( failed_currencies.is_empty(), "The following currencies are not properly classified: {failed_currencies:?}" ); println!("✅ Tested {tested_currencies} currencies, {successful_classifications} successful classifications"); assert_eq!( tested_currencies, successful_classifications, "All tested currencies should be properly classified" );
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_150_15
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs let mut failed_currencies = Vec::new(); for currency in test_currencies { tested_currencies += 1; match currency.number_of_digits_after_decimal_point() { Ok(_) => successful_classifications += 1, Err(_) => { failed_currencies.push(currency); println!("❌ Currency {currency:?} not properly classified"); } } } // Fail the test if any currencies failed
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_150_30
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs let mut failed_currencies = Vec::new(); for currency in test_currencies { tested_currencies += 1; match currency.number_of_digits_after_decimal_point() { Ok(_) => successful_classifications += 1, Err(_) => { failed_currencies.push(currency); println!("❌ Currency {currency:?} not properly classified"); } } } // Fail the test if any currencies failed assert!( failed_currencies.is_empty(), "The following currencies are not properly classified: {failed_currencies:?}" ); println!("✅ Tested {tested_currencies} currencies, {successful_classifications} successful classifications"); assert_eq!( tested_currencies, successful_classifications, "All tested currencies should be properly classified" ); } #[test] fn test_currency_error_message() { // Since all current currencies should be classified, we can't easily test
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_150_50
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs let mut failed_currencies = Vec::new(); for currency in test_currencies { tested_currencies += 1; match currency.number_of_digits_after_decimal_point() { Ok(_) => successful_classifications += 1, Err(_) => { failed_currencies.push(currency); println!("❌ Currency {currency:?} not properly classified"); } } } // Fail the test if any currencies failed assert!( failed_currencies.is_empty(), "The following currencies are not properly classified: {failed_currencies:?}" ); println!("✅ Tested {tested_currencies} currencies, {successful_classifications} successful classifications"); assert_eq!( tested_currencies, successful_classifications, "All tested currencies should be properly classified" ); } #[test] fn test_currency_error_message() { // Since all current currencies should be classified, we can't easily test // the error case without adding a fake currency. Instead, let's verify // the error type exists and can be created let error = CurrencyError::UnsupportedCurrency { currency: "TEST".to_string(), }; let error_string = format!("{error}"); assert!(error_string.contains("Unsupported currency: TEST")); assert!(error_string.contains("Please add this currency to the supported currency list")); } #[test] fn test_comprehensive_currency_coverage() { // Test a representative sample from each classification let currencies_to_test = vec![ // Zero decimal currencies (Currency::BIF, 0), (Currency::CLP, 0), (Currency::DJF, 0), (Currency::GNF, 0), (Currency::JPY, 0),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_175_15
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs } #[test] fn test_currency_error_message() { // Since all current currencies should be classified, we can't easily test // the error case without adding a fake currency. Instead, let's verify // the error type exists and can be created let error = CurrencyError::UnsupportedCurrency { currency: "TEST".to_string(), }; let error_string = format!("{error}"); assert!(error_string.contains("Unsupported currency: TEST")); assert!(error_string.contains("Please add this currency to the supported currency list")); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_175_30
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs } #[test] fn test_currency_error_message() { // Since all current currencies should be classified, we can't easily test // the error case without adding a fake currency. Instead, let's verify // the error type exists and can be created let error = CurrencyError::UnsupportedCurrency { currency: "TEST".to_string(), }; let error_string = format!("{error}"); assert!(error_string.contains("Unsupported currency: TEST")); assert!(error_string.contains("Please add this currency to the supported currency list")); } #[test] fn test_comprehensive_currency_coverage() { // Test a representative sample from each classification let currencies_to_test = vec![ // Zero decimal currencies (Currency::BIF, 0), (Currency::CLP, 0), (Currency::DJF, 0), (Currency::GNF, 0), (Currency::JPY, 0), (Currency::KMF, 0), (Currency::KRW, 0), (Currency::MGA, 0), (Currency::PYG, 0), (Currency::RWF, 0),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_175_50
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs } #[test] fn test_currency_error_message() { // Since all current currencies should be classified, we can't easily test // the error case without adding a fake currency. Instead, let's verify // the error type exists and can be created let error = CurrencyError::UnsupportedCurrency { currency: "TEST".to_string(), }; let error_string = format!("{error}"); assert!(error_string.contains("Unsupported currency: TEST")); assert!(error_string.contains("Please add this currency to the supported currency list")); } #[test] fn test_comprehensive_currency_coverage() { // Test a representative sample from each classification let currencies_to_test = vec![ // Zero decimal currencies (Currency::BIF, 0), (Currency::CLP, 0), (Currency::DJF, 0), (Currency::GNF, 0), (Currency::JPY, 0), (Currency::KMF, 0), (Currency::KRW, 0), (Currency::MGA, 0), (Currency::PYG, 0), (Currency::RWF, 0), (Currency::UGX, 0), (Currency::VND, 0), (Currency::VUV, 0), (Currency::XAF, 0), (Currency::XOF, 0), (Currency::XPF, 0), // Three decimal currencies (Currency::BHD, 3), (Currency::JOD, 3), (Currency::KWD, 3), (Currency::OMR, 3), (Currency::TND, 3), // Four decimal currencies (Currency::CLF, 4), // Two decimal currencies (sample) (Currency::USD, 2), (Currency::EUR, 2), (Currency::GBP, 2), (Currency::AED, 2), (Currency::AFN, 2),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_200_15
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs (Currency::KMF, 0), (Currency::KRW, 0), (Currency::MGA, 0), (Currency::PYG, 0), (Currency::RWF, 0), (Currency::UGX, 0), (Currency::VND, 0), (Currency::VUV, 0), (Currency::XAF, 0), (Currency::XOF, 0), (Currency::XPF, 0), // Three decimal currencies (Currency::BHD, 3), (Currency::JOD, 3), (Currency::KWD, 3),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_200_30
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs (Currency::KMF, 0), (Currency::KRW, 0), (Currency::MGA, 0), (Currency::PYG, 0), (Currency::RWF, 0), (Currency::UGX, 0), (Currency::VND, 0), (Currency::VUV, 0), (Currency::XAF, 0), (Currency::XOF, 0), (Currency::XPF, 0), // Three decimal currencies (Currency::BHD, 3), (Currency::JOD, 3), (Currency::KWD, 3), (Currency::OMR, 3), (Currency::TND, 3), // Four decimal currencies (Currency::CLF, 4), // Two decimal currencies (sample) (Currency::USD, 2), (Currency::EUR, 2), (Currency::GBP, 2), (Currency::AED, 2), (Currency::AFN, 2), (Currency::ALL, 2), (Currency::AMD, 2), (Currency::ANG, 2), (Currency::AOA, 2), ];
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_200_50
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs (Currency::KMF, 0), (Currency::KRW, 0), (Currency::MGA, 0), (Currency::PYG, 0), (Currency::RWF, 0), (Currency::UGX, 0), (Currency::VND, 0), (Currency::VUV, 0), (Currency::XAF, 0), (Currency::XOF, 0), (Currency::XPF, 0), // Three decimal currencies (Currency::BHD, 3), (Currency::JOD, 3), (Currency::KWD, 3), (Currency::OMR, 3), (Currency::TND, 3), // Four decimal currencies (Currency::CLF, 4), // Two decimal currencies (sample) (Currency::USD, 2), (Currency::EUR, 2), (Currency::GBP, 2), (Currency::AED, 2), (Currency::AFN, 2), (Currency::ALL, 2), (Currency::AMD, 2), (Currency::ANG, 2), (Currency::AOA, 2), ]; for (currency, expected_decimals) in currencies_to_test { match currency.number_of_digits_after_decimal_point() { Ok(decimals) => { assert_eq!(decimals, expected_decimals, "Currency {currency:?} should have {expected_decimals} decimals, got {decimals}"); } Err(e) => { panic!("Currency {currency:?} should be classified but got error: {e}"); } } } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 44, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_225_15
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs (Currency::ALL, 2), (Currency::AMD, 2), (Currency::ANG, 2), (Currency::AOA, 2), ]; for (currency, expected_decimals) in currencies_to_test { match currency.number_of_digits_after_decimal_point() { Ok(decimals) => { assert_eq!(decimals, expected_decimals, "Currency {currency:?} should have {expected_decimals} decimals, got {decimals}"); } Err(e) => { panic!("Currency {currency:?} should be classified but got error: {e}"); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_225_30
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs (Currency::ALL, 2), (Currency::AMD, 2), (Currency::ANG, 2), (Currency::AOA, 2), ]; for (currency, expected_decimals) in currencies_to_test { match currency.number_of_digits_after_decimal_point() { Ok(decimals) => { assert_eq!(decimals, expected_decimals, "Currency {currency:?} should have {expected_decimals} decimals, got {decimals}"); } Err(e) => { panic!("Currency {currency:?} should be classified but got error: {e}"); } } } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 19, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_1061119781833247450_225_50
clm
snippet
// connector-service/backend/grpc-server/tests/test_currency.rs (Currency::ALL, 2), (Currency::AMD, 2), (Currency::ANG, 2), (Currency::AOA, 2), ]; for (currency, expected_decimals) in currencies_to_test { match currency.number_of_digits_after_decimal_point() { Ok(decimals) => { assert_eq!(decimals, expected_decimals, "Currency {currency:?} should have {expected_decimals} decimals, got {decimals}"); } Err(e) => { panic!("Currency {currency:?} should be classified but got error: {e}"); } } } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 19, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_0_15
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs use std::{future::Future, sync::Arc}; use grpc_api_types::{ health_check::health_client::HealthClient, payments::{ payment_service_client::PaymentServiceClient, refund_service_client::RefundServiceClient, }, }; use http::Uri; use hyper_util::rt::TokioIo; // Add this import use tempfile::NamedTempFile; use tokio::net::UnixListener; use tokio_stream::wrappers::UnixListenerStream; use tonic::transport::{Channel, Endpoint, Server}; use tower::service_fn;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_0_30
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs use std::{future::Future, sync::Arc}; use grpc_api_types::{ health_check::health_client::HealthClient, payments::{ payment_service_client::PaymentServiceClient, refund_service_client::RefundServiceClient, }, }; use http::Uri; use hyper_util::rt::TokioIo; // Add this import use tempfile::NamedTempFile; use tokio::net::UnixListener; use tokio_stream::wrappers::UnixListenerStream; use tonic::transport::{Channel, Endpoint, Server}; use tower::service_fn; pub trait AutoClient { fn new(channel: Channel) -> Self; } impl AutoClient for PaymentServiceClient<Channel> { fn new(channel: Channel) -> Self { Self::new(channel) } } impl AutoClient for HealthClient<Channel> { fn new(channel: Channel) -> Self { Self::new(channel) } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_0_50
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs use std::{future::Future, sync::Arc}; use grpc_api_types::{ health_check::health_client::HealthClient, payments::{ payment_service_client::PaymentServiceClient, refund_service_client::RefundServiceClient, }, }; use http::Uri; use hyper_util::rt::TokioIo; // Add this import use tempfile::NamedTempFile; use tokio::net::UnixListener; use tokio_stream::wrappers::UnixListenerStream; use tonic::transport::{Channel, Endpoint, Server}; use tower::service_fn; pub trait AutoClient { fn new(channel: Channel) -> Self; } impl AutoClient for PaymentServiceClient<Channel> { fn new(channel: Channel) -> Self { Self::new(channel) } } impl AutoClient for HealthClient<Channel> { fn new(channel: Channel) -> Self { Self::new(channel) } } impl AutoClient for RefundServiceClient<Channel> { fn new(channel: Channel) -> Self { Self::new(channel) } } /// # Panics /// /// Will panic if the socket file cannot be created or removed pub async fn server_and_client_stub<T>( service: grpc_server::app::Service, ) -> Result<(impl Future<Output = ()>, T), Box<dyn std::error::Error>> where T: AutoClient, { let socket = NamedTempFile::new()?; let socket = Arc::new(socket.into_temp_path()); std::fs::remove_file(&*socket)?; let uds = UnixListener::bind(&*socket)?;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_25_15
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs fn new(channel: Channel) -> Self { Self::new(channel) } } impl AutoClient for RefundServiceClient<Channel> { fn new(channel: Channel) -> Self { Self::new(channel) } } /// # Panics /// /// Will panic if the socket file cannot be created or removed pub async fn server_and_client_stub<T>(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_25_30
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs fn new(channel: Channel) -> Self { Self::new(channel) } } impl AutoClient for RefundServiceClient<Channel> { fn new(channel: Channel) -> Self { Self::new(channel) } } /// # Panics /// /// Will panic if the socket file cannot be created or removed pub async fn server_and_client_stub<T>( service: grpc_server::app::Service, ) -> Result<(impl Future<Output = ()>, T), Box<dyn std::error::Error>> where T: AutoClient, { let socket = NamedTempFile::new()?; let socket = Arc::new(socket.into_temp_path()); std::fs::remove_file(&*socket)?; let uds = UnixListener::bind(&*socket)?; let stream = UnixListenerStream::new(uds); let serve_future = async { let result = Server::builder() .add_service(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_25_50
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs fn new(channel: Channel) -> Self { Self::new(channel) } } impl AutoClient for RefundServiceClient<Channel> { fn new(channel: Channel) -> Self { Self::new(channel) } } /// # Panics /// /// Will panic if the socket file cannot be created or removed pub async fn server_and_client_stub<T>( service: grpc_server::app::Service, ) -> Result<(impl Future<Output = ()>, T), Box<dyn std::error::Error>> where T: AutoClient, { let socket = NamedTempFile::new()?; let socket = Arc::new(socket.into_temp_path()); std::fs::remove_file(&*socket)?; let uds = UnixListener::bind(&*socket)?; let stream = UnixListenerStream::new(uds); let serve_future = async { let result = Server::builder() .add_service( grpc_api_types::health_check::health_server::HealthServer::new( service.health_check_service, ), ) .add_service( grpc_api_types::payments::payment_service_server::PaymentServiceServer::new( service.payments_service, ), ) .add_service( grpc_api_types::payments::refund_service_server::RefundServiceServer::new( service.refunds_service, ), ) .serve_with_incoming(stream) .await; // Server must be running fine... assert!(result.is_ok()); };
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_50_15
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs let stream = UnixListenerStream::new(uds); let serve_future = async { let result = Server::builder() .add_service( grpc_api_types::health_check::health_server::HealthServer::new( service.health_check_service, ), ) .add_service( grpc_api_types::payments::payment_service_server::PaymentServiceServer::new( service.payments_service, ), ) .add_service(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_50_30
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs let stream = UnixListenerStream::new(uds); let serve_future = async { let result = Server::builder() .add_service( grpc_api_types::health_check::health_server::HealthServer::new( service.health_check_service, ), ) .add_service( grpc_api_types::payments::payment_service_server::PaymentServiceServer::new( service.payments_service, ), ) .add_service( grpc_api_types::payments::refund_service_server::RefundServiceServer::new( service.refunds_service, ), ) .serve_with_incoming(stream) .await; // Server must be running fine... assert!(result.is_ok()); }; let socket = Arc::clone(&socket); // Connect to the server over a Unix socket // The URL will be ignored. let channel = Endpoint::try_from("http://any.url")? .connect_with_connector(service_fn(move |_: Uri| {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_50_50
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs let stream = UnixListenerStream::new(uds); let serve_future = async { let result = Server::builder() .add_service( grpc_api_types::health_check::health_server::HealthServer::new( service.health_check_service, ), ) .add_service( grpc_api_types::payments::payment_service_server::PaymentServiceServer::new( service.payments_service, ), ) .add_service( grpc_api_types::payments::refund_service_server::RefundServiceServer::new( service.refunds_service, ), ) .serve_with_incoming(stream) .await; // Server must be running fine... assert!(result.is_ok()); }; let socket = Arc::clone(&socket); // Connect to the server over a Unix socket // The URL will be ignored. let channel = Endpoint::try_from("http://any.url")? .connect_with_connector(service_fn(move |_: Uri| { let socket = Arc::clone(&socket); async move { // Wrap the UnixStream with TokioIo to make it compatible with hyper let unix_stream = tokio::net::UnixStream::connect(&*socket).await?; Ok::<_, std::io::Error>(TokioIo::new(unix_stream)) } })) .await?; let client = T::new(channel); Ok((serve_future, client)) } #[macro_export] macro_rules! grpc_test { ($client:ident, $c_type:ty, $body:block) => { let config = configs::Config::new().expect("Failed while parsing config"); let server = app::Service::new(std::sync::Arc::new(config)).await; let (server_fut, mut $client) = common::server_and_client_stub::<$c_type>(server)
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_75_15
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs let socket = Arc::clone(&socket); // Connect to the server over a Unix socket // The URL will be ignored. let channel = Endpoint::try_from("http://any.url")? .connect_with_connector(service_fn(move |_: Uri| { let socket = Arc::clone(&socket); async move { // Wrap the UnixStream with TokioIo to make it compatible with hyper let unix_stream = tokio::net::UnixStream::connect(&*socket).await?; Ok::<_, std::io::Error>(TokioIo::new(unix_stream)) } })) .await?; let client = T::new(channel);
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_75_30
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs let socket = Arc::clone(&socket); // Connect to the server over a Unix socket // The URL will be ignored. let channel = Endpoint::try_from("http://any.url")? .connect_with_connector(service_fn(move |_: Uri| { let socket = Arc::clone(&socket); async move { // Wrap the UnixStream with TokioIo to make it compatible with hyper let unix_stream = tokio::net::UnixStream::connect(&*socket).await?; Ok::<_, std::io::Error>(TokioIo::new(unix_stream)) } })) .await?; let client = T::new(channel); Ok((serve_future, client)) } #[macro_export] macro_rules! grpc_test { ($client:ident, $c_type:ty, $body:block) => { let config = configs::Config::new().expect("Failed while parsing config"); let server = app::Service::new(std::sync::Arc::new(config)).await; let (server_fut, mut $client) = common::server_and_client_stub::<$c_type>(server) .await .expect("Failed to create the server client pair"); let response = async { $body }; tokio::select! {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_75_50
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs let socket = Arc::clone(&socket); // Connect to the server over a Unix socket // The URL will be ignored. let channel = Endpoint::try_from("http://any.url")? .connect_with_connector(service_fn(move |_: Uri| { let socket = Arc::clone(&socket); async move { // Wrap the UnixStream with TokioIo to make it compatible with hyper let unix_stream = tokio::net::UnixStream::connect(&*socket).await?; Ok::<_, std::io::Error>(TokioIo::new(unix_stream)) } })) .await?; let client = T::new(channel); Ok((serve_future, client)) } #[macro_export] macro_rules! grpc_test { ($client:ident, $c_type:ty, $body:block) => { let config = configs::Config::new().expect("Failed while parsing config"); let server = app::Service::new(std::sync::Arc::new(config)).await; let (server_fut, mut $client) = common::server_and_client_stub::<$c_type>(server) .await .expect("Failed to create the server client pair"); let response = async { $body }; tokio::select! { _ = server_fut => panic!("Server failed"), _ = response => {} } }; }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 35, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_100_15
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs .await .expect("Failed to create the server client pair"); let response = async { $body }; tokio::select! { _ = server_fut => panic!("Server failed"), _ = response => {} } }; }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 10, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_100_30
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs .await .expect("Failed to create the server client pair"); let response = async { $body }; tokio::select! { _ = server_fut => panic!("Server failed"), _ = response => {} } }; }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 10, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4265129285553488760_100_50
clm
snippet
// connector-service/backend/grpc-server/tests/common.rs .await .expect("Failed to create the server client pair"); let response = async { $body }; tokio::select! { _ = server_fut => panic!("Server failed"), _ = response => {} } }; }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 10, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_0_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs //! Common credential loading utilities for test files //! //! This module provides a generic way to load connector credentials from //! the JSON configuration file (.github/test/creds.json) #![allow(dead_code)] use common_enums::enums::Currency; use common_utils::pii::SecretSerdeValue; use domain_types::router_data::ConnectorAuthType; use hyperswitch_masking::Secret; use std::{collections::HashMap, fs}; // Path to the credentials file - use environment variable if set (for CI), otherwise use relative path (for local) fn get_creds_file_path() -> String {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_0_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs //! Common credential loading utilities for test files //! //! This module provides a generic way to load connector credentials from //! the JSON configuration file (.github/test/creds.json) #![allow(dead_code)] use common_enums::enums::Currency; use common_utils::pii::SecretSerdeValue; use domain_types::router_data::ConnectorAuthType; use hyperswitch_masking::Secret; use std::{collections::HashMap, fs}; // Path to the credentials file - use environment variable if set (for CI), otherwise use relative path (for local) fn get_creds_file_path() -> String { std::env::var("CONNECTOR_AUTH_FILE_PATH") .unwrap_or_else(|_| "../../.github/test/creds.json".to_string()) } /// Generic credential structure that can deserialize any connector's credentials #[derive(serde::Deserialize, Debug, Clone)] pub struct ConnectorAccountDetails { pub auth_type: String, #[serde(default)] pub api_key: Option<String>, #[serde(default)] pub key1: Option<String>, #[serde(default)] pub api_secret: Option<String>, #[serde(default)]
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_0_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs //! Common credential loading utilities for test files //! //! This module provides a generic way to load connector credentials from //! the JSON configuration file (.github/test/creds.json) #![allow(dead_code)] use common_enums::enums::Currency; use common_utils::pii::SecretSerdeValue; use domain_types::router_data::ConnectorAuthType; use hyperswitch_masking::Secret; use std::{collections::HashMap, fs}; // Path to the credentials file - use environment variable if set (for CI), otherwise use relative path (for local) fn get_creds_file_path() -> String { std::env::var("CONNECTOR_AUTH_FILE_PATH") .unwrap_or_else(|_| "../../.github/test/creds.json".to_string()) } /// Generic credential structure that can deserialize any connector's credentials #[derive(serde::Deserialize, Debug, Clone)] pub struct ConnectorAccountDetails { pub auth_type: String, #[serde(default)] pub api_key: Option<String>, #[serde(default)] pub key1: Option<String>, #[serde(default)] pub api_secret: Option<String>, #[serde(default)] pub key2: Option<String>, #[serde(default)] pub certificate: Option<String>, #[serde(default)] pub private_key: Option<String>, #[serde(default)] pub auth_key_map: Option<HashMap<Currency, SecretSerdeValue>>, } #[derive(serde::Deserialize, Debug, Clone)] pub struct ConnectorCredentials { pub connector_account_details: ConnectorAccountDetails, #[serde(default)] pub metadata: Option<serde_json::Value>, } /// All connector credentials stored in the JSON file pub type AllCredentials = HashMap<String, ConnectorCredentials>; /// Error type for credential loading operations
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_25_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs #[serde(default)] pub key1: Option<String>, #[serde(default)] pub api_secret: Option<String>, #[serde(default)] pub key2: Option<String>, #[serde(default)] pub certificate: Option<String>, #[serde(default)] pub private_key: Option<String>, #[serde(default)] pub auth_key_map: Option<HashMap<Currency, SecretSerdeValue>>, } #[derive(serde::Deserialize, Debug, Clone)]
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_25_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs #[serde(default)] pub key1: Option<String>, #[serde(default)] pub api_secret: Option<String>, #[serde(default)] pub key2: Option<String>, #[serde(default)] pub certificate: Option<String>, #[serde(default)] pub private_key: Option<String>, #[serde(default)] pub auth_key_map: Option<HashMap<Currency, SecretSerdeValue>>, } #[derive(serde::Deserialize, Debug, Clone)] pub struct ConnectorCredentials { pub connector_account_details: ConnectorAccountDetails, #[serde(default)] pub metadata: Option<serde_json::Value>, } /// All connector credentials stored in the JSON file pub type AllCredentials = HashMap<String, ConnectorCredentials>; /// Error type for credential loading operations #[derive(Debug, thiserror::Error)] pub enum CredentialError { #[error("Failed to read credentials file: {0}")] FileReadError(#[from] std::io::Error), #[error("Failed to parse credentials JSON: {0}")]
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_25_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs #[serde(default)] pub key1: Option<String>, #[serde(default)] pub api_secret: Option<String>, #[serde(default)] pub key2: Option<String>, #[serde(default)] pub certificate: Option<String>, #[serde(default)] pub private_key: Option<String>, #[serde(default)] pub auth_key_map: Option<HashMap<Currency, SecretSerdeValue>>, } #[derive(serde::Deserialize, Debug, Clone)] pub struct ConnectorCredentials { pub connector_account_details: ConnectorAccountDetails, #[serde(default)] pub metadata: Option<serde_json::Value>, } /// All connector credentials stored in the JSON file pub type AllCredentials = HashMap<String, ConnectorCredentials>; /// Error type for credential loading operations #[derive(Debug, thiserror::Error)] pub enum CredentialError { #[error("Failed to read credentials file: {0}")] FileReadError(#[from] std::io::Error), #[error("Failed to parse credentials JSON: {0}")] ParseError(#[from] serde_json::Error), #[error("Connector '{0}' not found in credentials")] ConnectorNotFound(String), #[error("Invalid auth type '{0}' for connector '{1}'")] InvalidAuthType(String, String), #[error("Missing required field '{0}' for auth type '{1}'")] MissingField(String, String), #[error("Invalid structure for connector '{0}': {1}")] InvalidStructure(String, String), } /// Load credentials for a specific connector from the JSON configuration file /// /// # Arguments /// * `connector_name` - Name of the connector (e.g., "aci", "authorizedotnet") /// /// # Returns /// * `ConnectorAuthType` - The loaded and converted credentials /// /// # Examples
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_50_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs #[derive(Debug, thiserror::Error)] pub enum CredentialError { #[error("Failed to read credentials file: {0}")] FileReadError(#[from] std::io::Error), #[error("Failed to parse credentials JSON: {0}")] ParseError(#[from] serde_json::Error), #[error("Connector '{0}' not found in credentials")] ConnectorNotFound(String), #[error("Invalid auth type '{0}' for connector '{1}'")] InvalidAuthType(String, String), #[error("Missing required field '{0}' for auth type '{1}'")] MissingField(String, String), #[error("Invalid structure for connector '{0}': {1}")] InvalidStructure(String, String), }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_50_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs #[derive(Debug, thiserror::Error)] pub enum CredentialError { #[error("Failed to read credentials file: {0}")] FileReadError(#[from] std::io::Error), #[error("Failed to parse credentials JSON: {0}")] ParseError(#[from] serde_json::Error), #[error("Connector '{0}' not found in credentials")] ConnectorNotFound(String), #[error("Invalid auth type '{0}' for connector '{1}'")] InvalidAuthType(String, String), #[error("Missing required field '{0}' for auth type '{1}'")] MissingField(String, String), #[error("Invalid structure for connector '{0}': {1}")] InvalidStructure(String, String), } /// Load credentials for a specific connector from the JSON configuration file /// /// # Arguments /// * `connector_name` - Name of the connector (e.g., "aci", "authorizedotnet") /// /// # Returns /// * `ConnectorAuthType` - The loaded and converted credentials /// /// # Examples /// ``` /// // Load Authorize.Net credentials /// let auth = load_connector_auth("authorizedotnet").unwrap(); /// ``` pub fn load_connector_auth(connector_name: &str) -> Result<ConnectorAuthType, CredentialError> {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_50_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs #[derive(Debug, thiserror::Error)] pub enum CredentialError { #[error("Failed to read credentials file: {0}")] FileReadError(#[from] std::io::Error), #[error("Failed to parse credentials JSON: {0}")] ParseError(#[from] serde_json::Error), #[error("Connector '{0}' not found in credentials")] ConnectorNotFound(String), #[error("Invalid auth type '{0}' for connector '{1}'")] InvalidAuthType(String, String), #[error("Missing required field '{0}' for auth type '{1}'")] MissingField(String, String), #[error("Invalid structure for connector '{0}': {1}")] InvalidStructure(String, String), } /// Load credentials for a specific connector from the JSON configuration file /// /// # Arguments /// * `connector_name` - Name of the connector (e.g., "aci", "authorizedotnet") /// /// # Returns /// * `ConnectorAuthType` - The loaded and converted credentials /// /// # Examples /// ``` /// // Load Authorize.Net credentials /// let auth = load_connector_auth("authorizedotnet").unwrap(); /// ``` pub fn load_connector_auth(connector_name: &str) -> Result<ConnectorAuthType, CredentialError> { load_from_json(connector_name) } /// Load metadata for a specific connector from the JSON configuration file /// /// # Arguments /// * `connector_name` - Name of the connector (e.g., "nexinets", "fiserv") /// /// # Returns /// * `HashMap<String, String>` - The metadata key-value pairs, or empty map if no metadata /// /// # Examples /// ``` /// // Load connector metadata (e.g., terminal_id, shop_name) /// let metadata = load_connector_metadata("fiserv").unwrap(); /// let terminal_id = metadata.get("terminal_id"); /// ``` pub fn load_connector_metadata( connector_name: &str, ) -> Result<HashMap<String, String>, CredentialError> {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_75_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs /// ``` /// // Load Authorize.Net credentials /// let auth = load_connector_auth("authorizedotnet").unwrap(); /// ``` pub fn load_connector_auth(connector_name: &str) -> Result<ConnectorAuthType, CredentialError> { load_from_json(connector_name) } /// Load metadata for a specific connector from the JSON configuration file /// /// # Arguments /// * `connector_name` - Name of the connector (e.g., "nexinets", "fiserv") /// /// # Returns /// * `HashMap<String, String>` - The metadata key-value pairs, or empty map if no metadata
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_75_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs /// ``` /// // Load Authorize.Net credentials /// let auth = load_connector_auth("authorizedotnet").unwrap(); /// ``` pub fn load_connector_auth(connector_name: &str) -> Result<ConnectorAuthType, CredentialError> { load_from_json(connector_name) } /// Load metadata for a specific connector from the JSON configuration file /// /// # Arguments /// * `connector_name` - Name of the connector (e.g., "nexinets", "fiserv") /// /// # Returns /// * `HashMap<String, String>` - The metadata key-value pairs, or empty map if no metadata /// /// # Examples /// ``` /// // Load connector metadata (e.g., terminal_id, shop_name) /// let metadata = load_connector_metadata("fiserv").unwrap(); /// let terminal_id = metadata.get("terminal_id"); /// ``` pub fn load_connector_metadata( connector_name: &str, ) -> Result<HashMap<String, String>, CredentialError> { let creds_file_path = get_creds_file_path(); let creds_content = fs::read_to_string(&creds_file_path)?; let json_value: serde_json::Value = serde_json::from_str(&creds_content)?;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_75_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs /// ``` /// // Load Authorize.Net credentials /// let auth = load_connector_auth("authorizedotnet").unwrap(); /// ``` pub fn load_connector_auth(connector_name: &str) -> Result<ConnectorAuthType, CredentialError> { load_from_json(connector_name) } /// Load metadata for a specific connector from the JSON configuration file /// /// # Arguments /// * `connector_name` - Name of the connector (e.g., "nexinets", "fiserv") /// /// # Returns /// * `HashMap<String, String>` - The metadata key-value pairs, or empty map if no metadata /// /// # Examples /// ``` /// // Load connector metadata (e.g., terminal_id, shop_name) /// let metadata = load_connector_metadata("fiserv").unwrap(); /// let terminal_id = metadata.get("terminal_id"); /// ``` pub fn load_connector_metadata( connector_name: &str, ) -> Result<HashMap<String, String>, CredentialError> { let creds_file_path = get_creds_file_path(); let creds_content = fs::read_to_string(&creds_file_path)?; let json_value: serde_json::Value = serde_json::from_str(&creds_content)?; let all_credentials = match load_credentials_individually(&json_value) { Ok(creds) => creds, Err(_e) => { // Try standard parsing as fallback serde_json::from_value(json_value)? } }; let connector_creds = all_credentials .get(connector_name) .ok_or_else(|| CredentialError::ConnectorNotFound(connector_name.to_string()))?; match &connector_creds.metadata { Some(serde_json::Value::Object(map)) => { let mut result = HashMap::new(); for (key, value) in map { if let Some(string_val) = value.as_str() { result.insert(key.clone(), string_val.to_string()); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_100_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs let creds_file_path = get_creds_file_path(); let creds_content = fs::read_to_string(&creds_file_path)?; let json_value: serde_json::Value = serde_json::from_str(&creds_content)?; let all_credentials = match load_credentials_individually(&json_value) { Ok(creds) => creds, Err(_e) => { // Try standard parsing as fallback serde_json::from_value(json_value)? } }; let connector_creds = all_credentials .get(connector_name)
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_100_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs let creds_file_path = get_creds_file_path(); let creds_content = fs::read_to_string(&creds_file_path)?; let json_value: serde_json::Value = serde_json::from_str(&creds_content)?; let all_credentials = match load_credentials_individually(&json_value) { Ok(creds) => creds, Err(_e) => { // Try standard parsing as fallback serde_json::from_value(json_value)? } }; let connector_creds = all_credentials .get(connector_name) .ok_or_else(|| CredentialError::ConnectorNotFound(connector_name.to_string()))?; match &connector_creds.metadata { Some(serde_json::Value::Object(map)) => { let mut result = HashMap::new(); for (key, value) in map { if let Some(string_val) = value.as_str() { result.insert(key.clone(), string_val.to_string()); } } Ok(result) } _ => Ok(HashMap::new()), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_100_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs let creds_file_path = get_creds_file_path(); let creds_content = fs::read_to_string(&creds_file_path)?; let json_value: serde_json::Value = serde_json::from_str(&creds_content)?; let all_credentials = match load_credentials_individually(&json_value) { Ok(creds) => creds, Err(_e) => { // Try standard parsing as fallback serde_json::from_value(json_value)? } }; let connector_creds = all_credentials .get(connector_name) .ok_or_else(|| CredentialError::ConnectorNotFound(connector_name.to_string()))?; match &connector_creds.metadata { Some(serde_json::Value::Object(map)) => { let mut result = HashMap::new(); for (key, value) in map { if let Some(string_val) = value.as_str() { result.insert(key.clone(), string_val.to_string()); } } Ok(result) } _ => Ok(HashMap::new()), } } /// Load credentials from JSON file fn load_from_json(connector_name: &str) -> Result<ConnectorAuthType, CredentialError> { let creds_file_path = get_creds_file_path(); let creds_content = fs::read_to_string(&creds_file_path)?; let json_value: serde_json::Value = serde_json::from_str(&creds_content)?; let all_credentials = match load_credentials_individually(&json_value) { Ok(creds) => creds, Err(_e) => { // Try standard parsing as fallback serde_json::from_value(json_value)? } }; let connector_creds = all_credentials .get(connector_name) .ok_or_else(|| CredentialError::ConnectorNotFound(connector_name.to_string()))?;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_125_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs Ok(result) } _ => Ok(HashMap::new()), } } /// Load credentials from JSON file fn load_from_json(connector_name: &str) -> Result<ConnectorAuthType, CredentialError> { let creds_file_path = get_creds_file_path(); let creds_content = fs::read_to_string(&creds_file_path)?; let json_value: serde_json::Value = serde_json::from_str(&creds_content)?; let all_credentials = match load_credentials_individually(&json_value) { Ok(creds) => creds,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_125_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs Ok(result) } _ => Ok(HashMap::new()), } } /// Load credentials from JSON file fn load_from_json(connector_name: &str) -> Result<ConnectorAuthType, CredentialError> { let creds_file_path = get_creds_file_path(); let creds_content = fs::read_to_string(&creds_file_path)?; let json_value: serde_json::Value = serde_json::from_str(&creds_content)?; let all_credentials = match load_credentials_individually(&json_value) { Ok(creds) => creds, Err(_e) => { // Try standard parsing as fallback serde_json::from_value(json_value)? } }; let connector_creds = all_credentials .get(connector_name) .ok_or_else(|| CredentialError::ConnectorNotFound(connector_name.to_string()))?; convert_to_auth_type(&connector_creds.connector_account_details, connector_name) } /// Load credentials by parsing each connector individually fn load_credentials_individually(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_125_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs Ok(result) } _ => Ok(HashMap::new()), } } /// Load credentials from JSON file fn load_from_json(connector_name: &str) -> Result<ConnectorAuthType, CredentialError> { let creds_file_path = get_creds_file_path(); let creds_content = fs::read_to_string(&creds_file_path)?; let json_value: serde_json::Value = serde_json::from_str(&creds_content)?; let all_credentials = match load_credentials_individually(&json_value) { Ok(creds) => creds, Err(_e) => { // Try standard parsing as fallback serde_json::from_value(json_value)? } }; let connector_creds = all_credentials .get(connector_name) .ok_or_else(|| CredentialError::ConnectorNotFound(connector_name.to_string()))?; convert_to_auth_type(&connector_creds.connector_account_details, connector_name) } /// Load credentials by parsing each connector individually fn load_credentials_individually( json_value: &serde_json::Value, ) -> Result<AllCredentials, CredentialError> { let mut all_credentials = HashMap::new(); let root_object = json_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( "root".to_string(), "Expected JSON object at root".to_string(), ) })?; for (connector_name, connector_value) in root_object { match parse_single_connector(connector_name, connector_value) { Ok(creds) => { all_credentials.insert(connector_name.clone(), creds); } Err(_e) => { // Continue loading other connectors instead of failing completely } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_150_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs convert_to_auth_type(&connector_creds.connector_account_details, connector_name) } /// Load credentials by parsing each connector individually fn load_credentials_individually( json_value: &serde_json::Value, ) -> Result<AllCredentials, CredentialError> { let mut all_credentials = HashMap::new(); let root_object = json_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( "root".to_string(), "Expected JSON object at root".to_string(), ) })?;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_150_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs convert_to_auth_type(&connector_creds.connector_account_details, connector_name) } /// Load credentials by parsing each connector individually fn load_credentials_individually( json_value: &serde_json::Value, ) -> Result<AllCredentials, CredentialError> { let mut all_credentials = HashMap::new(); let root_object = json_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( "root".to_string(), "Expected JSON object at root".to_string(), ) })?; for (connector_name, connector_value) in root_object { match parse_single_connector(connector_name, connector_value) { Ok(creds) => { all_credentials.insert(connector_name.clone(), creds); } Err(_e) => { // Continue loading other connectors instead of failing completely } } } if all_credentials.is_empty() { return Err(CredentialError::InvalidStructure( "root".to_string(),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_150_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs convert_to_auth_type(&connector_creds.connector_account_details, connector_name) } /// Load credentials by parsing each connector individually fn load_credentials_individually( json_value: &serde_json::Value, ) -> Result<AllCredentials, CredentialError> { let mut all_credentials = HashMap::new(); let root_object = json_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( "root".to_string(), "Expected JSON object at root".to_string(), ) })?; for (connector_name, connector_value) in root_object { match parse_single_connector(connector_name, connector_value) { Ok(creds) => { all_credentials.insert(connector_name.clone(), creds); } Err(_e) => { // Continue loading other connectors instead of failing completely } } } if all_credentials.is_empty() { return Err(CredentialError::InvalidStructure( "root".to_string(), "No valid connectors found".to_string(), )); } Ok(all_credentials) } /// Parse a single connector's credentials fn parse_single_connector( connector_name: &str, connector_value: &serde_json::Value, ) -> Result<ConnectorCredentials, CredentialError> { let connector_obj = connector_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Expected JSON object".to_string(), ) })?; // Check if this is a flat structure (has connector_account_details directly)
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 150, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_175_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs } if all_credentials.is_empty() { return Err(CredentialError::InvalidStructure( "root".to_string(), "No valid connectors found".to_string(), )); } Ok(all_credentials) } /// Parse a single connector's credentials fn parse_single_connector( connector_name: &str,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_175_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs } if all_credentials.is_empty() { return Err(CredentialError::InvalidStructure( "root".to_string(), "No valid connectors found".to_string(), )); } Ok(all_credentials) } /// Parse a single connector's credentials fn parse_single_connector( connector_name: &str, connector_value: &serde_json::Value, ) -> Result<ConnectorCredentials, CredentialError> { let connector_obj = connector_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Expected JSON object".to_string(), ) })?; // Check if this is a flat structure (has connector_account_details directly) if connector_obj.contains_key("connector_account_details") { // Flat structure: connector_name -> { connector_account_details: {...} } return parse_connector_credentials(connector_name, connector_value); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_175_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs } if all_credentials.is_empty() { return Err(CredentialError::InvalidStructure( "root".to_string(), "No valid connectors found".to_string(), )); } Ok(all_credentials) } /// Parse a single connector's credentials fn parse_single_connector( connector_name: &str, connector_value: &serde_json::Value, ) -> Result<ConnectorCredentials, CredentialError> { let connector_obj = connector_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Expected JSON object".to_string(), ) })?; // Check if this is a flat structure (has connector_account_details directly) if connector_obj.contains_key("connector_account_details") { // Flat structure: connector_name -> { connector_account_details: {...} } return parse_connector_credentials(connector_name, connector_value); } // Nested structure: connector_name -> { connector_1: {...}, connector_2: {...} } eg. stripe for (_sub_name, sub_value) in connector_obj.iter() { if let Some(sub_obj) = sub_value.as_object() { if sub_obj.contains_key("connector_account_details") { return parse_connector_credentials(connector_name, sub_value); } } } // If we get here, no valid connector_account_details was found Err(CredentialError::InvalidStructure( connector_name.to_string(), "No connector_account_details found in flat or nested structure".to_string(), )) } /// Parse connector credentials from JSON value fn parse_connector_credentials( connector_name: &str, connector_value: &serde_json::Value,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_200_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs if connector_obj.contains_key("connector_account_details") { // Flat structure: connector_name -> { connector_account_details: {...} } return parse_connector_credentials(connector_name, connector_value); } // Nested structure: connector_name -> { connector_1: {...}, connector_2: {...} } eg. stripe for (_sub_name, sub_value) in connector_obj.iter() { if let Some(sub_obj) = sub_value.as_object() { if sub_obj.contains_key("connector_account_details") { return parse_connector_credentials(connector_name, sub_value); } } } // If we get here, no valid connector_account_details was found
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_200_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs if connector_obj.contains_key("connector_account_details") { // Flat structure: connector_name -> { connector_account_details: {...} } return parse_connector_credentials(connector_name, connector_value); } // Nested structure: connector_name -> { connector_1: {...}, connector_2: {...} } eg. stripe for (_sub_name, sub_value) in connector_obj.iter() { if let Some(sub_obj) = sub_value.as_object() { if sub_obj.contains_key("connector_account_details") { return parse_connector_credentials(connector_name, sub_value); } } } // If we get here, no valid connector_account_details was found Err(CredentialError::InvalidStructure( connector_name.to_string(), "No connector_account_details found in flat or nested structure".to_string(), )) } /// Parse connector credentials from JSON value fn parse_connector_credentials( connector_name: &str, connector_value: &serde_json::Value, ) -> Result<ConnectorCredentials, CredentialError> { let connector_obj = connector_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Expected JSON object".to_string(),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_200_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs if connector_obj.contains_key("connector_account_details") { // Flat structure: connector_name -> { connector_account_details: {...} } return parse_connector_credentials(connector_name, connector_value); } // Nested structure: connector_name -> { connector_1: {...}, connector_2: {...} } eg. stripe for (_sub_name, sub_value) in connector_obj.iter() { if let Some(sub_obj) = sub_value.as_object() { if sub_obj.contains_key("connector_account_details") { return parse_connector_credentials(connector_name, sub_value); } } } // If we get here, no valid connector_account_details was found Err(CredentialError::InvalidStructure( connector_name.to_string(), "No connector_account_details found in flat or nested structure".to_string(), )) } /// Parse connector credentials from JSON value fn parse_connector_credentials( connector_name: &str, connector_value: &serde_json::Value, ) -> Result<ConnectorCredentials, CredentialError> { let connector_obj = connector_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Expected JSON object".to_string(), ) })?; let account_details_value = connector_obj .get("connector_account_details") .ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Missing connector_account_details".to_string(), ) })?; let account_details = parse_connector_account_details(connector_name, account_details_value)?; // Parse metadata if present let metadata = connector_obj .get("metadata") .map(|v| serde_json::from_value(v.clone())) .transpose()?;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_225_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs ) -> Result<ConnectorCredentials, CredentialError> { let connector_obj = connector_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Expected JSON object".to_string(), ) })?; let account_details_value = connector_obj .get("connector_account_details") .ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Missing connector_account_details".to_string(),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_225_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs ) -> Result<ConnectorCredentials, CredentialError> { let connector_obj = connector_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Expected JSON object".to_string(), ) })?; let account_details_value = connector_obj .get("connector_account_details") .ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Missing connector_account_details".to_string(), ) })?; let account_details = parse_connector_account_details(connector_name, account_details_value)?; // Parse metadata if present let metadata = connector_obj .get("metadata") .map(|v| serde_json::from_value(v.clone())) .transpose()?; Ok(ConnectorCredentials { connector_account_details: account_details, metadata, })
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_225_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs ) -> Result<ConnectorCredentials, CredentialError> { let connector_obj = connector_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Expected JSON object".to_string(), ) })?; let account_details_value = connector_obj .get("connector_account_details") .ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Missing connector_account_details".to_string(), ) })?; let account_details = parse_connector_account_details(connector_name, account_details_value)?; // Parse metadata if present let metadata = connector_obj .get("metadata") .map(|v| serde_json::from_value(v.clone())) .transpose()?; Ok(ConnectorCredentials { connector_account_details: account_details, metadata, }) } /// Parse connector account details fn parse_connector_account_details( connector_name: &str, value: &serde_json::Value, ) -> Result<ConnectorAccountDetails, CredentialError> { let obj = value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "connector_account_details must be an object".to_string(), ) })?; // Extract auth_type first let auth_type = obj .get("auth_type") .and_then(|v| v.as_str()) .ok_or_else(|| { CredentialError::InvalidStructure(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_250_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs Ok(ConnectorCredentials { connector_account_details: account_details, metadata, }) } /// Parse connector account details fn parse_connector_account_details( connector_name: &str, value: &serde_json::Value, ) -> Result<ConnectorAccountDetails, CredentialError> { let obj = value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 250, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_250_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs Ok(ConnectorCredentials { connector_account_details: account_details, metadata, }) } /// Parse connector account details fn parse_connector_account_details( connector_name: &str, value: &serde_json::Value, ) -> Result<ConnectorAccountDetails, CredentialError> { let obj = value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "connector_account_details must be an object".to_string(), ) })?; // Extract auth_type first let auth_type = obj .get("auth_type") .and_then(|v| v.as_str()) .ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Missing or invalid auth_type".to_string(), ) })? .to_string();
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 250, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_250_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs Ok(ConnectorCredentials { connector_account_details: account_details, metadata, }) } /// Parse connector account details fn parse_connector_account_details( connector_name: &str, value: &serde_json::Value, ) -> Result<ConnectorAccountDetails, CredentialError> { let obj = value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "connector_account_details must be an object".to_string(), ) })?; // Extract auth_type first let auth_type = obj .get("auth_type") .and_then(|v| v.as_str()) .ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Missing or invalid auth_type".to_string(), ) })? .to_string(); // Handle different auth types with specific parsing logic match auth_type.as_str() { "CurrencyAuthKey" => { // Special handling for CurrencyAuthKey which has complex nested structure parse_currency_auth_key_details(connector_name, obj) } _ => { // For other auth types, use standard serde parsing serde_json::from_value(value.clone()).map_err(CredentialError::ParseError) } } } /// Special parsing logic for CurrencyAuthKey auth type fn parse_currency_auth_key_details( connector_name: &str, obj: &serde_json::Map<String, serde_json::Value>, ) -> Result<ConnectorAccountDetails, CredentialError> { let auth_key_map_value = obj.get("auth_key_map").ok_or_else(|| {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 250, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_275_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs connector_name.to_string(), "Missing or invalid auth_type".to_string(), ) })? .to_string(); // Handle different auth types with specific parsing logic match auth_type.as_str() { "CurrencyAuthKey" => { // Special handling for CurrencyAuthKey which has complex nested structure parse_currency_auth_key_details(connector_name, obj) } _ => { // For other auth types, use standard serde parsing serde_json::from_value(value.clone()).map_err(CredentialError::ParseError)
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 275, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_275_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs connector_name.to_string(), "Missing or invalid auth_type".to_string(), ) })? .to_string(); // Handle different auth types with specific parsing logic match auth_type.as_str() { "CurrencyAuthKey" => { // Special handling for CurrencyAuthKey which has complex nested structure parse_currency_auth_key_details(connector_name, obj) } _ => { // For other auth types, use standard serde parsing serde_json::from_value(value.clone()).map_err(CredentialError::ParseError) } } } /// Special parsing logic for CurrencyAuthKey auth type fn parse_currency_auth_key_details( connector_name: &str, obj: &serde_json::Map<String, serde_json::Value>, ) -> Result<ConnectorAccountDetails, CredentialError> { let auth_key_map_value = obj.get("auth_key_map").ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Missing auth_key_map for CurrencyAuthKey".to_string(), ) })?;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 275, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_275_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs connector_name.to_string(), "Missing or invalid auth_type".to_string(), ) })? .to_string(); // Handle different auth types with specific parsing logic match auth_type.as_str() { "CurrencyAuthKey" => { // Special handling for CurrencyAuthKey which has complex nested structure parse_currency_auth_key_details(connector_name, obj) } _ => { // For other auth types, use standard serde parsing serde_json::from_value(value.clone()).map_err(CredentialError::ParseError) } } } /// Special parsing logic for CurrencyAuthKey auth type fn parse_currency_auth_key_details( connector_name: &str, obj: &serde_json::Map<String, serde_json::Value>, ) -> Result<ConnectorAccountDetails, CredentialError> { let auth_key_map_value = obj.get("auth_key_map").ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "Missing auth_key_map for CurrencyAuthKey".to_string(), ) })?; let auth_key_map_obj = auth_key_map_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "auth_key_map must be an object".to_string(), ) })?; let mut auth_key_map = HashMap::new(); for (currency_str, secret_value) in auth_key_map_obj { let currency = currency_str.parse::<Currency>().map_err(|_| { CredentialError::InvalidStructure( connector_name.to_string(), format!("Invalid currency: {}", currency_str), ) })?; let secret_serde_value = SecretSerdeValue::new(secret_value.clone()); auth_key_map.insert(currency, secret_serde_value);
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 275, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_300_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs CredentialError::InvalidStructure( connector_name.to_string(), "Missing auth_key_map for CurrencyAuthKey".to_string(), ) })?; let auth_key_map_obj = auth_key_map_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "auth_key_map must be an object".to_string(), ) })?; let mut auth_key_map = HashMap::new();
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 300, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_300_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs CredentialError::InvalidStructure( connector_name.to_string(), "Missing auth_key_map for CurrencyAuthKey".to_string(), ) })?; let auth_key_map_obj = auth_key_map_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "auth_key_map must be an object".to_string(), ) })?; let mut auth_key_map = HashMap::new(); for (currency_str, secret_value) in auth_key_map_obj { let currency = currency_str.parse::<Currency>().map_err(|_| { CredentialError::InvalidStructure( connector_name.to_string(), format!("Invalid currency: {}", currency_str), ) })?; let secret_serde_value = SecretSerdeValue::new(secret_value.clone()); auth_key_map.insert(currency, secret_serde_value); } Ok(ConnectorAccountDetails { auth_type: "CurrencyAuthKey".to_string(), api_key: None,
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 300, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_300_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs CredentialError::InvalidStructure( connector_name.to_string(), "Missing auth_key_map for CurrencyAuthKey".to_string(), ) })?; let auth_key_map_obj = auth_key_map_value.as_object().ok_or_else(|| { CredentialError::InvalidStructure( connector_name.to_string(), "auth_key_map must be an object".to_string(), ) })?; let mut auth_key_map = HashMap::new(); for (currency_str, secret_value) in auth_key_map_obj { let currency = currency_str.parse::<Currency>().map_err(|_| { CredentialError::InvalidStructure( connector_name.to_string(), format!("Invalid currency: {}", currency_str), ) })?; let secret_serde_value = SecretSerdeValue::new(secret_value.clone()); auth_key_map.insert(currency, secret_serde_value); } Ok(ConnectorAccountDetails { auth_type: "CurrencyAuthKey".to_string(), api_key: None, key1: None, api_secret: None, key2: None, certificate: None, private_key: None, auth_key_map: Some(auth_key_map), }) } /// Convert generic credential details to specific ConnectorAuthType fn convert_to_auth_type( details: &ConnectorAccountDetails, connector_name: &str, ) -> Result<ConnectorAuthType, CredentialError> { match details.auth_type.as_str() { "HeaderKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "HeaderKey".to_string()) })?;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 300, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_325_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs } Ok(ConnectorAccountDetails { auth_type: "CurrencyAuthKey".to_string(), api_key: None, key1: None, api_secret: None, key2: None, certificate: None, private_key: None, auth_key_map: Some(auth_key_map), }) } /// Convert generic credential details to specific ConnectorAuthType
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 325, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_325_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs } Ok(ConnectorAccountDetails { auth_type: "CurrencyAuthKey".to_string(), api_key: None, key1: None, api_secret: None, key2: None, certificate: None, private_key: None, auth_key_map: Some(auth_key_map), }) } /// Convert generic credential details to specific ConnectorAuthType fn convert_to_auth_type( details: &ConnectorAccountDetails, connector_name: &str, ) -> Result<ConnectorAuthType, CredentialError> { match details.auth_type.as_str() { "HeaderKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "HeaderKey".to_string()) })?; Ok(ConnectorAuthType::HeaderKey { api_key: Secret::new(api_key.clone()), }) } "BodyKey" => {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 325, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_325_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs } Ok(ConnectorAccountDetails { auth_type: "CurrencyAuthKey".to_string(), api_key: None, key1: None, api_secret: None, key2: None, certificate: None, private_key: None, auth_key_map: Some(auth_key_map), }) } /// Convert generic credential details to specific ConnectorAuthType fn convert_to_auth_type( details: &ConnectorAccountDetails, connector_name: &str, ) -> Result<ConnectorAuthType, CredentialError> { match details.auth_type.as_str() { "HeaderKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "HeaderKey".to_string()) })?; Ok(ConnectorAuthType::HeaderKey { api_key: Secret::new(api_key.clone()), }) } "BodyKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "BodyKey".to_string()) })?; let key1 = details.key1.as_ref().ok_or_else(|| { CredentialError::MissingField("key1".to_string(), "BodyKey".to_string()) })?; Ok(ConnectorAuthType::BodyKey { api_key: Secret::new(api_key.clone()), key1: Secret::new(key1.clone()), }) } "SignatureKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "SignatureKey".to_string()) })?; let key1 = details.key1.as_ref().ok_or_else(|| { CredentialError::MissingField("key1".to_string(), "SignatureKey".to_string()) })?; let api_secret = details.api_secret.as_ref().ok_or_else(|| {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 325, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_350_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs Ok(ConnectorAuthType::HeaderKey { api_key: Secret::new(api_key.clone()), }) } "BodyKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "BodyKey".to_string()) })?; let key1 = details.key1.as_ref().ok_or_else(|| { CredentialError::MissingField("key1".to_string(), "BodyKey".to_string()) })?; Ok(ConnectorAuthType::BodyKey { api_key: Secret::new(api_key.clone()), key1: Secret::new(key1.clone()),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 350, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_350_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs Ok(ConnectorAuthType::HeaderKey { api_key: Secret::new(api_key.clone()), }) } "BodyKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "BodyKey".to_string()) })?; let key1 = details.key1.as_ref().ok_or_else(|| { CredentialError::MissingField("key1".to_string(), "BodyKey".to_string()) })?; Ok(ConnectorAuthType::BodyKey { api_key: Secret::new(api_key.clone()), key1: Secret::new(key1.clone()), }) } "SignatureKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "SignatureKey".to_string()) })?; let key1 = details.key1.as_ref().ok_or_else(|| { CredentialError::MissingField("key1".to_string(), "SignatureKey".to_string()) })?; let api_secret = details.api_secret.as_ref().ok_or_else(|| { CredentialError::MissingField("api_secret".to_string(), "SignatureKey".to_string()) })?; Ok(ConnectorAuthType::SignatureKey { api_key: Secret::new(api_key.clone()),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 350, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_350_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs Ok(ConnectorAuthType::HeaderKey { api_key: Secret::new(api_key.clone()), }) } "BodyKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "BodyKey".to_string()) })?; let key1 = details.key1.as_ref().ok_or_else(|| { CredentialError::MissingField("key1".to_string(), "BodyKey".to_string()) })?; Ok(ConnectorAuthType::BodyKey { api_key: Secret::new(api_key.clone()), key1: Secret::new(key1.clone()), }) } "SignatureKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "SignatureKey".to_string()) })?; let key1 = details.key1.as_ref().ok_or_else(|| { CredentialError::MissingField("key1".to_string(), "SignatureKey".to_string()) })?; let api_secret = details.api_secret.as_ref().ok_or_else(|| { CredentialError::MissingField("api_secret".to_string(), "SignatureKey".to_string()) })?; Ok(ConnectorAuthType::SignatureKey { api_key: Secret::new(api_key.clone()), key1: Secret::new(key1.clone()), api_secret: Secret::new(api_secret.clone()), }) } "MultiAuthKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "MultiAuthKey".to_string()) })?; let key1 = details.key1.as_ref().ok_or_else(|| { CredentialError::MissingField("key1".to_string(), "MultiAuthKey".to_string()) })?; let api_secret = details.api_secret.as_ref().ok_or_else(|| { CredentialError::MissingField("api_secret".to_string(), "MultiAuthKey".to_string()) })?; let key2 = details.key2.as_ref().ok_or_else(|| { CredentialError::MissingField("key2".to_string(), "MultiAuthKey".to_string()) })?; Ok(ConnectorAuthType::MultiAuthKey { api_key: Secret::new(api_key.clone()),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 350, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_375_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs CredentialError::MissingField("api_secret".to_string(), "SignatureKey".to_string()) })?; Ok(ConnectorAuthType::SignatureKey { api_key: Secret::new(api_key.clone()), key1: Secret::new(key1.clone()), api_secret: Secret::new(api_secret.clone()), }) } "MultiAuthKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "MultiAuthKey".to_string()) })?; let key1 = details.key1.as_ref().ok_or_else(|| { CredentialError::MissingField("key1".to_string(), "MultiAuthKey".to_string())
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 375, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_375_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs CredentialError::MissingField("api_secret".to_string(), "SignatureKey".to_string()) })?; Ok(ConnectorAuthType::SignatureKey { api_key: Secret::new(api_key.clone()), key1: Secret::new(key1.clone()), api_secret: Secret::new(api_secret.clone()), }) } "MultiAuthKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "MultiAuthKey".to_string()) })?; let key1 = details.key1.as_ref().ok_or_else(|| { CredentialError::MissingField("key1".to_string(), "MultiAuthKey".to_string()) })?; let api_secret = details.api_secret.as_ref().ok_or_else(|| { CredentialError::MissingField("api_secret".to_string(), "MultiAuthKey".to_string()) })?; let key2 = details.key2.as_ref().ok_or_else(|| { CredentialError::MissingField("key2".to_string(), "MultiAuthKey".to_string()) })?; Ok(ConnectorAuthType::MultiAuthKey { api_key: Secret::new(api_key.clone()), key1: Secret::new(key1.clone()), api_secret: Secret::new(api_secret.clone()), key2: Secret::new(key2.clone()), }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 375, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_375_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs CredentialError::MissingField("api_secret".to_string(), "SignatureKey".to_string()) })?; Ok(ConnectorAuthType::SignatureKey { api_key: Secret::new(api_key.clone()), key1: Secret::new(key1.clone()), api_secret: Secret::new(api_secret.clone()), }) } "MultiAuthKey" => { let api_key = details.api_key.as_ref().ok_or_else(|| { CredentialError::MissingField("api_key".to_string(), "MultiAuthKey".to_string()) })?; let key1 = details.key1.as_ref().ok_or_else(|| { CredentialError::MissingField("key1".to_string(), "MultiAuthKey".to_string()) })?; let api_secret = details.api_secret.as_ref().ok_or_else(|| { CredentialError::MissingField("api_secret".to_string(), "MultiAuthKey".to_string()) })?; let key2 = details.key2.as_ref().ok_or_else(|| { CredentialError::MissingField("key2".to_string(), "MultiAuthKey".to_string()) })?; Ok(ConnectorAuthType::MultiAuthKey { api_key: Secret::new(api_key.clone()), key1: Secret::new(key1.clone()), api_secret: Secret::new(api_secret.clone()), key2: Secret::new(key2.clone()), }) } "CurrencyAuthKey" => { // For CurrencyAuthKey, we expect the auth_key_map field to contain the mapping let auth_key_map = details.auth_key_map.as_ref().ok_or_else(|| { CredentialError::MissingField( "auth_key_map".to_string(), "CurrencyAuthKey".to_string(), ) })?; Ok(ConnectorAuthType::CurrencyAuthKey { auth_key_map: auth_key_map.clone(), }) } "CertificateAuth" => { let certificate = details.certificate.as_ref().ok_or_else(|| { CredentialError::MissingField( "certificate".to_string(), "CertificateAuth".to_string(), ) })?;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 375, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_400_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs key1: Secret::new(key1.clone()), api_secret: Secret::new(api_secret.clone()), key2: Secret::new(key2.clone()), }) } "CurrencyAuthKey" => { // For CurrencyAuthKey, we expect the auth_key_map field to contain the mapping let auth_key_map = details.auth_key_map.as_ref().ok_or_else(|| { CredentialError::MissingField( "auth_key_map".to_string(), "CurrencyAuthKey".to_string(), ) })?; Ok(ConnectorAuthType::CurrencyAuthKey {
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 400, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_400_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs key1: Secret::new(key1.clone()), api_secret: Secret::new(api_secret.clone()), key2: Secret::new(key2.clone()), }) } "CurrencyAuthKey" => { // For CurrencyAuthKey, we expect the auth_key_map field to contain the mapping let auth_key_map = details.auth_key_map.as_ref().ok_or_else(|| { CredentialError::MissingField( "auth_key_map".to_string(), "CurrencyAuthKey".to_string(), ) })?; Ok(ConnectorAuthType::CurrencyAuthKey { auth_key_map: auth_key_map.clone(), }) } "CertificateAuth" => { let certificate = details.certificate.as_ref().ok_or_else(|| { CredentialError::MissingField( "certificate".to_string(), "CertificateAuth".to_string(), ) })?; let private_key = details.private_key.as_ref().ok_or_else(|| { CredentialError::MissingField( "private_key".to_string(), "CertificateAuth".to_string(), )
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 400, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_400_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs key1: Secret::new(key1.clone()), api_secret: Secret::new(api_secret.clone()), key2: Secret::new(key2.clone()), }) } "CurrencyAuthKey" => { // For CurrencyAuthKey, we expect the auth_key_map field to contain the mapping let auth_key_map = details.auth_key_map.as_ref().ok_or_else(|| { CredentialError::MissingField( "auth_key_map".to_string(), "CurrencyAuthKey".to_string(), ) })?; Ok(ConnectorAuthType::CurrencyAuthKey { auth_key_map: auth_key_map.clone(), }) } "CertificateAuth" => { let certificate = details.certificate.as_ref().ok_or_else(|| { CredentialError::MissingField( "certificate".to_string(), "CertificateAuth".to_string(), ) })?; let private_key = details.private_key.as_ref().ok_or_else(|| { CredentialError::MissingField( "private_key".to_string(), "CertificateAuth".to_string(), ) })?; Ok(ConnectorAuthType::CertificateAuth { certificate: Secret::new(certificate.clone()), private_key: Secret::new(private_key.clone()), }) } "NoKey" => Ok(ConnectorAuthType::NoKey), "TemporaryAuth" => Ok(ConnectorAuthType::TemporaryAuth), _ => Err(CredentialError::InvalidAuthType( details.auth_type.clone(), connector_name.to_string(), )), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 45, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 400, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_425_15
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs let private_key = details.private_key.as_ref().ok_or_else(|| { CredentialError::MissingField( "private_key".to_string(), "CertificateAuth".to_string(), ) })?; Ok(ConnectorAuthType::CertificateAuth { certificate: Secret::new(certificate.clone()), private_key: Secret::new(private_key.clone()), }) } "NoKey" => Ok(ConnectorAuthType::NoKey), "TemporaryAuth" => Ok(ConnectorAuthType::TemporaryAuth), _ => Err(CredentialError::InvalidAuthType(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 425, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_425_30
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs let private_key = details.private_key.as_ref().ok_or_else(|| { CredentialError::MissingField( "private_key".to_string(), "CertificateAuth".to_string(), ) })?; Ok(ConnectorAuthType::CertificateAuth { certificate: Secret::new(certificate.clone()), private_key: Secret::new(private_key.clone()), }) } "NoKey" => Ok(ConnectorAuthType::NoKey), "TemporaryAuth" => Ok(ConnectorAuthType::TemporaryAuth), _ => Err(CredentialError::InvalidAuthType( details.auth_type.clone(), connector_name.to_string(), )), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 20, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 425, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-8391166333106684163_425_50
clm
snippet
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs let private_key = details.private_key.as_ref().ok_or_else(|| { CredentialError::MissingField( "private_key".to_string(), "CertificateAuth".to_string(), ) })?; Ok(ConnectorAuthType::CertificateAuth { certificate: Secret::new(certificate.clone()), private_key: Secret::new(private_key.clone()), }) } "NoKey" => Ok(ConnectorAuthType::NoKey), "TemporaryAuth" => Ok(ConnectorAuthType::TemporaryAuth), _ => Err(CredentialError::InvalidAuthType( details.auth_type.clone(), connector_name.to_string(), )), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 20, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 425, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8239156977382081034_0_15
clm
snippet
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs #![allow(clippy::expect_used)] #![allow(clippy::unwrap_used)] #![allow(clippy::panic)] use grpc_server::{app, configs}; mod common; mod utils; use std::{ collections::HashMap, str::FromStr, time::{Duration, SystemTime, UNIX_EPOCH}, }; use cards::CardNumber;
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8239156977382081034_0_30
clm
snippet
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs #![allow(clippy::expect_used)] #![allow(clippy::unwrap_used)] #![allow(clippy::panic)] use grpc_server::{app, configs}; mod common; mod utils; use std::{ collections::HashMap, str::FromStr, time::{Duration, SystemTime, UNIX_EPOCH}, }; use cards::CardNumber; use grpc_api_types::{ health_check::{health_client::HealthClient, HealthCheckRequest}, payments::{ card_payment_method_type, identifier::IdType, payment_method, payment_service_client::PaymentServiceClient, refund_service_client::RefundServiceClient, Address, AuthenticationType, BrowserInformation, CaptureMethod, CardDetails, CardPaymentMethodType, CountryAlpha2, Currency, Identifier, PaymentAddress, PaymentMethod, PaymentServiceAuthorizeRequest, PaymentServiceAuthorizeResponse, PaymentServiceCaptureRequest, PaymentServiceGetRequest, PaymentServiceRefundRequest, PaymentServiceVoidRequest, PaymentStatus, RefundServiceGetRequest, RefundStatus, }, }; use hyperswitch_masking::{ExposeInterface, Secret}; use tokio::time::sleep; use tonic::{transport::Channel, Request};
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8239156977382081034_0_50
clm
snippet
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs #![allow(clippy::expect_used)] #![allow(clippy::unwrap_used)] #![allow(clippy::panic)] use grpc_server::{app, configs}; mod common; mod utils; use std::{ collections::HashMap, str::FromStr, time::{Duration, SystemTime, UNIX_EPOCH}, }; use cards::CardNumber; use grpc_api_types::{ health_check::{health_client::HealthClient, HealthCheckRequest}, payments::{ card_payment_method_type, identifier::IdType, payment_method, payment_service_client::PaymentServiceClient, refund_service_client::RefundServiceClient, Address, AuthenticationType, BrowserInformation, CaptureMethod, CardDetails, CardPaymentMethodType, CountryAlpha2, Currency, Identifier, PaymentAddress, PaymentMethod, PaymentServiceAuthorizeRequest, PaymentServiceAuthorizeResponse, PaymentServiceCaptureRequest, PaymentServiceGetRequest, PaymentServiceRefundRequest, PaymentServiceVoidRequest, PaymentStatus, RefundServiceGetRequest, RefundStatus, }, }; use hyperswitch_masking::{ExposeInterface, Secret}; use tokio::time::sleep; use tonic::{transport::Channel, Request}; // Constants for dlocal connector const CONNECTOR_NAME: &str = "dlocal"; const TEST_AMOUNT: i64 = 1000; const TEST_CARD_NUMBER: &str = "5105105105105100"; const TEST_CARD_EXP_MONTH: &str = "10"; const TEST_CARD_EXP_YEAR: &str = "2040"; const TEST_CARD_CVC: &str = "123"; const TEST_CARD_HOLDER: &str = "Test User"; const TEST_EMAIL: &str = "customer@example.com"; // Helper function to get current timestamp fn get_timestamp() -> u64 { SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_secs() }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8239156977382081034_25_15
clm
snippet
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs }, }; use hyperswitch_masking::{ExposeInterface, Secret}; use tokio::time::sleep; use tonic::{transport::Channel, Request}; // Constants for dlocal connector const CONNECTOR_NAME: &str = "dlocal"; const TEST_AMOUNT: i64 = 1000; const TEST_CARD_NUMBER: &str = "5105105105105100"; const TEST_CARD_EXP_MONTH: &str = "10"; const TEST_CARD_EXP_YEAR: &str = "2040"; const TEST_CARD_CVC: &str = "123"; const TEST_CARD_HOLDER: &str = "Test User";
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8239156977382081034_25_30
clm
snippet
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs }, }; use hyperswitch_masking::{ExposeInterface, Secret}; use tokio::time::sleep; use tonic::{transport::Channel, Request}; // Constants for dlocal connector const CONNECTOR_NAME: &str = "dlocal"; const TEST_AMOUNT: i64 = 1000; const TEST_CARD_NUMBER: &str = "5105105105105100"; const TEST_CARD_EXP_MONTH: &str = "10"; const TEST_CARD_EXP_YEAR: &str = "2040"; const TEST_CARD_CVC: &str = "123"; const TEST_CARD_HOLDER: &str = "Test User"; const TEST_EMAIL: &str = "customer@example.com"; // Helper function to get current timestamp fn get_timestamp() -> u64 { SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_secs() } // Helper function to add dlocal metadata headers to a request fn add_dlocal_metadata<T>(request: &mut Request<T>) { let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load dlocal credentials");
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8239156977382081034_25_50
clm
snippet
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs }, }; use hyperswitch_masking::{ExposeInterface, Secret}; use tokio::time::sleep; use tonic::{transport::Channel, Request}; // Constants for dlocal connector const CONNECTOR_NAME: &str = "dlocal"; const TEST_AMOUNT: i64 = 1000; const TEST_CARD_NUMBER: &str = "5105105105105100"; const TEST_CARD_EXP_MONTH: &str = "10"; const TEST_CARD_EXP_YEAR: &str = "2040"; const TEST_CARD_CVC: &str = "123"; const TEST_CARD_HOLDER: &str = "Test User"; const TEST_EMAIL: &str = "customer@example.com"; // Helper function to get current timestamp fn get_timestamp() -> u64 { SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_secs() } // Helper function to add dlocal metadata headers to a request fn add_dlocal_metadata<T>(request: &mut Request<T>) { let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load dlocal credentials"); let (api_key, key1, api_secret) = match auth { domain_types::router_data::ConnectorAuthType::SignatureKey { api_key, key1, api_secret, } => (api_key.expose(), key1.expose(), api_secret.expose()), _ => panic!("Expected SignatureKey auth type for dlocal"), }; request.metadata_mut().append( "x-connector", CONNECTOR_NAME.parse().expect("Failed to parse x-connector"), ); request.metadata_mut().append( "x-auth", "signature-key".parse().expect("Failed to parse x-auth"), ); request.metadata_mut().append( "x-api-key", api_key.parse().expect("Failed to parse x-api-key"),
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8239156977382081034_50_15
clm
snippet
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs // Helper function to add dlocal metadata headers to a request fn add_dlocal_metadata<T>(request: &mut Request<T>) { let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load dlocal credentials"); let (api_key, key1, api_secret) = match auth { domain_types::router_data::ConnectorAuthType::SignatureKey { api_key, key1, api_secret, } => (api_key.expose(), key1.expose(), api_secret.expose()), _ => panic!("Expected SignatureKey auth type for dlocal"), }; request.metadata_mut().append(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8239156977382081034_50_30
clm
snippet
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs // Helper function to add dlocal metadata headers to a request fn add_dlocal_metadata<T>(request: &mut Request<T>) { let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load dlocal credentials"); let (api_key, key1, api_secret) = match auth { domain_types::router_data::ConnectorAuthType::SignatureKey { api_key, key1, api_secret, } => (api_key.expose(), key1.expose(), api_secret.expose()), _ => panic!("Expected SignatureKey auth type for dlocal"), }; request.metadata_mut().append( "x-connector", CONNECTOR_NAME.parse().expect("Failed to parse x-connector"), ); request.metadata_mut().append( "x-auth", "signature-key".parse().expect("Failed to parse x-auth"), ); request.metadata_mut().append( "x-api-key", api_key.parse().expect("Failed to parse x-api-key"), ); request .metadata_mut() .append("x-key1", key1.parse().expect("Failed to parse x-key1")); request.metadata_mut().append(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 30, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8239156977382081034_50_50
clm
snippet
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs // Helper function to add dlocal metadata headers to a request fn add_dlocal_metadata<T>(request: &mut Request<T>) { let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load dlocal credentials"); let (api_key, key1, api_secret) = match auth { domain_types::router_data::ConnectorAuthType::SignatureKey { api_key, key1, api_secret, } => (api_key.expose(), key1.expose(), api_secret.expose()), _ => panic!("Expected SignatureKey auth type for dlocal"), }; request.metadata_mut().append( "x-connector", CONNECTOR_NAME.parse().expect("Failed to parse x-connector"), ); request.metadata_mut().append( "x-auth", "signature-key".parse().expect("Failed to parse x-auth"), ); request.metadata_mut().append( "x-api-key", api_key.parse().expect("Failed to parse x-api-key"), ); request .metadata_mut() .append("x-key1", key1.parse().expect("Failed to parse x-key1")); request.metadata_mut().append( "x-api-secret", api_secret.parse().expect("Failed to parse x-api-secret"), ); request.metadata_mut().append( "x-merchant-id", "test_merchant" .parse() .expect("Failed to parse x-merchant-id"), ); request.metadata_mut().append( "x-tenant-id", "default".parse().expect("Failed to parse x-tenant-id"), ); request.metadata_mut().append( "x-request-id", format!("test_request_{}", get_timestamp()) .parse() .expect("Failed to parse x-request-id"), ); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8239156977382081034_75_15
clm
snippet
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs ); request .metadata_mut() .append("x-key1", key1.parse().expect("Failed to parse x-key1")); request.metadata_mut().append( "x-api-secret", api_secret.parse().expect("Failed to parse x-api-secret"), ); request.metadata_mut().append( "x-merchant-id", "test_merchant" .parse() .expect("Failed to parse x-merchant-id"), ); request.metadata_mut().append(
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 75, "struct_name": null, "total_crates": null, "trait_name": null }