braintree 2.10.0 → 4.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/braintree.gemspec +24 -0
- data/lib/braintree/account_updater_daily_report.rb +20 -0
- data/lib/braintree/ach_mandate.rb +14 -0
- data/lib/braintree/add_on.rb +4 -0
- data/lib/braintree/add_on_gateway.rb +17 -0
- data/lib/braintree/address/country_names.rb +4 -1
- data/lib/braintree/address.rb +35 -43
- data/lib/braintree/address_gateway.rb +24 -11
- data/lib/braintree/advanced_search.rb +26 -11
- data/lib/braintree/apple_pay.rb +29 -0
- data/lib/braintree/apple_pay_card.rb +66 -0
- data/lib/braintree/apple_pay_gateway.rb +37 -0
- data/lib/braintree/apple_pay_options.rb +19 -0
- data/lib/braintree/authorization_adjustment.rb +23 -0
- data/lib/braintree/base_module.rb +11 -1
- data/lib/braintree/bin_data.rb +34 -0
- data/lib/braintree/client_token.rb +11 -0
- data/lib/braintree/client_token_gateway.rb +45 -0
- data/lib/braintree/configuration.rb +231 -39
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +22 -0
- data/lib/braintree/connected_merchant_status_transitioned.rb +22 -0
- data/lib/braintree/credentials_parser.rb +44 -0
- data/lib/braintree/credit_card.rb +107 -132
- data/lib/braintree/credit_card_gateway.rb +90 -41
- data/lib/braintree/credit_card_verification.rb +90 -17
- data/lib/braintree/credit_card_verification_gateway.rb +87 -0
- data/lib/braintree/credit_card_verification_search.rb +20 -0
- data/lib/braintree/customer.rb +80 -118
- data/lib/braintree/customer_gateway.rb +66 -39
- data/lib/braintree/customer_search.rb +5 -2
- data/lib/braintree/customer_session_gateway.rb +194 -0
- data/lib/braintree/descriptor.rb +4 -2
- data/lib/braintree/digest.rb +16 -3
- data/lib/braintree/disbursement.rb +63 -0
- data/lib/braintree/discount.rb +4 -0
- data/lib/braintree/discount_gateway.rb +17 -0
- data/lib/braintree/dispute/evidence.rb +24 -0
- data/lib/braintree/dispute/paypal_message.rb +15 -0
- data/lib/braintree/dispute/status_history.rb +18 -0
- data/lib/braintree/dispute/transaction.rb +20 -0
- data/lib/braintree/dispute/transaction_details.rb +15 -0
- data/lib/braintree/dispute.rb +165 -0
- data/lib/braintree/dispute_gateway.rb +142 -0
- data/lib/braintree/dispute_search.rb +31 -0
- data/lib/braintree/document_upload.rb +37 -0
- data/lib/braintree/document_upload_gateway.rb +38 -0
- data/lib/braintree/enriched_customer_data.rb +21 -0
- data/lib/braintree/error_codes.rb +680 -15
- data/lib/braintree/error_result.rb +13 -6
- data/lib/braintree/errors.rb +5 -5
- data/lib/braintree/exceptions.rb +14 -20
- data/lib/braintree/exchange_rate.rb +13 -0
- data/lib/braintree/exchange_rate_quote.rb +24 -0
- data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
- data/lib/braintree/exchange_rate_quote_input.rb +21 -0
- data/lib/braintree/exchange_rate_quote_request.rb +18 -0
- data/lib/braintree/exchange_rate_quote_response.rb +18 -0
- data/lib/braintree/facilitated_details.rb +21 -0
- data/lib/braintree/facilitator_details.rb +20 -0
- data/lib/braintree/gateway.rb +104 -6
- data/lib/braintree/google_pay_card.rb +62 -0
- data/lib/braintree/granted_payment_instrument_update.rb +23 -0
- data/lib/braintree/graphql/enums/recommendations.rb +7 -0
- data/lib/braintree/graphql/enums/recommended_payment_option.rb +8 -0
- data/lib/braintree/graphql/inputs/create_customer_session_input.rb +35 -0
- data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +41 -0
- data/lib/braintree/graphql/inputs/customer_session_input.rb +39 -0
- data/lib/braintree/graphql/inputs/phone_input.rb +32 -0
- data/lib/braintree/graphql/inputs/update_customer_session_input.rb +37 -0
- data/lib/braintree/graphql/types/customer_recommendations_payload.rb +32 -0
- data/lib/braintree/graphql/types/payment_options.rb +33 -0
- data/lib/braintree/graphql/unions/customer_recommendations.rb +34 -0
- data/lib/braintree/graphql_client.rb +50 -0
- data/lib/braintree/http.rb +119 -25
- data/lib/braintree/local_payment_completed/blik_alias.rb +23 -0
- data/lib/braintree/local_payment_completed.rb +28 -0
- data/lib/braintree/local_payment_expired.rb +21 -0
- data/lib/braintree/local_payment_funded.rb +22 -0
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +34 -0
- data/lib/braintree/merchant_account/address_details.rb +16 -0
- data/lib/braintree/merchant_account/business_details.rb +17 -0
- data/lib/braintree/merchant_account/funding_details.rb +18 -0
- data/lib/braintree/merchant_account/individual_details.rb +20 -0
- data/lib/braintree/merchant_account.rb +76 -0
- data/lib/braintree/merchant_account_gateway.rb +130 -0
- data/lib/braintree/merchant_gateway.rb +38 -0
- data/lib/braintree/meta_checkout_card.rb +90 -0
- data/lib/braintree/meta_checkout_token.rb +89 -0
- data/lib/braintree/modification.rb +16 -5
- data/lib/braintree/oauth_credentials.rb +22 -0
- data/lib/braintree/oauth_gateway.rb +73 -0
- data/lib/braintree/paginated_collection.rb +25 -0
- data/lib/braintree/paginated_result.rb +15 -0
- data/lib/braintree/payment_instrument_type.rb +18 -0
- data/lib/braintree/payment_method.rb +37 -0
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
- data/lib/braintree/payment_method_gateway.rb +221 -0
- data/lib/braintree/payment_method_nonce.rb +49 -0
- data/lib/braintree/payment_method_nonce_details.rb +40 -0
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +38 -0
- data/lib/braintree/payment_method_parser.rb +29 -0
- data/lib/braintree/paypal_account.rb +60 -0
- data/lib/braintree/paypal_account_gateway.rb +73 -0
- data/lib/braintree/paypal_payment_resource.rb +22 -0
- data/lib/braintree/paypal_payment_resource_gateway.rb +36 -0
- data/lib/braintree/plan.rb +62 -0
- data/lib/braintree/plan_gateway.rb +117 -0
- data/lib/braintree/processor_response_types.rb +7 -0
- data/lib/braintree/resource_collection.rb +12 -5
- data/lib/braintree/revoked_payment_method_metadata.rb +22 -0
- data/lib/braintree/risk_data/liability_shift.rb +22 -0
- data/lib/braintree/risk_data.rb +29 -0
- data/lib/braintree/samsung_pay_card.rb +85 -0
- data/lib/braintree/sepa_direct_debit_account.rb +60 -0
- data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
- data/lib/braintree/settlement_batch_summary.rb +25 -0
- data/lib/braintree/settlement_batch_summary_gateway.rb +27 -0
- data/lib/braintree/sha256_digest.rb +13 -0
- data/lib/braintree/signature_service.rb +19 -0
- data/lib/braintree/subscription/status_details.rb +20 -0
- data/lib/braintree/subscription.rb +67 -47
- data/lib/braintree/subscription_gateway.rb +43 -16
- data/lib/braintree/subscription_search.rb +2 -2
- data/lib/braintree/successful_result.rb +30 -10
- data/lib/braintree/test/authentication_id.rb +21 -0
- data/lib/braintree/test/credit_card.rb +76 -0
- data/lib/braintree/test/merchant_account.rb +12 -0
- data/lib/braintree/test/nonce.rb +81 -0
- data/lib/braintree/test/transaction_amounts.rb +3 -5
- data/lib/braintree/test/venmo_sdk.rb +21 -0
- data/lib/braintree/test_transaction.rb +19 -0
- data/lib/braintree/testing_gateway.rb +43 -0
- data/lib/braintree/three_d_secure_info.rb +53 -0
- data/lib/braintree/transaction/address_details.rb +27 -5
- data/lib/braintree/transaction/apple_pay_details.rb +35 -0
- data/lib/braintree/transaction/credit_card_details.rb +55 -4
- data/lib/braintree/transaction/customer_details.rb +11 -3
- data/lib/braintree/transaction/disbursement_details.rb +28 -0
- data/lib/braintree/transaction/google_pay_details.rb +42 -0
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/local_payment_details.rb +27 -0
- data/lib/braintree/transaction/meta_checkout_card_details.rb +55 -0
- data/lib/braintree/transaction/meta_checkout_token_details.rb +58 -0
- data/lib/braintree/transaction/package_details.rb +19 -0
- data/lib/braintree/transaction/payment_receipt/card_present_data.rb +36 -0
- data/lib/braintree/transaction/payment_receipt/merchant_address.rb +19 -0
- data/lib/braintree/transaction/payment_receipt.rb +31 -0
- data/lib/braintree/transaction/paypal_details.rb +40 -0
- data/lib/braintree/transaction/paypal_here_details.rb +23 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +50 -0
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
- data/lib/braintree/transaction/status_details.rb +6 -2
- data/lib/braintree/transaction/subscription_details.rb +5 -2
- data/lib/braintree/transaction/us_bank_account_details.rb +22 -0
- data/lib/braintree/transaction/venmo_account_details.rb +17 -0
- data/lib/braintree/transaction/visa_checkout_card_details.rb +51 -0
- data/lib/braintree/transaction.rb +293 -150
- data/lib/braintree/transaction_gateway.rb +303 -59
- data/lib/braintree/transaction_line_item.rb +43 -0
- data/lib/braintree/transaction_line_item_gateway.rb +19 -0
- data/lib/braintree/transaction_review.rb +18 -0
- data/lib/braintree/transaction_search.rb +17 -9
- data/lib/braintree/unknown_payment_method.rb +26 -0
- data/lib/braintree/us_bank_account.rb +57 -0
- data/lib/braintree/us_bank_account_gateway.rb +17 -0
- data/lib/braintree/us_bank_account_verification.rb +89 -0
- data/lib/braintree/us_bank_account_verification_gateway.rb +51 -0
- data/lib/braintree/us_bank_account_verification_search.rb +19 -0
- data/lib/braintree/util.rb +91 -11
- data/lib/braintree/validation_error.rb +14 -5
- data/lib/braintree/validation_error_collection.rb +5 -5
- data/lib/braintree/venmo_account.rb +34 -0
- data/lib/braintree/venmo_profile_data.rb +25 -0
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +90 -0
- data/lib/braintree/webhook_notification.rb +146 -0
- data/lib/braintree/webhook_notification_gateway.rb +46 -0
- data/lib/braintree/webhook_testing.rb +7 -0
- data/lib/braintree/webhook_testing_gateway.rb +1239 -0
- data/lib/braintree/xml/generator.rb +18 -10
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +24 -36
- data/lib/braintree/xml/rexml.rb +6 -7
- data/lib/braintree/xml.rb +1 -2
- data/lib/braintree.rb +186 -52
- data/lib/ssl/api_braintreegateway_com.ca.crt +474 -0
- data/spec/fixtures/files/bt_logo.png +0 -0
- data/spec/fixtures/files/gif_extension_bt_logo.gif +0 -0
- data/spec/fixtures/files/malformed_pdf.pdf +1 -0
- data/spec/fixtures/files/too_long.pdf +0 -0
- data/spec/integration/braintree/add_on_spec.rb +46 -0
- data/spec/integration/braintree/address_spec.rb +101 -178
- data/spec/integration/braintree/advanced_search_spec.rb +100 -97
- data/spec/integration/braintree/apple_pay_spec.rb +63 -0
- data/spec/integration/braintree/braintree_gateway_spec.rb +72 -0
- data/spec/integration/braintree/client_api/client_token_spec.rb +407 -0
- data/spec/integration/braintree/client_api/spec_helper.rb +300 -0
- data/spec/integration/braintree/credit_card_spec.rb +885 -654
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +193 -0
- data/spec/integration/braintree/credit_card_verification_spec.rb +473 -0
- data/spec/integration/braintree/customer_search_spec.rb +69 -21
- data/spec/integration/braintree/customer_session_spec.rb +143 -0
- data/spec/integration/braintree/customer_spec.rb +1437 -518
- data/spec/integration/braintree/disbursement_spec.rb +31 -0
- data/spec/integration/braintree/discount_spec.rb +34 -0
- data/spec/integration/braintree/dispute_search_spec.rb +165 -0
- data/spec/integration/braintree/dispute_spec.rb +333 -0
- data/spec/integration/braintree/document_upload_spec.rb +87 -0
- data/spec/integration/braintree/error_codes_spec.rb +3 -3
- data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
- data/spec/integration/braintree/graphql_client_spec.rb +72 -0
- data/spec/integration/braintree/http_spec.rb +106 -56
- data/spec/integration/braintree/merchant_account_spec.rb +603 -0
- data/spec/integration/braintree/merchant_spec.rb +227 -0
- data/spec/integration/braintree/oauth_spec.rb +225 -0
- data/spec/integration/braintree/package_tracking_spec.rb +130 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +345 -0
- data/spec/integration/braintree/payment_method_spec.rb +2146 -0
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +325 -0
- data/spec/integration/braintree/paypal_account_spec.rb +299 -0
- data/spec/integration/braintree/paypal_payment_resource_spec.rb +141 -0
- data/spec/integration/braintree/plan_spec.rb +136 -0
- data/spec/integration/braintree/samsung_pay_card_spec.rb +146 -0
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +194 -0
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +62 -0
- data/spec/integration/braintree/subscription_spec.rb +785 -431
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +4 -4
- data/spec/integration/braintree/test_transaction_spec.rb +145 -0
- data/spec/integration/braintree/transaction_line_item_spec.rb +44 -0
- data/spec/integration/braintree/transaction_search_spec.rb +745 -156
- data/spec/integration/braintree/transaction_spec.rb +7452 -1288
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +196 -0
- data/spec/integration/braintree/us_bank_account_spec.rb +113 -0
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +178 -0
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +240 -0
- data/spec/integration/braintree/visa_checkout_card_spec.rb +110 -0
- data/spec/integration/spec_helper.rb +61 -5
- data/spec/oauth_test_helper.rb +17 -0
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +77 -21
- data/spec/ssl/certificate.crt +17 -0
- data/spec/ssl/geotrust_global.crt +20 -0
- data/spec/ssl/privateKey.key +15 -0
- data/spec/unit/braintree/address_spec.rb +27 -16
- data/spec/unit/braintree/apple_pay_card_spec.rb +133 -0
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +37 -0
- data/spec/unit/braintree/configuration_spec.rb +293 -43
- data/spec/unit/braintree/credentials_parser_spec.rb +81 -0
- data/spec/unit/braintree/credit_card_spec.rb +138 -47
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +56 -0
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +79 -0
- data/spec/unit/braintree/credit_card_verification_spec.rb +132 -6
- data/spec/unit/braintree/customer_session_gateway_spec.rb +120 -0
- data/spec/unit/braintree/customer_spec.rb +196 -40
- data/spec/unit/braintree/digest_spec.rb +16 -3
- data/spec/unit/braintree/disbursement_spec.rb +131 -0
- data/spec/unit/braintree/dispute_search_spec.rb +66 -0
- data/spec/unit/braintree/dispute_spec.rb +479 -0
- data/spec/unit/braintree/document_upload_spec.rb +35 -0
- data/spec/unit/braintree/enriched_customer_data_spec.rb +41 -0
- data/spec/unit/braintree/error_result_spec.rb +11 -11
- data/spec/unit/braintree/errors_spec.rb +17 -17
- data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
- data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
- data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
- data/spec/unit/braintree/google_pay_card_spec.rb +8 -0
- data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +81 -0
- data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +110 -0
- data/spec/unit/braintree/graphql/customer_session_input_spec.rb +81 -0
- data/spec/unit/braintree/graphql/phone_input_spec.rb +51 -0
- data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +93 -0
- data/spec/unit/braintree/graphql_client_spec.rb +37 -0
- data/spec/unit/braintree/http_spec.rb +164 -2
- data/spec/unit/braintree/local_payment_completed_spec.rb +90 -0
- data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
- data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
- data/spec/unit/braintree/merchant_account_spec.rb +33 -0
- data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +62 -0
- data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +65 -0
- data/spec/unit/braintree/modification_spec.rb +7 -0
- data/spec/unit/braintree/package_tracking_spec.rb +77 -0
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +51 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +43 -0
- data/spec/unit/braintree/payment_method_spec.rb +135 -0
- data/spec/unit/braintree/paypal_account_spec.rb +53 -0
- data/spec/unit/braintree/paypal_payment_resource_spec.rb +125 -0
- data/spec/unit/braintree/resource_collection_spec.rb +44 -3
- data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
- data/spec/unit/braintree/risk_data_spec.rb +55 -0
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
- data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
- data/spec/unit/braintree/sha256_digest_spec.rb +11 -0
- data/spec/unit/braintree/signature_service_spec.rb +23 -0
- data/spec/unit/braintree/subscription_search_spec.rb +25 -18
- data/spec/unit/braintree/subscription_spec.rb +34 -7
- data/spec/unit/braintree/successful_result_spec.rb +9 -9
- data/spec/unit/braintree/three_d_secure_info_spec.rb +69 -0
- data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +8 -0
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +34 -6
- data/spec/unit/braintree/transaction/customer_details_spec.rb +3 -2
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +18 -0
- data/spec/unit/braintree/transaction/google_pay_details_spec.rb +8 -0
- data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +36 -0
- data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +8 -0
- data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +8 -0
- data/spec/unit/braintree/transaction/payment_receipt_spec.rb +73 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +68 -0
- data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
- data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +8 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +150 -0
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +366 -52
- data/spec/unit/braintree/unknown_payment_method_spec.rb +33 -0
- data/spec/unit/braintree/us_bank_account_spec.rb +13 -0
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +60 -0
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +98 -0
- data/spec/unit/braintree/util_spec.rb +199 -39
- data/spec/unit/braintree/validation_error_collection_spec.rb +336 -133
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +43 -0
- data/spec/unit/braintree/visa_checkout_card_spec.rb +8 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +977 -0
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +39 -5
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +39 -32
- data/spec/unit/braintree_spec.rb +3 -2
- data/spec/unit/credit_card_details_spec.rb +8 -0
- metadata +314 -73
- data/README.rdoc +0 -80
- data/lib/braintree/test/credit_card_numbers.rb +0 -52
- data/lib/braintree/transparent_redirect.rb +0 -51
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/lib/ssl/sandbox_braintreegateway_com.ca.crt +0 -19
- data/lib/ssl/www_braintreegateway_com.ca.crt +0 -202
- data/spec/hacks/tcp_socket.rb +0 -18
- data/spec/integration/braintree/transparent_redirect_spec.rb +0 -236
- data/spec/unit/braintree/transparent_redirect_spec.rb +0 -160
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require "stringio"
|
|
2
|
+
|
|
1
3
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
4
|
|
|
3
5
|
describe Braintree::Configuration do
|
|
@@ -11,14 +13,113 @@ describe Braintree::Configuration do
|
|
|
11
13
|
|
|
12
14
|
after do
|
|
13
15
|
Braintree::Configuration.merchant_id = @original_merchant_id
|
|
14
|
-
Braintree::Configuration.public_key
|
|
16
|
+
Braintree::Configuration.public_key = @original_public_key
|
|
15
17
|
Braintree::Configuration.private_key = @original_private_key
|
|
16
18
|
Braintree::Configuration.environment = @original_environment
|
|
19
|
+
Braintree::Configuration.endpoint = Braintree::Configuration::DEFAULT_ENDPOINT
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe "initialize" do
|
|
23
|
+
it "accepts merchant credentials" do
|
|
24
|
+
config = Braintree::Configuration.new(
|
|
25
|
+
:merchant_id => "merchant_id",
|
|
26
|
+
:public_key => "public_key",
|
|
27
|
+
:private_key => "private_key",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
expect(config.merchant_id).to eq("merchant_id")
|
|
31
|
+
expect(config.public_key).to eq("public_key")
|
|
32
|
+
expect(config.private_key).to eq("private_key")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "accepts partner credentials" do
|
|
36
|
+
config = Braintree::Configuration.new(
|
|
37
|
+
:partner_id => "partner_id",
|
|
38
|
+
:public_key => "public_key",
|
|
39
|
+
:private_key => "private_key",
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
expect(config.merchant_id).to eq("partner_id")
|
|
43
|
+
expect(config.public_key).to eq("public_key")
|
|
44
|
+
expect(config.private_key).to eq("private_key")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "raises if combining client_id/secret with access_token" do
|
|
48
|
+
expect do
|
|
49
|
+
Braintree::Configuration.new(
|
|
50
|
+
:client_id => "client_id$development$integration_client_id",
|
|
51
|
+
:client_secret => "client_secret$development$integration_client_secret",
|
|
52
|
+
:access_token => "access_token$development$integration_merchant_id$fb27c79dd",
|
|
53
|
+
)
|
|
54
|
+
end.to raise_error(Braintree::ConfigurationError, /mixed credential types/)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "raises if combining client_id/secret with public_key/private_key" do
|
|
58
|
+
expect do
|
|
59
|
+
Braintree::Configuration.new(
|
|
60
|
+
:client_id => "client_id$development$integration_client_id",
|
|
61
|
+
:client_secret => "client_secret$development$integration_client_secret",
|
|
62
|
+
:merchant_id => "merchant_id",
|
|
63
|
+
:public_key => "public_key",
|
|
64
|
+
:private_key => "private_key",
|
|
65
|
+
:environment => "development",
|
|
66
|
+
)
|
|
67
|
+
end.to raise_error(Braintree::ConfigurationError, /mixed credential types/)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context "mixed environments" do
|
|
71
|
+
before do
|
|
72
|
+
@original_stderr = $stderr
|
|
73
|
+
$stderr = StringIO.new
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
after do
|
|
77
|
+
$stderr = @original_stderr
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "warns if both environment and access_token are provided and their environments differ" do
|
|
81
|
+
Braintree::Configuration.new(
|
|
82
|
+
:access_token => "access_token$development$integration_merchant_id$fb27c79dd",
|
|
83
|
+
:environment => "sandbox",
|
|
84
|
+
)
|
|
85
|
+
expect($stderr.string).to eq("Braintree::Gateway should not be initialized with mixed environments: environment parameter and access_token do not match, environment from access_token is used.\n")
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "does not warn if both environment and access_token are provided and their environments match" do
|
|
89
|
+
Braintree::Configuration.new(
|
|
90
|
+
:access_token => "access_token$development$integration_merchant_id$fb27c79dd",
|
|
91
|
+
:environment => "development",
|
|
92
|
+
)
|
|
93
|
+
expect($stderr.string).to eq("")
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "accepts proxy params" do
|
|
98
|
+
config = Braintree::Configuration.new(
|
|
99
|
+
:proxy_address => "localhost",
|
|
100
|
+
:proxy_port => 8080,
|
|
101
|
+
:proxy_user => "user",
|
|
102
|
+
:proxy_pass => "test",
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
expect(config.proxy_address).to eq("localhost")
|
|
106
|
+
expect(config.proxy_port).to eq(8080)
|
|
107
|
+
expect(config.proxy_user).to eq("user")
|
|
108
|
+
expect(config.proxy_pass).to eq("test")
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it "accepts ssl version" do
|
|
112
|
+
config = Braintree::Configuration.new(
|
|
113
|
+
:ssl_version => :TLSv1_2,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
expect(config.ssl_version).to eq(:TLSv1_2)
|
|
117
|
+
end
|
|
17
118
|
end
|
|
18
119
|
|
|
19
120
|
describe "base_merchant_path" do
|
|
20
121
|
it "returns /merchants/{merchant_id}" do
|
|
21
|
-
Braintree::Configuration.instantiate.base_merchant_path.
|
|
122
|
+
expect(Braintree::Configuration.instantiate.base_merchant_path).to eq("/merchants/integration_merchant_id")
|
|
22
123
|
end
|
|
23
124
|
end
|
|
24
125
|
|
|
@@ -26,52 +127,58 @@ describe Braintree::Configuration do
|
|
|
26
127
|
it "returns the expected url for the development env" do
|
|
27
128
|
Braintree::Configuration.environment = :development
|
|
28
129
|
port = Braintree::Configuration.instantiate.port
|
|
29
|
-
Braintree::Configuration.instantiate.base_merchant_url.
|
|
130
|
+
expect(Braintree::Configuration.instantiate.base_merchant_url).to eq("http://localhost:#{port}/merchants/integration_merchant_id")
|
|
30
131
|
end
|
|
31
132
|
|
|
32
133
|
it "returns the expected url for the sandbox env" do
|
|
33
134
|
Braintree::Configuration.environment = :sandbox
|
|
34
|
-
Braintree::Configuration.instantiate.base_merchant_url.
|
|
135
|
+
expect(Braintree::Configuration.instantiate.base_merchant_url).to eq("https://api.sandbox.braintreegateway.com:443/merchants/integration_merchant_id")
|
|
35
136
|
end
|
|
36
137
|
|
|
37
138
|
it "returns the expected url for the production env" do
|
|
38
139
|
Braintree::Configuration.environment = :production
|
|
39
|
-
Braintree::Configuration.instantiate.base_merchant_url.
|
|
140
|
+
expect(Braintree::Configuration.instantiate.base_merchant_url).to eq("https://api.braintreegateway.com:443/merchants/integration_merchant_id")
|
|
40
141
|
end
|
|
41
142
|
end
|
|
42
143
|
|
|
43
144
|
describe "ca_file" do
|
|
44
|
-
it "qa" do
|
|
45
|
-
Braintree::Configuration.environment = :qa
|
|
46
|
-
ca_file = Braintree::Configuration.instantiate.ca_file
|
|
47
|
-
ca_file.should match(/sandbox_braintreegateway_com.ca.crt$/)
|
|
48
|
-
File.exists?(ca_file).should == true
|
|
49
|
-
end
|
|
50
|
-
|
|
51
145
|
it "sandbox" do
|
|
52
146
|
Braintree::Configuration.environment = :sandbox
|
|
53
147
|
ca_file = Braintree::Configuration.instantiate.ca_file
|
|
54
|
-
ca_file.
|
|
55
|
-
File.
|
|
148
|
+
expect(ca_file).to match(/api_braintreegateway_com\.ca\.crt$/)
|
|
149
|
+
expect(File.exist?(ca_file)).to eq(true)
|
|
56
150
|
end
|
|
57
151
|
|
|
58
152
|
it "production" do
|
|
59
153
|
Braintree::Configuration.environment = :production
|
|
60
154
|
ca_file = Braintree::Configuration.instantiate.ca_file
|
|
61
|
-
ca_file.
|
|
62
|
-
File.
|
|
155
|
+
expect(ca_file).to match(/api_braintreegateway_com\.ca\.crt$/)
|
|
156
|
+
expect(File.exist?(ca_file)).to eq(true)
|
|
63
157
|
end
|
|
64
158
|
end
|
|
65
159
|
|
|
66
160
|
describe "logger" do
|
|
67
161
|
it "defaults to logging to stdout with log_level info" do
|
|
68
162
|
config = Braintree::Configuration.new
|
|
69
|
-
config.logger.level.
|
|
163
|
+
expect(config.logger.level).to eq(Logger::INFO)
|
|
70
164
|
end
|
|
71
165
|
|
|
72
166
|
it "lazily initializes so that you can do Braintree::Configuration.logger.level = when configuring the client lib" do
|
|
73
167
|
config = Braintree::Configuration.new :logger => nil
|
|
74
|
-
config.logger.
|
|
168
|
+
expect(config.logger).not_to eq(nil)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it "can set logger on gateway instance" do
|
|
172
|
+
gateway = Braintree::Configuration.gateway
|
|
173
|
+
old_logger = Braintree::Configuration.logger
|
|
174
|
+
|
|
175
|
+
new_logger = Logger.new("/dev/null")
|
|
176
|
+
|
|
177
|
+
gateway.config.logger = new_logger
|
|
178
|
+
|
|
179
|
+
expect(gateway.config.logger).to eq(new_logger)
|
|
180
|
+
|
|
181
|
+
gateway.config.logger = old_logger
|
|
75
182
|
end
|
|
76
183
|
end
|
|
77
184
|
|
|
@@ -82,6 +189,44 @@ describe Braintree::Configuration do
|
|
|
82
189
|
Braintree::Configuration.environment
|
|
83
190
|
end.to raise_error(Braintree::ConfigurationError, "Braintree::Configuration.environment needs to be set")
|
|
84
191
|
end
|
|
192
|
+
|
|
193
|
+
it "raises an exception if it is an empty string" do
|
|
194
|
+
Braintree::Configuration.instance_variable_set(:@environment, "")
|
|
195
|
+
expect do
|
|
196
|
+
Braintree::Configuration.environment
|
|
197
|
+
end.to raise_error(Braintree::ConfigurationError, "Braintree::Configuration.environment needs to be set")
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
it "converts environment to symbol" do
|
|
201
|
+
config = Braintree::Configuration.new({
|
|
202
|
+
:environment => "sandbox"
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
expect(config.environment).to eq(:sandbox)
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
describe "self.gateway" do
|
|
210
|
+
it "sets its proxy config" do
|
|
211
|
+
Braintree::Configuration.proxy_address = "localhost"
|
|
212
|
+
Braintree::Configuration.proxy_port = 8080
|
|
213
|
+
Braintree::Configuration.proxy_user = "user"
|
|
214
|
+
Braintree::Configuration.proxy_pass = "test"
|
|
215
|
+
|
|
216
|
+
gateway = Braintree::Configuration.gateway
|
|
217
|
+
|
|
218
|
+
expect(gateway.config.proxy_address).to eq("localhost")
|
|
219
|
+
expect(gateway.config.proxy_port).to eq(8080)
|
|
220
|
+
expect(gateway.config.proxy_user).to eq("user")
|
|
221
|
+
expect(gateway.config.proxy_pass).to eq("test")
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
it "sets the ssl version" do
|
|
225
|
+
Braintree::Configuration.ssl_version = :TLSv1_2
|
|
226
|
+
gateway = Braintree::Configuration.gateway
|
|
227
|
+
|
|
228
|
+
expect(gateway.config.ssl_version).to eq(:TLSv1_2)
|
|
229
|
+
end
|
|
85
230
|
end
|
|
86
231
|
|
|
87
232
|
describe "self.environment=" do
|
|
@@ -90,6 +235,17 @@ describe Braintree::Configuration do
|
|
|
90
235
|
Braintree::Configuration.environment = :invalid_environment
|
|
91
236
|
end.to raise_error(ArgumentError, ":invalid_environment is not a valid environment")
|
|
92
237
|
end
|
|
238
|
+
|
|
239
|
+
it "allows the environment to be set with a string value" do
|
|
240
|
+
expect do
|
|
241
|
+
Braintree::Configuration.environment = "sandbox"
|
|
242
|
+
end.not_to raise_error
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
it "sets the environment as a symbol" do
|
|
246
|
+
Braintree::Configuration.environment = "sandbox"
|
|
247
|
+
expect(Braintree::Configuration.environment).to eq :sandbox
|
|
248
|
+
end
|
|
93
249
|
end
|
|
94
250
|
|
|
95
251
|
describe "self.logger" do
|
|
@@ -97,7 +253,7 @@ describe Braintree::Configuration do
|
|
|
97
253
|
begin
|
|
98
254
|
old_logger = Braintree::Configuration.logger
|
|
99
255
|
Braintree::Configuration.logger = nil
|
|
100
|
-
Braintree::Configuration.instantiate.logger.level.
|
|
256
|
+
expect(Braintree::Configuration.instantiate.logger.level).to eq(Logger::INFO)
|
|
101
257
|
ensure
|
|
102
258
|
Braintree::Configuration.logger = old_logger
|
|
103
259
|
end
|
|
@@ -105,7 +261,7 @@ describe Braintree::Configuration do
|
|
|
105
261
|
|
|
106
262
|
it "lazily initializes so that you can do Braintree::Configuration.logger.level = when configuring the client lib" do
|
|
107
263
|
Braintree::Configuration.logger = nil
|
|
108
|
-
Braintree::Configuration.logger.
|
|
264
|
+
expect(Braintree::Configuration.logger).not_to eq(nil)
|
|
109
265
|
end
|
|
110
266
|
end
|
|
111
267
|
|
|
@@ -116,6 +272,13 @@ describe Braintree::Configuration do
|
|
|
116
272
|
Braintree::Configuration.merchant_id
|
|
117
273
|
end.to raise_error(Braintree::ConfigurationError, "Braintree::Configuration.merchant_id needs to be set")
|
|
118
274
|
end
|
|
275
|
+
|
|
276
|
+
it "raises an exception if it is an empty string" do
|
|
277
|
+
Braintree::Configuration.instance_variable_set(:@merchant_id, "")
|
|
278
|
+
expect do
|
|
279
|
+
Braintree::Configuration.merchant_id
|
|
280
|
+
end.to raise_error(Braintree::ConfigurationError, "Braintree::Configuration.merchant_id needs to be set")
|
|
281
|
+
end
|
|
119
282
|
end
|
|
120
283
|
|
|
121
284
|
describe "self.public_key" do
|
|
@@ -125,6 +288,13 @@ describe Braintree::Configuration do
|
|
|
125
288
|
Braintree::Configuration.public_key
|
|
126
289
|
end.to raise_error(Braintree::ConfigurationError, "Braintree::Configuration.public_key needs to be set")
|
|
127
290
|
end
|
|
291
|
+
|
|
292
|
+
it "raises an exception if it is an empty string" do
|
|
293
|
+
Braintree::Configuration.instance_variable_set(:@public_key, "")
|
|
294
|
+
expect do
|
|
295
|
+
Braintree::Configuration.public_key
|
|
296
|
+
end.to raise_error(Braintree::ConfigurationError, "Braintree::Configuration.public_key needs to be set")
|
|
297
|
+
end
|
|
128
298
|
end
|
|
129
299
|
|
|
130
300
|
describe "self.private_key" do
|
|
@@ -134,30 +304,37 @@ describe Braintree::Configuration do
|
|
|
134
304
|
Braintree::Configuration.private_key
|
|
135
305
|
end.to raise_error(Braintree::ConfigurationError, "Braintree::Configuration.private_key needs to be set")
|
|
136
306
|
end
|
|
307
|
+
|
|
308
|
+
it "raises an exception if it is an empty string" do
|
|
309
|
+
Braintree::Configuration.instance_variable_set(:@private_key, "")
|
|
310
|
+
expect do
|
|
311
|
+
Braintree::Configuration.private_key
|
|
312
|
+
end.to raise_error(Braintree::ConfigurationError, "Braintree::Configuration.private_key needs to be set")
|
|
313
|
+
end
|
|
137
314
|
end
|
|
138
315
|
|
|
139
316
|
describe "self.port" do
|
|
140
317
|
it "is 443 for production" do
|
|
141
318
|
Braintree::Configuration.environment = :production
|
|
142
|
-
Braintree::Configuration.instantiate.port.
|
|
319
|
+
expect(Braintree::Configuration.instantiate.port).to eq(443)
|
|
143
320
|
end
|
|
144
321
|
|
|
145
322
|
it "is 443 for sandbox" do
|
|
146
323
|
Braintree::Configuration.environment = :sandbox
|
|
147
|
-
Braintree::Configuration.instantiate.port.
|
|
324
|
+
expect(Braintree::Configuration.instantiate.port).to eq(443)
|
|
148
325
|
end
|
|
149
326
|
|
|
150
327
|
it "is 3000 or GATEWAY_PORT environment variable for development" do
|
|
151
328
|
Braintree::Configuration.environment = :development
|
|
152
|
-
old_gateway_port = ENV[
|
|
329
|
+
old_gateway_port = ENV["GATEWAY_PORT"]
|
|
153
330
|
begin
|
|
154
|
-
ENV[
|
|
155
|
-
Braintree::Configuration.instantiate.port.
|
|
331
|
+
ENV["GATEWAY_PORT"] = nil
|
|
332
|
+
expect(Braintree::Configuration.instantiate.port).to eq(3000)
|
|
156
333
|
|
|
157
|
-
ENV[
|
|
158
|
-
Braintree::Configuration.instantiate.port.
|
|
334
|
+
ENV["GATEWAY_PORT"] = "1234"
|
|
335
|
+
expect(Braintree::Configuration.instantiate.port).to eq("1234")
|
|
159
336
|
ensure
|
|
160
|
-
ENV[
|
|
337
|
+
ENV["GATEWAY_PORT"] = old_gateway_port
|
|
161
338
|
end
|
|
162
339
|
end
|
|
163
340
|
end
|
|
@@ -165,52 +342,109 @@ describe Braintree::Configuration do
|
|
|
165
342
|
describe "self.protocol" do
|
|
166
343
|
it "is http for development" do
|
|
167
344
|
Braintree::Configuration.environment = :development
|
|
168
|
-
Braintree::Configuration.instantiate.protocol.
|
|
345
|
+
expect(Braintree::Configuration.instantiate.protocol).to eq("http")
|
|
169
346
|
end
|
|
170
347
|
|
|
171
348
|
it "is https for production" do
|
|
172
349
|
Braintree::Configuration.environment = :production
|
|
173
|
-
Braintree::Configuration.instantiate.protocol.
|
|
350
|
+
expect(Braintree::Configuration.instantiate.protocol).to eq("https")
|
|
174
351
|
end
|
|
175
352
|
|
|
176
353
|
it "is https for sandbox" do
|
|
177
354
|
Braintree::Configuration.environment = :sandbox
|
|
178
|
-
Braintree::Configuration.instantiate.protocol.
|
|
355
|
+
expect(Braintree::Configuration.instantiate.protocol).to eq("https")
|
|
179
356
|
end
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
describe "graphql_server" do
|
|
360
|
+
it "is localhost or GRAPHQL_HOST environment variable for development" do
|
|
361
|
+
Braintree::Configuration.environment = :development
|
|
362
|
+
old_gateway_url = ENV["GRAPHQL_HOST"]
|
|
363
|
+
begin
|
|
364
|
+
ENV["GRAPHQL_HOST"] = nil
|
|
365
|
+
expect(Braintree::Configuration.instantiate.graphql_server).to eq("graphql.bt.local")
|
|
180
366
|
|
|
367
|
+
ENV["GRAPHQL_HOST"] = "gateway"
|
|
368
|
+
expect(Braintree::Configuration.instantiate.graphql_server).to eq("gateway")
|
|
369
|
+
ensure
|
|
370
|
+
ENV["GRAPHQL_HOST"] = old_gateway_url
|
|
371
|
+
end
|
|
372
|
+
end
|
|
181
373
|
end
|
|
182
374
|
|
|
183
|
-
describe "
|
|
184
|
-
it "is localhost for development" do
|
|
375
|
+
describe "server" do
|
|
376
|
+
it "is localhost or GATEWAY_HOST environment variable for development" do
|
|
185
377
|
Braintree::Configuration.environment = :development
|
|
186
|
-
|
|
378
|
+
old_gateway_url = ENV["GATEWAY_HOST"]
|
|
379
|
+
begin
|
|
380
|
+
ENV["GATEWAY_HOST"] = nil
|
|
381
|
+
expect(Braintree::Configuration.instantiate.server).to eq("localhost")
|
|
382
|
+
|
|
383
|
+
ENV["GATEWAY_HOST"] = "gateway"
|
|
384
|
+
expect(Braintree::Configuration.instantiate.server).to eq("gateway")
|
|
385
|
+
ensure
|
|
386
|
+
ENV["GATEWAY_HOST"] = old_gateway_url
|
|
387
|
+
end
|
|
187
388
|
end
|
|
188
389
|
|
|
189
|
-
it "is
|
|
390
|
+
it "is api.braintreegateway.com for production" do
|
|
190
391
|
Braintree::Configuration.environment = :production
|
|
191
|
-
Braintree::Configuration.instantiate.server.
|
|
392
|
+
expect(Braintree::Configuration.instantiate.server).to eq("api.braintreegateway.com")
|
|
192
393
|
end
|
|
193
394
|
|
|
194
|
-
it "is sandbox.braintreegateway.com for sandbox" do
|
|
395
|
+
it "is api.sandbox.braintreegateway.com for sandbox" do
|
|
195
396
|
Braintree::Configuration.environment = :sandbox
|
|
196
|
-
Braintree::Configuration.instantiate.server.
|
|
397
|
+
expect(Braintree::Configuration.instantiate.server).to eq("api.sandbox.braintreegateway.com")
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
it "is qa.braintreegateway.com for qa" do
|
|
401
|
+
Braintree::Configuration.environment = :qa
|
|
402
|
+
expect(Braintree::Configuration.instantiate.server).to eq("gateway.qa2.braintreepayments.com")
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
it "can by changed by configuring the production endpoint" do
|
|
406
|
+
Braintree::Configuration.environment = :production
|
|
407
|
+
Braintree::Configuration.endpoint = "custom-endpoint"
|
|
408
|
+
expect(Braintree::Configuration.instantiate.server).to eq("custom-endpoint.braintreegateway.com")
|
|
409
|
+
end
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
describe "auth_url" do
|
|
413
|
+
it "is http://auth.venmo.dev for development" do
|
|
414
|
+
Braintree::Configuration.environment = :development
|
|
415
|
+
expect(Braintree::Configuration.instantiate.auth_url).to eq("http://auth.venmo.dev:9292")
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
it "is https://auth.venmo.com for production" do
|
|
419
|
+
Braintree::Configuration.environment = :production
|
|
420
|
+
expect(Braintree::Configuration.instantiate.auth_url).to eq("https://auth.venmo.com")
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
it "is https://auth.sandbox.venmo.com for sandbox" do
|
|
424
|
+
Braintree::Configuration.environment = :sandbox
|
|
425
|
+
expect(Braintree::Configuration.instantiate.auth_url).to eq("https://auth.venmo.sandbox.braintreegateway.com")
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
it "is https://auth.qa.venmo.com for qa" do
|
|
429
|
+
Braintree::Configuration.environment = :qa
|
|
430
|
+
expect(Braintree::Configuration.instantiate.auth_url).to eq("https://auth.venmo.qa2.braintreegateway.com")
|
|
197
431
|
end
|
|
198
432
|
end
|
|
199
433
|
|
|
200
434
|
describe "ssl?" do
|
|
201
435
|
it "returns false for development" do
|
|
202
436
|
Braintree::Configuration.environment = :development
|
|
203
|
-
Braintree::Configuration.instantiate.ssl
|
|
437
|
+
expect(Braintree::Configuration.instantiate.ssl?).to eq(false)
|
|
204
438
|
end
|
|
205
439
|
|
|
206
440
|
it "returns true for production" do
|
|
207
441
|
Braintree::Configuration.environment = :production
|
|
208
|
-
Braintree::Configuration.instantiate.ssl
|
|
442
|
+
expect(Braintree::Configuration.instantiate.ssl?).to eq(true)
|
|
209
443
|
end
|
|
210
444
|
|
|
211
445
|
it "returns true for sandbox" do
|
|
212
446
|
Braintree::Configuration.environment = :sandbox
|
|
213
|
-
Braintree::Configuration.instantiate.ssl
|
|
447
|
+
expect(Braintree::Configuration.instantiate.ssl?).to eq(true)
|
|
214
448
|
end
|
|
215
449
|
end
|
|
216
450
|
|
|
@@ -221,12 +455,28 @@ describe Braintree::Configuration do
|
|
|
221
455
|
|
|
222
456
|
it "appends the default user_agent with the given value" do
|
|
223
457
|
Braintree::Configuration.custom_user_agent = "ActiveMerchant 1.2.3"
|
|
224
|
-
Braintree::Configuration.instantiate.user_agent.
|
|
458
|
+
expect(Braintree::Configuration.instantiate.user_agent).to eq("Braintree Ruby Gem #{Braintree::Version::String} (ActiveMerchant 1.2.3)")
|
|
225
459
|
end
|
|
226
460
|
|
|
227
461
|
it "does not append anything if there is no custom_user_agent" do
|
|
228
462
|
Braintree::Configuration.custom_user_agent = nil
|
|
229
|
-
Braintree::Configuration.instantiate.user_agent.
|
|
463
|
+
expect(Braintree::Configuration.instantiate.user_agent).to eq("Braintree Ruby Gem #{Braintree::Version::String}")
|
|
464
|
+
end
|
|
465
|
+
end
|
|
466
|
+
|
|
467
|
+
describe "inspect" do
|
|
468
|
+
it "masks the private_key" do
|
|
469
|
+
config = Braintree::Configuration.new(:private_key => "secret_key")
|
|
470
|
+
expect(config.inspect).to include('@private_key="[FILTERED]"')
|
|
471
|
+
expect(config.inspect).not_to include("secret_key")
|
|
472
|
+
end
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
describe "signature_service" do
|
|
476
|
+
it "has a signature service initialized with the private key" do
|
|
477
|
+
config = Braintree::Configuration.new(:private_key => "secret_key")
|
|
478
|
+
|
|
479
|
+
expect(config.signature_service.key).to eq("secret_key")
|
|
230
480
|
end
|
|
231
481
|
end
|
|
232
482
|
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::CredentialsParser do
|
|
4
|
+
describe "parse_client_credentials" do
|
|
5
|
+
it "parses client credentials" do
|
|
6
|
+
parser = Braintree::CredentialsParser.new
|
|
7
|
+
parser.parse_client_credentials("client_id$development$integration_client_id", "client_secret$development$integration_client_secret")
|
|
8
|
+
|
|
9
|
+
expect(parser.client_id).to eq("client_id$development$integration_client_id")
|
|
10
|
+
expect(parser.client_secret).to eq("client_secret$development$integration_client_secret")
|
|
11
|
+
expect(parser.environment).to eq(:development)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "raises error on inconsistent environment" do
|
|
15
|
+
parser = Braintree::CredentialsParser.new
|
|
16
|
+
|
|
17
|
+
expect do
|
|
18
|
+
parser.parse_client_credentials("client_id$development$integration_client_id", "client_secret$qa$integration_client_secret")
|
|
19
|
+
end.to raise_error(Braintree::ConfigurationError, /Mismatched credential environments/)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "raises error on nil client_id" do
|
|
23
|
+
parser = Braintree::CredentialsParser.new
|
|
24
|
+
|
|
25
|
+
expect do
|
|
26
|
+
parser.parse_client_credentials(nil, "client_secret$development$integration_client_secret")
|
|
27
|
+
end.to raise_error(Braintree::ConfigurationError, /Missing client_id/)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "raises error on missing client_secret" do
|
|
31
|
+
parser = Braintree::CredentialsParser.new
|
|
32
|
+
|
|
33
|
+
expect do
|
|
34
|
+
parser.parse_client_credentials("client_id$development$integration_client_id", nil)
|
|
35
|
+
end.to raise_error(Braintree::ConfigurationError, /Missing client_secret/)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "raises error on invalid client_id" do
|
|
39
|
+
parser = Braintree::CredentialsParser.new
|
|
40
|
+
|
|
41
|
+
expect do
|
|
42
|
+
parser.parse_client_credentials("client_secret$development$integration_client_secret", "client_secret$development$integration_client_secret")
|
|
43
|
+
end.to raise_error(Braintree::ConfigurationError, /is not a client_id/)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "raises error on invalid client_secret" do
|
|
47
|
+
parser = Braintree::CredentialsParser.new
|
|
48
|
+
|
|
49
|
+
expect do
|
|
50
|
+
parser.parse_client_credentials("client_id$development$integration_client_id", "client_id$development$integration_client_id")
|
|
51
|
+
end.to raise_error(Braintree::ConfigurationError, /is not a client_secret/)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe "parse_access_token" do
|
|
56
|
+
it "parses access token" do
|
|
57
|
+
parser = Braintree::CredentialsParser.new
|
|
58
|
+
parser.parse_access_token("access_token$development$integration_merchant_id$fb27c79dd")
|
|
59
|
+
|
|
60
|
+
expect(parser.merchant_id).to eq("integration_merchant_id")
|
|
61
|
+
expect(parser.access_token).to eq("access_token$development$integration_merchant_id$fb27c79dd")
|
|
62
|
+
expect(parser.environment).to eq(:development)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "raises error on nil access_token" do
|
|
66
|
+
parser = Braintree::CredentialsParser.new
|
|
67
|
+
|
|
68
|
+
expect do
|
|
69
|
+
parser.parse_access_token(nil)
|
|
70
|
+
end.to raise_error(Braintree::ConfigurationError, /Missing access_token/)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "raises error on invalid access_token" do
|
|
74
|
+
parser = Braintree::CredentialsParser.new
|
|
75
|
+
|
|
76
|
+
expect do
|
|
77
|
+
parser.parse_access_token("client_id$development$integration_client_id")
|
|
78
|
+
end.to raise_error(Braintree::ConfigurationError, /is not a valid access_token/)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|