connect-sdk-ruby 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +140 -0
- data/Rakefile +34 -0
- data/connect-sdk-ruby.gemspec +28 -0
- data/examples/merchant/example_configuration.yml +6 -0
- data/examples/merchant/hostedcheckouts/create_hosted_checkout_example.rb +53 -0
- data/examples/merchant/hostedcheckouts/get_hosted_checkout_example.rb +22 -0
- data/examples/merchant/payments/approve_payment_example.rb +42 -0
- data/examples/merchant/payments/cancel_approval_payment_example.rb +22 -0
- data/examples/merchant/payments/cancel_payment_example.rb +22 -0
- data/examples/merchant/payments/create_payment_example.rb +177 -0
- data/examples/merchant/payments/get_payment_example.rb +22 -0
- data/examples/merchant/payments/process_challenged_payment_example.rb +22 -0
- data/examples/merchant/payments/refund_payment_example.rb +85 -0
- data/examples/merchant/payments/tokenize_payment_example.rb +27 -0
- data/examples/merchant/payouts/approve_payout_example.rb +27 -0
- data/examples/merchant/payouts/cancel_approval_payout_example.rb +22 -0
- data/examples/merchant/payouts/cancel_payout_example.rb +22 -0
- data/examples/merchant/payouts/create_payout_example.rb +96 -0
- data/examples/merchant/payouts/get_payout_example.rb +22 -0
- data/examples/merchant/productgroups/get_payment_product_group_example.rb +32 -0
- data/examples/merchant/productgroups/get_payment_product_groups_example.rb +32 -0
- data/examples/merchant/products/get_directory_example.rb +28 -0
- data/examples/merchant/products/get_payment_product_example.rb +32 -0
- data/examples/merchant/products/get_payment_products_example.rb +32 -0
- data/examples/merchant/refunds/approve_refund_example.rb +27 -0
- data/examples/merchant/refunds/cancel_approval_refund_example.rb +22 -0
- data/examples/merchant/refunds/cancel_refund_example.rb +22 -0
- data/examples/merchant/refunds/get_refund_example.rb +22 -0
- data/examples/merchant/riskassessments/risk_assessment_bank_account_example.rb +54 -0
- data/examples/merchant/riskassessments/risk_assessment_cards_example.rb +114 -0
- data/examples/merchant/services/convert_amount_example.rb +29 -0
- data/examples/merchant/services/convert_bank_account_example.rb +34 -0
- data/examples/merchant/services/iin_details_example.rb +27 -0
- data/examples/merchant/services/test_connection_example.rb +22 -0
- data/examples/merchant/sessions/create_session_example.rb +34 -0
- data/examples/merchant/tokens/approve_sepa_direct_debit_token_example.rb +29 -0
- data/examples/merchant/tokens/create_token_example.rb +82 -0
- data/examples/merchant/tokens/delete_token_example.rb +27 -0
- data/examples/merchant/tokens/get_token_example.rb +22 -0
- data/examples/merchant/tokens/update_token_example.rb +76 -0
- data/lib/ingenico/connect/sdk.rb +27 -0
- data/lib/ingenico/connect/sdk/api_exception.rb +52 -0
- data/lib/ingenico/connect/sdk/api_resource.rb +126 -0
- data/lib/ingenico/connect/sdk/authenticator.rb +15 -0
- data/lib/ingenico/connect/sdk/authorization_exception.rb +13 -0
- data/lib/ingenico/connect/sdk/call_context.rb +26 -0
- data/lib/ingenico/connect/sdk/client.rb +92 -0
- data/lib/ingenico/connect/sdk/communication_exception.rb +15 -0
- data/lib/ingenico/connect/sdk/communicator.rb +277 -0
- data/lib/ingenico/connect/sdk/communicator_configuration.rb +98 -0
- data/lib/ingenico/connect/sdk/connection.rb +31 -0
- data/lib/ingenico/connect/sdk/data_object.rb +43 -0
- data/lib/ingenico/connect/sdk/declined_payment_exception.rb +44 -0
- data/lib/ingenico/connect/sdk/declined_payout_exception.rb +44 -0
- data/lib/ingenico/connect/sdk/declined_refund_exception.rb +46 -0
- data/lib/ingenico/connect/sdk/declined_transaction_exception.rb +16 -0
- data/lib/ingenico/connect/sdk/defaultimpl.rb +6 -0
- data/lib/ingenico/connect/sdk/defaultimpl/authorization_type.rb +18 -0
- data/lib/ingenico/connect/sdk/defaultimpl/default_authenticator.rb +106 -0
- data/lib/ingenico/connect/sdk/defaultimpl/default_connection.rb +242 -0
- data/lib/ingenico/connect/sdk/defaultimpl/default_marshaller.rb +35 -0
- data/lib/ingenico/connect/sdk/domain/definitions/abstract_order_status.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/abstract_payment_method_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/additional_order_input_airline_data.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/definitions/address.rb +81 -0
- data/lib/ingenico/connect/sdk/domain/definitions/airline_data.rb +165 -0
- data/lib/ingenico/connect/sdk/domain/definitions/airline_flight_leg.rb +102 -0
- data/lib/ingenico/connect/sdk/domain/definitions/amount_of_money.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/bank_account.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/bank_account_bban.rb +67 -0
- data/lib/ingenico/connect/sdk/domain/definitions/bank_account_iban.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/card.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/card_essentials.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/card_fraud_results.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/definitions/card_without_cvv.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/company_information.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/contact_details_base.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/customer_base.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/definitions/fraud_fields.rb +115 -0
- data/lib/ingenico/connect/sdk/domain/definitions/fraud_results.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/fraud_results_retail_decisions.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/definitions/key_value_pair.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/order_status_output.rb +67 -0
- data/lib/ingenico/connect/sdk/domain/definitions/payment_product_filter.rb +51 -0
- data/lib/ingenico/connect/sdk/domain/definitions/personal_name_base.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/definitions/result_do_risk_assessment.rb +61 -0
- data/lib/ingenico/connect/sdk/domain/definitions/retail_decisions_cc_fraud_check_output.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/definitions/validation_bank_account_check.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/definitions/validation_bank_account_output.rb +67 -0
- data/lib/ingenico/connect/sdk/domain/errors/api_error.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/errors/error_response.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/create_hosted_checkout_request.rb +102 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/create_hosted_checkout_response.rb +59 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/created_payment_output.rb +72 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/displayed_data.rb +53 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/get_hosted_checkout_response.rb +43 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/hosted_checkout_specific_input.rb +78 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/payment_product_filters_hosted_checkout.rb +53 -0
- data/lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb +48 -0
- data/lib/ingenico/connect/sdk/domain/payment/abstract_payment_method_specific_output.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/additional_order_input.rb +72 -0
- data/lib/ingenico/connect/sdk/domain/payment/address_personal.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_card_payment_method_specific_output.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_non_sepa_direct_debit_payment_method_specific_input.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_payment_method_specific_input.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_request.rb +65 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_sepa_direct_debit_payment_method_specific_input.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/bank_transfer_payment_method_specific_input.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/bank_transfer_payment_method_specific_input_base.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/bank_transfer_payment_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/cancel_approval_payment_response.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/cancel_payment_card_payment_method_specific_output.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/cancel_payment_response.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/card_payment_method_specific_input.rb +61 -0
- data/lib/ingenico/connect/sdk/domain/payment/card_payment_method_specific_input_base.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/payment/card_payment_method_specific_output.rb +65 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_method_specific_input.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_method_specific_input_base.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_product1503_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_product1504_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/contact_details.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/create_payment_request.rb +131 -0
- data/lib/ingenico/connect/sdk/domain/payment/create_payment_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/create_payment_result.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/payment/customer.rb +83 -0
- data/lib/ingenico/connect/sdk/domain/payment/external_cardholder_authentication_data.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/payment/invoice_payment_method_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/invoice_payment_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/level3_summary_data.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/payment/line_item.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/payment/line_item_invoice_data.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/payment/line_item_level3_interchange_information.rb +81 -0
- data/lib/ingenico/connect/sdk/domain/payment/merchant_action.rb +64 -0
- data/lib/ingenico/connect/sdk/domain/payment/non_sepa_direct_debit_payment_method_specific_input.rb +71 -0
- data/lib/ingenico/connect/sdk/domain/payment/non_sepa_direct_debit_payment_method_specific_output.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/non_sepa_direct_debit_payment_product705_specific_input.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/payment/order.rb +83 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_approve_payment.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_invoice_data.rb +59 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_output.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_references.rb +57 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_references_approve_payment.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_type_information.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_approval_response.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_creation_output.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_creation_references.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_error_response.rb +57 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_output.rb +116 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_product836_specific_output.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_product840_customer_account.rb +88 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_product840_specific_output.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_references.rb +67 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_status_output.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/personal_information.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/payment/personal_name.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_data.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_method_specific_input.rb +72 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_method_specific_input_base.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_method_specific_output.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_product809_specific_input.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_product816_specific_input.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_product882_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_bank_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_card_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_e_wallet_method_specific_output.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_method_specific_output.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_output.rb +72 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_payment_product840_customer_account.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_payment_product840_specific_output.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/sepa_direct_debit_payment_method_specific_input.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/payment/sepa_direct_debit_payment_method_specific_output.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/three_d_secure_results.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/payment/tokenize_payment_request.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payout/approve_payout_request.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payout/create_payout_request.rb +101 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_customer.rb +76 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_error_response.rb +57 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_references.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_result.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/product/account_on_file.rb +64 -0
- data/lib/ingenico/connect/sdk/domain/product/account_on_file_attribute.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/account_on_file_display_hints.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/product/directory.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/directory_entry.rb +59 -0
- data/lib/ingenico/connect/sdk/domain/product/empty_validator.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/product/fixed_list_validator.rb +38 -0
- data/lib/ingenico/connect/sdk/domain/product/label_template_element.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/length_validator.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product.rb +134 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_display_hints.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field.rb +61 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_data_restrictions.rb +43 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_display_hints.rb +96 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_form_element.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_tooltip.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_validators.rb +100 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_group.rb +71 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_group_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_groups.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_products.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/range_validator.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/regular_expression_validator.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/product/value_mapping_element.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/refund/approve_refund_request.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/refund/bank_account_bban_refund.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/refund/bank_refund_method_specific_input.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_customer.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_error_response.rb +57 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_references.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_request.rb +76 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_result.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/customer_risk_assessment.rb +65 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/order_risk_assessment.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/personal_information_risk_assessment.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/personal_name_risk_assessment.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment_bank_account.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment_card.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment_response.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/services/bank_data.rb +53 -0
- data/lib/ingenico/connect/sdk/domain/services/bank_details.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/services/bank_details_request.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/services/bank_details_response.rb +69 -0
- data/lib/ingenico/connect/sdk/domain/services/convert_amount.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/services/get_iin_details_request.rb +43 -0
- data/lib/ingenico/connect/sdk/domain/services/get_iin_details_response.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/services/iin_detail.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/services/payment_context.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/services/swift.rb +95 -0
- data/lib/ingenico/connect/sdk/domain/services/test_connection.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/sessions/payment_product_filters_client_session.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/sessions/session_request.rb +49 -0
- data/lib/ingenico/connect/sdk/domain/sessions/session_response.rb +59 -0
- data/lib/ingenico/connect/sdk/domain/token/abstract_token.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/token/approve_token_request.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/token/contact_details_token.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/token/create_token_request.rb +76 -0
- data/lib/ingenico/connect/sdk/domain/token/create_token_response.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/token/creditor.rb +102 -0
- data/lib/ingenico/connect/sdk/domain/token/customer_token.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/customer_token_with_contact_details.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/token/debtor.rb +102 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_approval.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_non_sepa_direct_debit.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_sepa_direct_debit.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_sepa_direct_debit_with_mandate_id.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_sepa_direct_debit_without_creditor.rb +79 -0
- data/lib/ingenico/connect/sdk/domain/token/personal_information_token.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/token/personal_name_token.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/token/token_card.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/token_card_data.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/token/token_e_wallet.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/token_e_wallet_data.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/token/token_non_sepa_direct_debit.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/token_non_sepa_direct_debit_payment_product705_specific_data.rb +43 -0
- data/lib/ingenico/connect/sdk/domain/token/token_response.rb +83 -0
- data/lib/ingenico/connect/sdk/domain/token/token_sepa_direct_debit.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/token_sepa_direct_debit_without_creditor.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/update_token_request.rb +76 -0
- data/lib/ingenico/connect/sdk/endpoint_configuration.rb +139 -0
- data/lib/ingenico/connect/sdk/exceptions.rb +8 -0
- data/lib/ingenico/connect/sdk/factory.rb +200 -0
- data/lib/ingenico/connect/sdk/global_collect_exception.rb +15 -0
- data/lib/ingenico/connect/sdk/idempotence_exception.rb +24 -0
- data/lib/ingenico/connect/sdk/logging.rb +10 -0
- data/lib/ingenico/connect/sdk/logging/communicator_logger.rb +19 -0
- data/lib/ingenico/connect/sdk/logging/log_message_builder.rb +61 -0
- data/lib/ingenico/connect/sdk/logging/logging_capable.rb +19 -0
- data/lib/ingenico/connect/sdk/logging/logging_util.rb +298 -0
- data/lib/ingenico/connect/sdk/logging/request_log_message_builder.rb +42 -0
- data/lib/ingenico/connect/sdk/logging/response_log_message_builder.rb +34 -0
- data/lib/ingenico/connect/sdk/logging/ruby_communicator_logger.rb +58 -0
- data/lib/ingenico/connect/sdk/logging/stdout_communicator_logger.rb +36 -0
- data/lib/ingenico/connect/sdk/marshaller.rb +19 -0
- data/lib/ingenico/connect/sdk/marshaller_syntax_exception.rb +6 -0
- data/lib/ingenico/connect/sdk/merchant/hostedcheckouts/hostedcheckouts_client.rb +88 -0
- data/lib/ingenico/connect/sdk/merchant/merchant_client.rb +110 -0
- data/lib/ingenico/connect/sdk/merchant/payments/payments_client.rb +319 -0
- data/lib/ingenico/connect/sdk/merchant/payouts/payouts_client.rb +197 -0
- data/lib/ingenico/connect/sdk/merchant/productgroups/find_productgroups_params.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/productgroups/get_productgroup_params.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/productgroups/productgroups_client.rb +90 -0
- data/lib/ingenico/connect/sdk/merchant/products/directory_params.rb +31 -0
- data/lib/ingenico/connect/sdk/merchant/products/find_products_params.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/products/get_product_params.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/products/products_client.rb +124 -0
- data/lib/ingenico/connect/sdk/merchant/refunds/refunds_client.rb +154 -0
- data/lib/ingenico/connect/sdk/merchant/riskassessments/riskassessments_client.rb +85 -0
- data/lib/ingenico/connect/sdk/merchant/services/convert_amount_params.rb +35 -0
- data/lib/ingenico/connect/sdk/merchant/services/services_client.rb +149 -0
- data/lib/ingenico/connect/sdk/merchant/sessions/sessions_client.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/tokens/delete_token_params.rb +27 -0
- data/lib/ingenico/connect/sdk/merchant/tokens/tokens_client.rb +192 -0
- data/lib/ingenico/connect/sdk/meta_data_provider.rb +152 -0
- data/lib/ingenico/connect/sdk/modules.rb +130 -0
- data/lib/ingenico/connect/sdk/not_found_exception.rb +19 -0
- data/lib/ingenico/connect/sdk/param_request.rb +33 -0
- data/lib/ingenico/connect/sdk/pooled_connection.rb +21 -0
- data/lib/ingenico/connect/sdk/proxy_configuration.rb +75 -0
- data/lib/ingenico/connect/sdk/reference_exception.rb +14 -0
- data/lib/ingenico/connect/sdk/request_header.rb +25 -0
- data/lib/ingenico/connect/sdk/request_param.rb +24 -0
- data/lib/ingenico/connect/sdk/response.rb +62 -0
- data/lib/ingenico/connect/sdk/response_exception.rb +54 -0
- data/lib/ingenico/connect/sdk/response_header.rb +25 -0
- data/lib/ingenico/connect/sdk/session.rb +39 -0
- data/lib/ingenico/connect/sdk/validation_exception.rb +14 -0
- data/spec/comparable_extension.rb +29 -0
- data/spec/fixtures/resources/defaultimpl/convertAmount.json +3 -0
- data/spec/fixtures/resources/defaultimpl/createPayment.failure.invalidCardNumber.json +11 -0
- data/spec/fixtures/resources/defaultimpl/createPayment.failure.rejected.json +48 -0
- data/spec/fixtures/resources/defaultimpl/createPayment.json +40 -0
- data/spec/fixtures/resources/defaultimpl/idempotence_duplicate_failure.json +8 -0
- data/spec/fixtures/resources/defaultimpl/idempotence_rejected.json +46 -0
- data/spec/fixtures/resources/defaultimpl/idempotence_success.json +39 -0
- data/spec/fixtures/resources/defaultimpl/notFound.html +1 -0
- data/spec/fixtures/resources/defaultimpl/testConnection.json +3 -0
- data/spec/fixtures/resources/defaultimpl/unknownServerError.json +10 -0
- data/spec/fixtures/resources/logging/bodyNoObfuscation.json +17 -0
- data/spec/fixtures/resources/logging/bodyWithBinObfuscated.json +3 -0
- data/spec/fixtures/resources/logging/bodyWithBinOriginal.json +3 -0
- data/spec/fixtures/resources/logging/bodyWithCardObfuscated.json +21 -0
- data/spec/fixtures/resources/logging/bodyWithCardOriginal.json +21 -0
- data/spec/fixtures/resources/logging/bodyWithIbanObfuscated.json +19 -0
- data/spec/fixtures/resources/logging/bodyWithIbanOriginal.json +19 -0
- data/spec/fixtures/resources/payment/duplicate_request.json +8 -0
- data/spec/fixtures/resources/payment/invalid_authorization.json +9 -0
- data/spec/fixtures/resources/payment/invalid_request.json +11 -0
- data/spec/fixtures/resources/payment/method_not_allowed.html +1 -0
- data/spec/fixtures/resources/payment/not_found.html +1 -0
- data/spec/fixtures/resources/payment/pending_approval.json +39 -0
- data/spec/fixtures/resources/payment/rejected.json +46 -0
- data/spec/fixtures/resources/properties.proxy.yml +13 -0
- data/spec/fixtures/resources/properties.yml +7 -0
- data/spec/integration/connection_pooling_spec.rb +78 -0
- data/spec/integration/convert_amount_spec.rb +25 -0
- data/spec/integration/idempotence_spec.rb +59 -0
- data/spec/integration/multiline_header_spec.rb +30 -0
- data/spec/integration/payment_product_groups_spec.rb +23 -0
- data/spec/integration/payment_products_spec.rb +22 -0
- data/spec/integration/risk_assessments_spec.rb +37 -0
- data/spec/integration/sdk_proxy_spec.rb +89 -0
- data/spec/integration/token_spec.rb +42 -0
- data/spec/integration_setup.rb +50 -0
- data/spec/lib/client_spec.rb +69 -0
- data/spec/lib/communicator_configuration_spec.rb +179 -0
- data/spec/lib/communicator_spec.rb +31 -0
- data/spec/lib/defaultimpl/default_authenticator_spec.rb +74 -0
- data/spec/lib/defaultimpl/default_connection_idempotence_spec.rb +142 -0
- data/spec/lib/defaultimpl/default_connection_logger_spec.rb +526 -0
- data/spec/lib/defaultimpl/default_connection_spec.rb +334 -0
- data/spec/lib/defaultimpl/default_marshaller_spec.rb +36 -0
- data/spec/lib/factory_spec.rb +41 -0
- data/spec/lib/logging/header_obfuscator_spec.rb +51 -0
- data/spec/lib/logging/logging_util_spec.rb +143 -0
- data/spec/lib/logging/obfuscator_spec.rb +52 -0
- data/spec/lib/logging/ruby_communicator_logger_spec.rb +84 -0
- data/spec/lib/logging/stdout_communicator_logger_spec.rb +64 -0
- data/spec/lib/logging/value_obfuscator_spec.rb +95 -0
- data/spec/lib/meta_data_provider_spec.rb +71 -0
- data/spec/lib/payments_client_spec.rb +157 -0
- data/spec/lib/requestparams/delete_params_spec.rb +21 -0
- data/spec/lib/requestparams/directory_params_spec.rb +27 -0
- data/spec/lib/requestparams/find_params_spec.rb +58 -0
- data/spec/lib/requestparams/get_params_spec.rb +59 -0
- data/spec/lib/requestparams/param_request_spec.rb +57 -0
- data/spec/spec_helper.rb +23 -0
- metadata +565 -0
@@ -0,0 +1,143 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
LoggingUtil = Ingenico::Connect::SDK::Logging::LoggingUtil
|
4
|
+
|
5
|
+
def test_obfuscate_body_with_matches(originalResource, obfuscatedResource)
|
6
|
+
prefix = 'spec/fixtures/resources/logging/'
|
7
|
+
body = IO.read(prefix + originalResource)
|
8
|
+
expected = IO.read(prefix + obfuscatedResource)
|
9
|
+
expected == LoggingUtil.obfuscate_body(body)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_obfuscate_body_with_no_matches(resource)
|
13
|
+
prefix = 'spec/fixtures/resources/logging/'
|
14
|
+
body = IO.read(prefix + resource)
|
15
|
+
body == LoggingUtil.obfuscate_body(body)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_obfuscate_header_with_match(name, originalValue, expectedValue)
|
19
|
+
expectedValue == LoggingUtil.obfuscate_header(name, originalValue)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_obfuscate_header_with_no_match(name, originalValue)
|
23
|
+
originalValue == LoggingUtil.obfuscate_header(name, originalValue)
|
24
|
+
end
|
25
|
+
|
26
|
+
describe LoggingUtil do
|
27
|
+
context '.obfuscate_body()' do
|
28
|
+
|
29
|
+
context 'with null body' do
|
30
|
+
let(:body) { nil }
|
31
|
+
it 'returns null body' do
|
32
|
+
expect(
|
33
|
+
LoggingUtil.obfuscate_body(body)
|
34
|
+
).to be_nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'with empty body' do
|
39
|
+
let(:body) { '' }
|
40
|
+
it 'returns empty body' do
|
41
|
+
expect(
|
42
|
+
LoggingUtil.obfuscate_body(body)
|
43
|
+
).to eq(body)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'works with card' do
|
48
|
+
expect(
|
49
|
+
test_obfuscate_body_with_matches("bodyWithCardOriginal.json",
|
50
|
+
"bodyWithCardObfuscated.json")
|
51
|
+
).to be(true)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'works with iban' do
|
55
|
+
expect(
|
56
|
+
test_obfuscate_body_with_matches("bodyWithIbanOriginal.json",
|
57
|
+
"bodyWithIbanObfuscated.json")
|
58
|
+
).to be(true)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'works with bin' do
|
62
|
+
expect(
|
63
|
+
test_obfuscate_body_with_matches("bodyWithBinOriginal.json",
|
64
|
+
"bodyWithBinObfuscated.json")
|
65
|
+
).to be(true)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'works when there is no match' do
|
69
|
+
expect(
|
70
|
+
test_obfuscate_body_with_no_matches("bodyNoObfuscation.json")
|
71
|
+
).to be(true)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context '.obfuscate_header()' do
|
76
|
+
it 'works when there is a match' do
|
77
|
+
expect(
|
78
|
+
test_obfuscate_header_with_match("Authorization",
|
79
|
+
"Basic QWxhZGRpbjpPcGVuU2VzYW1l",
|
80
|
+
"********")
|
81
|
+
).to be(true)
|
82
|
+
|
83
|
+
expect(
|
84
|
+
test_obfuscate_header_with_match("authorization",
|
85
|
+
"Basic QWxhZGRpbjpPcGVuU2VzYW1l",
|
86
|
+
"********")
|
87
|
+
).to be(true)
|
88
|
+
|
89
|
+
expect(
|
90
|
+
test_obfuscate_header_with_match("AUTHORIZATION",
|
91
|
+
"Basic QWxhZGRpbjpPcGVuU2VzYW1l",
|
92
|
+
"********")
|
93
|
+
).to be(true)
|
94
|
+
|
95
|
+
expect(
|
96
|
+
test_obfuscate_header_with_match("X-GCS-Authentication-Token",
|
97
|
+
"foobar", "********")
|
98
|
+
).to be(true)
|
99
|
+
|
100
|
+
expect(
|
101
|
+
test_obfuscate_header_with_match("x-gcs-authentication-token",
|
102
|
+
"foobar", "********")
|
103
|
+
).to be(true)
|
104
|
+
|
105
|
+
expect(
|
106
|
+
test_obfuscate_header_with_match("X-GCS-AUTHENTICATION-TOKEN",
|
107
|
+
"foobar", "********")
|
108
|
+
).to be(true)
|
109
|
+
|
110
|
+
expect(
|
111
|
+
test_obfuscate_header_with_match("X-GCS-CallerPassword", "foobar",
|
112
|
+
"********")
|
113
|
+
).to be(true)
|
114
|
+
|
115
|
+
expect(
|
116
|
+
test_obfuscate_header_with_match("x-gcs-callerpassword", "foobar",
|
117
|
+
"********")
|
118
|
+
).to be(true)
|
119
|
+
|
120
|
+
expect(
|
121
|
+
test_obfuscate_header_with_match("X-GCS-CALLERPASSWORD", "foobar",
|
122
|
+
"********")
|
123
|
+
).to be(true)
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'works when there is no match' do
|
127
|
+
expect(
|
128
|
+
test_obfuscate_header_with_no_match("Content-Type",
|
129
|
+
"application/json")
|
130
|
+
).to be(true)
|
131
|
+
|
132
|
+
expect(
|
133
|
+
test_obfuscate_header_with_no_match("content-type",
|
134
|
+
"application/json")
|
135
|
+
).to be(true)
|
136
|
+
|
137
|
+
expect(
|
138
|
+
test_obfuscate_header_with_no_match("CONTENT-TYPE",
|
139
|
+
"application/json")
|
140
|
+
).to be(true)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
Obfuscator ||= Ingenico::Connect::SDK::Logging::Obfuscator
|
4
|
+
ValueObfuscator ||= Ingenico::Connect::SDK::Logging::ValueObfuscator
|
5
|
+
|
6
|
+
describe Obfuscator do
|
7
|
+
subject(:sample) { Obfuscator.new(obsfs, caseInsensitive) }
|
8
|
+
context 'initialize' do
|
9
|
+
let(:obsfs) { { 'k1' => ValueObfuscator.fixed_length(5),
|
10
|
+
'k2' => ValueObfuscator.keep_start_count(2) } }
|
11
|
+
|
12
|
+
context 'case sensitive' do
|
13
|
+
let(:caseInsensitive) { false }
|
14
|
+
it 'deep-copies obfuscators' do
|
15
|
+
obsfs_copy = sample.instance_variable_get(:@obfuscators)
|
16
|
+
obsfs['k2'] = nil
|
17
|
+
expect(obsfs_copy).not_to be_nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'case insensitive' do
|
22
|
+
let(:caseInsensitive) { true }
|
23
|
+
it 'deep-copies obfuscators' do
|
24
|
+
obsfs_copy = sample.instance_variable_get(:@obfuscators)
|
25
|
+
expect(obsfs_copy['K2']).to equal(obsfs_copy['k2'])
|
26
|
+
obsfs['k2'] = nil
|
27
|
+
expect(obsfs_copy).not_to be_nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context '.obfuscate_value' do
|
33
|
+
let(:obsfs) { { 'k1' => ValueObfuscator.fixed_length(10),
|
34
|
+
'k2' => ValueObfuscator.keep_start_count(1) } }
|
35
|
+
let(:caseInsensitive) { false }
|
36
|
+
it 'uses the correct obfuscator' do
|
37
|
+
str = 'str'
|
38
|
+
|
39
|
+
expect(
|
40
|
+
sample.obfuscate_value('k1', str)
|
41
|
+
).to eq('*' * 10)
|
42
|
+
|
43
|
+
expect(
|
44
|
+
sample.obfuscate_value('k2', str)
|
45
|
+
).to eq('s**')
|
46
|
+
|
47
|
+
expect(
|
48
|
+
sample.obfuscate_value('k3', str)
|
49
|
+
).to eq(str)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'logger'
|
3
|
+
require 'English'
|
4
|
+
|
5
|
+
RubyCommunicatorLogger = Ingenico::Connect::SDK::Logging::RubyCommunicatorLogger
|
6
|
+
|
7
|
+
describe RubyCommunicatorLogger do
|
8
|
+
|
9
|
+
# TODO: is it possbile that we run into a filename collision here?
|
10
|
+
let(:filename) { "testing-#{(0...8).map { (65 + rand(26)).chr }.join}.log" }
|
11
|
+
let(:logger) { Logger.new(RubyCommunicatorLogger.create_logfile(filename)) }
|
12
|
+
let(:regex) { Regexp.new("#{tag}, .* -- : (.*)#{$RS}", Regexp::MULTILINE) }
|
13
|
+
subject(:sample) { RubyCommunicatorLogger.new(logger, logLevel, errorLevel) }
|
14
|
+
|
15
|
+
def expected_msg(msg, thrown=false)
|
16
|
+
return msg unless thrown
|
17
|
+
msg + $RS + thrown.backtrace.join($RS)
|
18
|
+
end
|
19
|
+
|
20
|
+
after do
|
21
|
+
# delete the log files
|
22
|
+
logger.close
|
23
|
+
File.delete(filename)
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'logging without error' do
|
27
|
+
|
28
|
+
let(:errorLevel) { Logger::WARN }
|
29
|
+
let(:msg) { 'Hello World' }
|
30
|
+
|
31
|
+
context "with level 'INFO'" do
|
32
|
+
let(:logLevel) { Logger::INFO }
|
33
|
+
let(:tag) { 'I' }
|
34
|
+
|
35
|
+
it 'logs with the correct logLevel and message' do
|
36
|
+
sample.log(msg)
|
37
|
+
line = IO.readlines(filename).last
|
38
|
+
|
39
|
+
expect(line).to match(regex)
|
40
|
+
expect(
|
41
|
+
line.match(regex)[1] # first capture
|
42
|
+
).to eq(expected_msg(msg))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "with level 'WARN'" do
|
47
|
+
let(:logLevel) { Logger::WARN }
|
48
|
+
let(:tag) { 'W' }
|
49
|
+
|
50
|
+
it 'logs with the correct logLevel and message' do
|
51
|
+
sample.log(msg)
|
52
|
+
line = IO.readlines(filename).last
|
53
|
+
|
54
|
+
expect(line).to match(regex)
|
55
|
+
expect(
|
56
|
+
line.match(regex)[1] # idem
|
57
|
+
).to eq(expected_msg(msg))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'logging with error' do
|
63
|
+
let(:errorLevel) { Logger::WARN }
|
64
|
+
let(:logLevel) { Logger::INFO }
|
65
|
+
let(:msg) { 'Some error message' }
|
66
|
+
let(:tag) { 'W' }
|
67
|
+
|
68
|
+
it 'logs with the errorLevel and message with backtrace' do
|
69
|
+
def dummy_method
|
70
|
+
raise 'Boom!'
|
71
|
+
end
|
72
|
+
|
73
|
+
begin
|
74
|
+
dummy_method
|
75
|
+
rescue => exception
|
76
|
+
sample.log(msg, exception)
|
77
|
+
end
|
78
|
+
|
79
|
+
line = IO.read(filename)
|
80
|
+
expect(line).to match(regex)
|
81
|
+
expect(line.match(regex)[1]).to eq(expected_msg(msg, exception))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'English'
|
3
|
+
|
4
|
+
StdoutCommunicatorLogger ||= Ingenico::Connect::SDK::Logging::StdoutCommunicatorLogger
|
5
|
+
|
6
|
+
describe StdoutCommunicatorLogger do
|
7
|
+
before do
|
8
|
+
$stdout = StringIO.new
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
$stdout.close
|
13
|
+
$stdout = STDOUT
|
14
|
+
end
|
15
|
+
|
16
|
+
subject(:sample) { StdoutCommunicatorLogger.INSTANCE }
|
17
|
+
let(:regex) do
|
18
|
+
Regexp.new("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2} (.*)#{$RS}",
|
19
|
+
Regexp::MULTILINE)
|
20
|
+
end
|
21
|
+
|
22
|
+
def expected_msg(msg, thrown=false)
|
23
|
+
return msg unless thrown
|
24
|
+
msg + $RS + thrown.backtrace.join($RS)
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'test log' do
|
28
|
+
let(:msg) { 'Hello World' }
|
29
|
+
|
30
|
+
it 'should log the exact message' do
|
31
|
+
sample.log(msg)
|
32
|
+
|
33
|
+
expect(
|
34
|
+
$stdout.string
|
35
|
+
).to match(regex)
|
36
|
+
|
37
|
+
expect(
|
38
|
+
regex.match($stdout.string)[1] # first capture
|
39
|
+
).to eq(expected_msg(msg))
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should log the backtrace of the exception' do
|
43
|
+
|
44
|
+
def dummy_method
|
45
|
+
raise 'Boom!'
|
46
|
+
end
|
47
|
+
|
48
|
+
begin
|
49
|
+
dummy_method
|
50
|
+
rescue => exception
|
51
|
+
sample.log(msg, exception)
|
52
|
+
end
|
53
|
+
|
54
|
+
expect(
|
55
|
+
$stdout.string
|
56
|
+
).to match(regex)
|
57
|
+
|
58
|
+
expect(
|
59
|
+
regex.match($stdout.string)[1] # first capture
|
60
|
+
).to eq(expected_msg(msg, exception))
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Ingenico::Connect::SDK::Logging
|
4
|
+
|
5
|
+
describe ValueObfuscator do
|
6
|
+
let(:fixed_length) { 10 }
|
7
|
+
let(:keep_start_count) { 20 }
|
8
|
+
let(:keep_end_count) { 30 }
|
9
|
+
|
10
|
+
it 'can be initialized correctly' do
|
11
|
+
sample = ValueObfuscator.send(:new, fixed_length,
|
12
|
+
keep_start_count, keep_end_count)
|
13
|
+
expect(sample.instance_variable_get(:@fixed_length)).to eq(10)
|
14
|
+
expect(sample.instance_variable_get(:@keep_start_count)).to eq(20)
|
15
|
+
expect(sample.instance_variable_get(:@keep_end_count)).to eq(30)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'has the correct class variable ALL' do
|
19
|
+
sample = ValueObfuscator.ALL
|
20
|
+
expect(sample.instance_variable_get(:@fixed_length)).to eq(0)
|
21
|
+
expect(sample.instance_variable_get(:@keep_start_count)).to eq(0)
|
22
|
+
expect(sample.instance_variable_get(:@keep_end_count)).to eq(0)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'can be initialized only with fixed_length' do
|
26
|
+
sample = ValueObfuscator.fixed_length(fixed_length)
|
27
|
+
expect(sample.instance_variable_get(:@fixed_length)).to eq(10)
|
28
|
+
expect(sample.instance_variable_get(:@keep_start_count)).to eq(0)
|
29
|
+
expect(sample.instance_variable_get(:@keep_end_count)).to eq(0)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'can be initialized only with keep_start_count' do
|
33
|
+
sample = ValueObfuscator.keep_start_count(keep_start_count)
|
34
|
+
expect(sample.instance_variable_get(:@fixed_length)).to eq(0)
|
35
|
+
expect(sample.instance_variable_get(:@keep_start_count)).to eq(20)
|
36
|
+
expect(sample.instance_variable_get(:@keep_end_count)).to eq(0)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'can be initialized only with keep_end_count' do
|
40
|
+
sample = ValueObfuscator.keep_end_count(keep_end_count)
|
41
|
+
expect(sample.instance_variable_get(:@fixed_length)).to eq(0)
|
42
|
+
expect(sample.instance_variable_get(:@keep_start_count)).to eq(0)
|
43
|
+
expect(sample.instance_variable_get(:@keep_end_count)).to eq(30)
|
44
|
+
end
|
45
|
+
|
46
|
+
context '.repeat_mask' do
|
47
|
+
it 'returns the correct mask' do
|
48
|
+
sample = ValueObfuscator.ALL
|
49
|
+
expect(sample.send(:repeat_mask, 5)).to eq('*' * 5)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context '.obfuscate_value' do
|
54
|
+
subject(:sample) { ValueObfuscator.send(:new, fixed_length,
|
55
|
+
keep_start_count, keep_end_count) }
|
56
|
+
let(:value) { 'str' }
|
57
|
+
|
58
|
+
it 'returns nil if value is nil' do
|
59
|
+
expect(sample.obfuscate_value(nil)).to be_nil
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'returns empty string if value has length 0' do
|
63
|
+
expect(sample.obfuscate_value('')).to eq ('')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'calls repeak_mask(@fixed_length) if @fixed_length is not 0' do
|
67
|
+
expect(
|
68
|
+
sample.obfuscate_value('str')
|
69
|
+
).to eq(sample.send(:repeat_mask, fixed_length))
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'calls repeak_mask(value.length) if using ALL' do
|
73
|
+
expect(
|
74
|
+
ValueObfuscator.ALL.obfuscate_value(value)
|
75
|
+
).to eq(sample.send(:repeat_mask, value.length))
|
76
|
+
end
|
77
|
+
|
78
|
+
context '.keep_start_count or .keep_end_count' do
|
79
|
+
subject(:sample) { ValueObfuscator.keep_start_count(5) }
|
80
|
+
|
81
|
+
it 'returns orignal value if value is too short' do
|
82
|
+
expect(
|
83
|
+
sample.obfuscate_value('str')
|
84
|
+
).to eq('str')
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'returns masked string if value is long enough' do
|
88
|
+
str = 'this str is long enough'
|
89
|
+
expect(
|
90
|
+
sample.obfuscate_value(str)
|
91
|
+
).to eq('this ' + '*' * (str.length - 5))
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ingenico/connect/sdk/domain/metadata/shopping_cart_extension'
|
3
|
+
require 'base64'
|
4
|
+
|
5
|
+
describe 'MetaDataProvider' do
|
6
|
+
|
7
|
+
MetaDataProvider ||= Ingenico::Connect::SDK::MetaDataProvider
|
8
|
+
RequestHeader ||= Ingenico::Connect::SDK::RequestHeader
|
9
|
+
|
10
|
+
it 'can give meta_data_headers with a full shopping cart' do
|
11
|
+
shopping_cart_extension = Ingenico::Connect::SDK::Domain::Metadata::ShoppingCartExtension.new('Ingenico.creator', 'Extension', '1.0')
|
12
|
+
meta_data_provider = MetaDataProvider.new('Ingenico', shopping_cart_extension: shopping_cart_extension)
|
13
|
+
|
14
|
+
request_headers = meta_data_provider.meta_data_headers
|
15
|
+
expect(request_headers.length).to eq(1)
|
16
|
+
expect(request_headers.length).to eq(1)
|
17
|
+
|
18
|
+
# Server meta info is stored in json format and encoded using utf-8 and base64
|
19
|
+
server_meta_info_json = Base64.strict_decode64(request_headers[0].value).force_encoding('utf-8')
|
20
|
+
server_meta_info = Ingenico::Connect::SDK::DefaultImpl::DefaultMarshaller.INSTANCE.unmarshal(server_meta_info_json, MetaDataProvider::ServerMetaInfo)
|
21
|
+
|
22
|
+
expect(server_meta_info.platform_identifier).to eq(meta_data_provider.send(:get_platform_identifier))
|
23
|
+
expect(server_meta_info.sdk_identifier).to eq(meta_data_provider.send(:get_sdk_identifier))
|
24
|
+
expect(server_meta_info.sdk_creator).to eq('Ingenico')
|
25
|
+
expect(server_meta_info.shopping_cart_extension.creator).to eq(shopping_cart_extension.creator)
|
26
|
+
expect(server_meta_info.shopping_cart_extension.name).to eq(shopping_cart_extension.name)
|
27
|
+
expect(server_meta_info.shopping_cart_extension.version).to eq(shopping_cart_extension.version)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'provides a server_meta_info header when no additional headers are provided' do
|
31
|
+
meta_data_provider = MetaDataProvider.new('Ingenico')
|
32
|
+
|
33
|
+
request_headers = meta_data_provider.meta_data_headers
|
34
|
+
expect(request_headers.length).to eq(1)
|
35
|
+
expect(request_headers[0].name).to eq('X-GCS-ServerMetaInfo')
|
36
|
+
expect(request_headers[0].value).to_not be_nil
|
37
|
+
|
38
|
+
# Server meta info is stored in json format and encoded using utf-8 and base64
|
39
|
+
server_meta_info_json = Base64.strict_decode64(request_headers[0].value).force_encoding('utf-8')
|
40
|
+
server_meta_info = Ingenico::Connect::SDK::DefaultImpl::DefaultMarshaller.INSTANCE.unmarshal(server_meta_info_json, MetaDataProvider::ServerMetaInfo)
|
41
|
+
|
42
|
+
expect(server_meta_info.platform_identifier).to eq(meta_data_provider.send(:get_platform_identifier))
|
43
|
+
expect(server_meta_info.sdk_identifier).to eq(meta_data_provider.send(:get_sdk_identifier))
|
44
|
+
expect(server_meta_info.sdk_creator).to eq('Ingenico')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'provides a server_meta_info header and any additional headers provided' do
|
48
|
+
additional_headers = [RequestHeader.new('Header1', '&=$%'), RequestHeader.new('Header2', 'blah, blah'),
|
49
|
+
RequestHeader.new('Header3', 'foo')]
|
50
|
+
meta_data_provider = MetaDataProvider.new('Ingenico', additional_request_headers: additional_headers)
|
51
|
+
request_headers = meta_data_provider.meta_data_headers
|
52
|
+
|
53
|
+
expect(request_headers.length).to eq(4)
|
54
|
+
|
55
|
+
i = 1
|
56
|
+
additional_headers.each do |header|
|
57
|
+
expect(request_headers[i]).to eq(header)
|
58
|
+
i += 1
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'refuses headers marked as prohibited' do
|
63
|
+
MetaDataProvider.PROHIBITED_HEADERS.each do |name|
|
64
|
+
additional_headers = [RequestHeader.new('Header1', 'Value1'),
|
65
|
+
RequestHeader.new(name, 'blood diamonds'),
|
66
|
+
RequestHeader.new('Header3', 'Value3')]
|
67
|
+
expect{MetaDataProvider.new('Ingenico', additional_request_headers: additional_headers)}
|
68
|
+
.to raise_error{|error| expect(error.message).to include(name)}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|