mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 01:57:45 +08:00 
			
		
		
		
	ci(runner): refactor newman command to address commands directly (#1499)
Co-authored-by: Likhin Bopanna <likhin.bopanna@juspay.in> Co-authored-by: Sanchith Hegde <sanchith.hegde@juspay.in>
This commit is contained in:
		
							
								
								
									
										22
									
								
								.github/workflows/postman-collection-runner.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										22
									
								
								.github/workflows/postman-collection-runner.yml
									
									
									
									
										vendored
									
									
								
							| @ -18,8 +18,17 @@ jobs: | |||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         connector: |         connector: | ||||||
|           - adyen |           - aci | ||||||
|  |           # - authorizedotnet | ||||||
|  |           - bluesnap | ||||||
|  |           # - braintree | ||||||
|  |           - checkout | ||||||
|  |           # - iatapay | ||||||
|  |           # - multisafepay | ||||||
|  |           - nmi | ||||||
|           - stripe |           - stripe | ||||||
|  |           # - trustpay | ||||||
|  |           - worldline | ||||||
|  |  | ||||||
|     steps: |     steps: | ||||||
|       - name: Checkout repository |       - name: Checkout repository | ||||||
| @ -39,12 +48,13 @@ jobs: | |||||||
|         env: |         env: | ||||||
|           ADMIN_API_KEY: ${{ secrets.INTEG_ADMIN_API_KEY }} |           ADMIN_API_KEY: ${{ secrets.INTEG_ADMIN_API_KEY }} | ||||||
|           BASE_URL: ${{ secrets.INTEG_BASE_URL }} |           BASE_URL: ${{ secrets.INTEG_BASE_URL }} | ||||||
|           MERCHANT_ID: ${{ secrets.STRIPE_GATEWAY_MERCHANT_ID }} |  | ||||||
|           CONNECTOR_CONFIG_PATH: ${{ env.CONNECTOR_CONFIG_PATH }} |           CONNECTOR_CONFIG_PATH: ${{ env.CONNECTOR_CONFIG_PATH }} | ||||||
|  |  | ||||||
|           # Stripe specific env variables, will be replaced by connector_auth.toml |  | ||||||
|           GATEWAY_MERCHANT_ID: ${{ secrets.STRIPE_GATEWAY_MERCHANT_ID }} |           GATEWAY_MERCHANT_ID: ${{ secrets.STRIPE_GATEWAY_MERCHANT_ID }} | ||||||
|           GPAY_CERTIFICATE: ${{ secrets.STRIPE_GPAY_CERTIFICATE }} |           GPAY_CERTIFICATE: ${{ secrets.STRIPE_GPAY_CERTIFICATE }} | ||||||
|           GPAY_CERTIFICATE_KEYS: ${{ secrets.STRIPE_GPAY_CERTIFICATE_KEYS }} |           GPAY_CERTIFICATE_KEYS: ${{ secrets.STRIPE_GPAY_CERTIFICATE_KEYS }} | ||||||
|         shell: bash |         uses: nick-fields/retry@v2 | ||||||
|         run: ./scripts/postman_test_automation.sh ${{ matrix.connector }} |         with: | ||||||
|  |           timeout_minutes: 6 | ||||||
|  |           max_attempts: 3 | ||||||
|  |           retry_on: error | ||||||
|  |           command: ./scripts/postman_test_automation.sh ${{ matrix.connector }} | ||||||
|  | |||||||
							
								
								
									
										12463
									
								
								postman/aci.postman_collection.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12463
									
								
								postman/aci.postman_collection.json
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										5979
									
								
								postman/bluesnap.postman_collection.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5979
									
								
								postman/bluesnap.postman_collection.json
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										6558
									
								
								postman/checkout.postman_collection.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6558
									
								
								postman/checkout.postman_collection.json
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										5880
									
								
								postman/nmi.postman_collection.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5880
									
								
								postman/nmi.postman_collection.json
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -1,12 +1,9 @@ | |||||||
| { | { | ||||||
| 	"info": { | 	"info": { | ||||||
| 		"_postman_id": "faf79340-e864-41f2-afe8-c87d2b593060", | 		"_postman_id": "789922f3-108b-4c10-82c7-f03dd6c60059", | ||||||
| 		"name": "Stripe collection", | 		"name": "Stripe collection", | ||||||
| 		"description": "## Get started\n\nJuspay Router provides a collection of APIs that enable you to process and manage payments. Our APIs accept and return JSON in the HTTP body, and return standard HTTP response codes.  \nYou can consume the APIs directly using your favorite HTTP/REST library.  \nWe have a testing environment referred to \"sandbox\", which you can setup to test API calls without affecting production data.\n\n### Base URLs\n\nUse the following base URLs when making requests to the APIs:\n\n| Environment | Base URL |\n| --- | --- |\n| Sandbox | [https://sandbox.hyperswitch.io](https://sandbox.hyperswitch.io) |\n| Production | [https://router.juspay.io](https://router.juspay.io) |\n\n# Authentication\n\nWhen you sign up for an account, you are given a secret key (also referred as api-key). You may authenticate all API requests with Juspay server by providing the appropriate key in the request Authorization header.  \nNever share your secret api keys. Keep them guarded and secure.\n\nContact Support:  \nName: Juspay Support  \nEmail: [support@juspay.in](mailto:support@juspay.in)", | 		"description": "## Get started\n\nJuspay Router provides a collection of APIs that enable you to process and manage payments. Our APIs accept and return JSON in the HTTP body, and return standard HTTP response codes.  \nYou can consume the APIs directly using your favorite HTTP/REST library.  \nWe have a testing environment referred to \"sandbox\", which you can setup to test API calls without affecting production data.\n\n### Base URLs\n\nUse the following base URLs when making requests to the APIs:\n\n| Environment | Base URL |\n| --- | --- |\n| Sandbox | [https://sandbox.hyperswitch.io](https://sandbox.hyperswitch.io) |\n| Production | [https://router.juspay.io](https://router.juspay.io) |\n\n# Authentication\n\nWhen you sign up for an account, you are given a secret key (also referred as api-key). You may authenticate all API requests with Juspay server by providing the appropriate key in the request Authorization header.  \nNever share your secret api keys. Keep them guarded and secure.\n\nContact Support:  \nName: Juspay Support  \nEmail: [support@juspay.in](mailto:support@juspay.in)", | ||||||
| 		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", | 		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"}, | ||||||
| 		"_exporter_id": "25176183", |  | ||||||
| 		"_collection_link": "https://hyperswitch.postman.co/workspace/My-Workspace~d96cf932-bfd8-42e0-8a66-0ecd4c038223/collection/25176183-faf79340-e864-41f2-afe8-c87d2b593060?action=share&creator=25176183&source=collection_link" |  | ||||||
| 	}, |  | ||||||
| 	"item": [ | 	"item": [ | ||||||
| 		{ | 		{ | ||||||
| 			"name": "Health check", | 			"name": "Health check", | ||||||
| @ -2494,7 +2491,7 @@ | |||||||
| 						], | 						], | ||||||
| 						"body": { | 						"body": { | ||||||
| 							"mode": "raw", | 							"mode": "raw", | ||||||
| 							"raw": "{\n  \"amount\": 20000,\n  \"currency\": \"SGD\",\n  \"confirm\" :false,\n  \"capture_method\": \"automatic\",\n  \"capture_on\": \"2022-09-10T10:11:12Z\",\n  \"amount_to_capture\": 6540,\n  \"email\": \"joseph@example.com\",\n  \"name\": \"joseph Doe\",\n  \"phone\": \"8888888888\",\n  \"phone_country_code\": \"+65\",\n  \"description\": \"Its my first payment request\",\n  \"authentication_type\": \"no_three_ds\",\n  \"payment_method\": \"card\",\n  \"return_url\": \"https://google.com\",\n  \"payment_method_data\": {\n    \"card\": {\n      \"card_number\": \"4242424242424242\",\n      \"card_exp_month\": \"10\",\n      \"card_exp_year\": \"25\",\n      \"card_holder_name\": \"joseph Doe\",\n      \"card_cvc\": \"123\"\n    }\n  },\n   \"billing\": {\n        \"address\": {\n            \"line1\": \"1467\",\n            \"line2\": \"Harrison Street\",\n            \"line3\": \"Harrison Street\",\n            \"city\": \"San Fransico\",\n            \"state\": \"California\",\n            \"zip\": \"94122\",\n            \"country\": \"US\"\n        }\n    },\n    \"shipping\": {\n        \"address\": {\n            \"line1\": \"1467\",\n            \"line2\": \"Harrison Street\",\n            \"line3\": \"Harrison Street\",\n            \"city\": \"San Fransico\",\n            \"state\": \"California\",\n            \"zip\": \"94122\",\n            \"country\": \"US\"\n        }\n    },\n  \"statement_descriptor_name\": \"joseph\",\n  \"statement_descriptor_suffix\": \"JS\",\n  \"metadata\": {\n    \"udf1\": \"value1\",\n    \"new_customer\": \"true\",\n    \"login_date\": \"2019-09-10T10:11:12Z\"\n  }\n}", | 							"raw": "{\n  \"amount\": 20000,\n  \"currency\": \"SGD\",\n  \"confirm\" :false,\n  \"capture_method\": \"manual\",\n  \"capture_on\": \"2022-09-10T10:11:12Z\",\n  \"amount_to_capture\": 6540,\n  \"email\": \"joseph@example.com\",\n  \"name\": \"joseph Doe\",\n  \"phone\": \"8888888888\",\n  \"phone_country_code\": \"+65\",\n  \"description\": \"Its my first payment request\",\n  \"authentication_type\": \"no_three_ds\",\n  \"payment_method\": \"card\",\n  \"return_url\": \"https://google.com\",\n  \"payment_method_data\": {\n    \"card\": {\n      \"card_number\": \"4242424242424242\",\n      \"card_exp_month\": \"10\",\n      \"card_exp_year\": \"25\",\n      \"card_holder_name\": \"joseph Doe\",\n      \"card_cvc\": \"123\"\n    }\n  },\n   \"billing\": {\n        \"address\": {\n            \"line1\": \"1467\",\n            \"line2\": \"Harrison Street\",\n            \"line3\": \"Harrison Street\",\n            \"city\": \"San Fransico\",\n            \"state\": \"California\",\n            \"zip\": \"94122\",\n            \"country\": \"US\"\n        }\n    },\n    \"shipping\": {\n        \"address\": {\n            \"line1\": \"1467\",\n            \"line2\": \"Harrison Street\",\n            \"line3\": \"Harrison Street\",\n            \"city\": \"San Fransico\",\n            \"state\": \"California\",\n            \"zip\": \"94122\",\n            \"country\": \"US\"\n        }\n    },\n  \"statement_descriptor_name\": \"joseph\",\n  \"statement_descriptor_suffix\": \"JS\",\n  \"metadata\": {\n    \"udf1\": \"value1\",\n    \"new_customer\": \"true\",\n    \"login_date\": \"2019-09-10T10:11:12Z\"\n  }\n}", | ||||||
| 							"options": { | 							"options": { | ||||||
| 								"raw": { | 								"raw": { | ||||||
| 									"language": "json" | 									"language": "json" | ||||||
| @ -11479,8 +11476,8 @@ | |||||||
| 													"", | 													"", | ||||||
| 													"// Response body should have value \"connector error\" for \"error type\"", | 													"// Response body should have value \"connector error\" for \"error type\"", | ||||||
| 													"if (jsonData?.error?.type) {", | 													"if (jsonData?.error?.type) {", | ||||||
| 													"pm.test(\"[POST]::/payments - Content check if value for 'error.type' matches 'connector'\", function() {", | 													"pm.test(\"[POST]::/payments - Content check if value for 'error.type' matches 'invalid_request'\", function() {", | ||||||
| 													"  pm.expect(jsonData.error.type).to.eql(\"connector\");", | 													"  pm.expect(jsonData.error.type).to.eql(\"invalid_request\");", | ||||||
| 													"})};" | 													"})};" | ||||||
| 												], | 												], | ||||||
| 												"type": "text/javascript" | 												"type": "text/javascript" | ||||||
| @ -11579,8 +11576,14 @@ | |||||||
| 													"", | 													"", | ||||||
| 													"// Response body should have value \"connector error\" for \"error type\"", | 													"// Response body should have value \"connector error\" for \"error type\"", | ||||||
| 													"if (jsonData?.error?.type) {", | 													"if (jsonData?.error?.type) {", | ||||||
| 													"pm.test(\"[POST]::/payments - Content check if value for 'error.type' matches 'connector'\", function() {", | 													"pm.test(\"[POST]::/payments - Content check if value for 'error.type' matches 'invalid_request'\", function() {", | ||||||
| 													"  pm.expect(jsonData.error.type).to.eql(\"connector\");", | 													"  pm.expect(jsonData.error.type).to.eql(\"invalid_request\");", | ||||||
|  | 													"})};", | ||||||
|  | 													"", | ||||||
|  | 													"// Response body should have value \"connector error\" for \"error message\"", | ||||||
|  | 													"if (jsonData?.error?.message) {", | ||||||
|  | 													"pm.test(\"[POST]::/payments - Content check if value for 'error.message' matches 'invalid_expiry_year: Your card's expiration year is invalid.'\", function() {", | ||||||
|  | 													"  pm.expect(jsonData.error.message).to.eql(\"Invalid Expiry Year\");", | ||||||
| 													"})};" | 													"})};" | ||||||
| 												], | 												], | ||||||
| 												"type": "text/javascript" | 												"type": "text/javascript" | ||||||
|  | |||||||
							
								
								
									
										4114
									
								
								postman/worldline.postman_collection.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4114
									
								
								postman/worldline.postman_collection.json
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -19,16 +19,23 @@ get_api_keys() { | |||||||
|     # [<connector_name>] |     # [<connector_name>] | ||||||
|     # api_key = "HeadKey of <connector_name>" |     # api_key = "HeadKey of <connector_name>" | ||||||
|  |  | ||||||
|     API_KEY=$(echo "${result}" | awk -F ' = ' '$1 == "api_key" { print $2 }') |     # Keys are set as variables since some API Keys for connectors such as ACI | ||||||
|     KEY1=$(echo "${result}" | awk -F ' = ' '$1 == "key1" { print $2 }') |     # are Base64 encoded and require "Bearer" to be prefixed such as "Bearer Skst45645gey5r#&$==". | ||||||
|     API_SECRET=$(echo "${result}" | awk -F ' = ' '$1 == "api_secret" { print $2 }') |     # This effectively stops the shell from interpreting the value of the variable as a command. | ||||||
|  |     API_KEY=$(echo "${result}" | awk -F ' = ' '$1 == "api_key" { gsub(/"/, "", $2); print $2 }') | ||||||
|  |     KEY1=$(echo "${result}" | awk -F ' = ' '$1 == "key1" { gsub(/"/, "", $2); print $2 }') | ||||||
|  |     KEY2=$(echo "${result}" | awk -F ' = ' '$1 == "key2" { gsub(/"/, "", $2); print $2 }') | ||||||
|  |     API_SECRET=$(echo "${result}" | awk -F ' = ' '$1 == "api_secret" { gsub(/"/, "", $2); print $2 }') | ||||||
|      |      | ||||||
|  |     # Determine the type of key | ||||||
|     if [[ -n "${API_KEY}" && -z "${KEY1}" && -z "${API_SECRET}" ]]; then |     if [[ -n "${API_KEY}" && -z "${KEY1}" && -z "${API_SECRET}" ]]; then | ||||||
|         KEY_TYPE="HeaderKey" |         KEY_TYPE="HeaderKey" | ||||||
|     elif [[ -n "${API_KEY}" && -n "{$KEY1}" && -z "${API_SECRET}" ]]; then |     elif [[ -n "${API_KEY}" && -n "${KEY1}" && -z "${API_SECRET}" ]]; then | ||||||
|         KEY_TYPE="BodyKey" |         KEY_TYPE="BodyKey" | ||||||
|     elif [[ -n "${API_KEY}" && -n "${KEY1}" && -n "${API_SECRET}" ]]; then |     elif [[ -n "${API_KEY}" && -n "${KEY1}" && -n "${API_SECRET}" ]]; then | ||||||
|         KEY_TYPE="SignatureKey" |         KEY_TYPE="SignatureKey" | ||||||
|  |     elif [[ -n "${API_KEY}" && -n "${KEY1}" && -n "${KEY2}" && -n "${API_SECRET}" ]]; then | ||||||
|  |         KEY_TYPE="MultiAuthKey" | ||||||
|     else |     else | ||||||
|         KEY_TYPE="Invalid" |         KEY_TYPE="Invalid" | ||||||
|     fi |     fi | ||||||
| @ -38,50 +45,22 @@ get_api_keys() { | |||||||
| CONNECTOR_NAME="${1}" | CONNECTOR_NAME="${1}" | ||||||
| KEY_TYPE="" | KEY_TYPE="" | ||||||
|  |  | ||||||
| API_KEY="" |  | ||||||
| API_SECRET="" |  | ||||||
| KEY1="" |  | ||||||
|  |  | ||||||
| # Function call | # Function call | ||||||
| get_api_keys "${CONNECTOR_NAME}" |  | ||||||
| COLLECTION_PATH=$(path_generation "${CONNECTOR_NAME}") | COLLECTION_PATH=$(path_generation "${CONNECTOR_NAME}") | ||||||
|  | get_api_keys "${CONNECTOR_NAME}" | ||||||
|  |  | ||||||
| # Run Newman collection | # Newman runner | ||||||
| case "$KEY_TYPE" in | # Depending on the conditions satisfied, variables are added. Since certificates of stripe have already | ||||||
|     "HeaderKey" ) | # been added to the postman collection, those conditions are set to true and collections that have | ||||||
|         args=( | # variables set up for certificate, will consider those variables and will fail. | ||||||
|             --env-var "admin_api_key=${ADMIN_API_KEY}" | newman run "${COLLECTION_PATH}" \ | ||||||
|             --env-var "baseUrl=${BASE_URL}" |     --env-var "admin_api_key=${ADMIN_API_KEY}" \ | ||||||
|             --env-var "connector_api_key=${API_KEY}" |     --env-var "baseUrl=${BASE_URL}" \ | ||||||
|         ) |     --env-var "connector_api_key=${API_KEY}" \ | ||||||
|         [[ -n "$GATEWAY_MERCHANT_ID" ]] && args+=("--env-var" "gateway_merchant_id=${GATEWAY_MERCHANT_ID}") |     $(if [[ "${KEY_TYPE}" == BodyKey ]]; then echo --env-var "connector_key1=${KEY1}"; fi) \ | ||||||
|         [[ -n "$GPAY_CERTIFICATE" ]] && args+=("--env-var" "certificate=${GPAY_CERTIFICATE}") |     $(if [[ "${KEY_TYPE}" == SignatureKey ]]; then echo --env-var "connector_key1=${KEY1}" --env-var "connector_api_secret=${API_SECRET}"; fi) \ | ||||||
|         [[ -n "$GPAY_CERTIFICATE_KEYS" ]] && args+=("--env-var" "certificate_keys=${GPAY_CERTIFICATE_KEYS}") |     $(if [[ "${KEY_TYPE}" == MultiAuthKey ]]; then echo --env-var "connector_key1=${KEY1}" --env-var "connector_key2=${KEY2}" --env-var "connector_api_secret=${API_SECRET}"; fi) \ | ||||||
|         newman run "${COLLECTION_PATH}" "${args[@]}" |     $(if [[ -n "${GATEWAY_MERCHANT_ID}" ]]; then echo --env-var "gateway_merchant_id=${GATEWAY_MERCHANT_ID}"; fi) \ | ||||||
|         ;; |     $(if [[ -n "${GPAY_CERTIFICATE}" ]]; then echo --env-var "certificate=${GPAY_CERTIFICATE}"; fi) \ | ||||||
|     "BodyKey" ) |     $(if [[ -n "${GPAY_CERTIFICATE_KEYS}" ]]; then echo --env-var "certificate_keys=${GPAY_CERTIFICATE_KEYS}"; fi) \ | ||||||
|         args=( |     --delay-request 5 | ||||||
|             --env-var "admin_api_key=${ADMIN_API_KEY}" |  | ||||||
|             --env-var "baseUrl=${BASE_URL}" |  | ||||||
|             --env-var "connector_api_key=${API_KEY}" |  | ||||||
|             --env-var "connector_key1=${KEY1}" |  | ||||||
|         ) |  | ||||||
|         [[ -n "$GATEWAY_MERCHANT_ID" ]] && args+=("--env-var" "gateway_merchant_id=${GATEWAY_MERCHANT_ID}") |  | ||||||
|         [[ -n "$GPAY_CERTIFICATE" ]] && args+=("--env-var" "certificate=${GPAY_CERTIFICATE}") |  | ||||||
|         [[ -n "$GPAY_CERTIFICATE_KEYS" ]] && args+=("--env-var" "certificate_keys=${GPAY_CERTIFICATE_KEYS}") |  | ||||||
|         newman run "${COLLECTION_PATH}" "${args[@]}" |  | ||||||
|         ;; |  | ||||||
|     "SignatureKey" ) |  | ||||||
|         args=( |  | ||||||
|             --env-var "admin_api_key=${ADMIN_API_KEY}" |  | ||||||
|             --env-var "baseUrl=${BASE_URL}" |  | ||||||
|             --env-var "connector_api_key=${API_KEY}" |  | ||||||
|             --env-var "connector_api_secret=${API_SECRET}" |  | ||||||
|             --env-var "connector_key1=${KEY1}" |  | ||||||
|         ) |  | ||||||
|         [[ -n "$GATEWAY_MERCHANT_ID" ]] && args+=("--env-var" "gateway_merchant_id=${GATEWAY_MERCHANT_ID}") |  | ||||||
|         [[ -n "$GPAY_CERTIFICATE" ]] && args+=("--env-var" "certificate=${GPAY_CERTIFICATE}") |  | ||||||
|         [[ -n "$GPAY_CERTIFICATE_KEYS" ]] && args+=("--env-var" "certificate_keys=${GPAY_CERTIFICATE_KEYS}") |  | ||||||
|         newman run "${COLLECTION_PATH}" "${args[@]}" |  | ||||||
|         ;; |  | ||||||
| esac |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Pa1NarK
					Pa1NarK