mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +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
|
||||
matrix:
|
||||
connector:
|
||||
- adyen
|
||||
- aci
|
||||
# - authorizedotnet
|
||||
- bluesnap
|
||||
# - braintree
|
||||
- checkout
|
||||
# - iatapay
|
||||
# - multisafepay
|
||||
- nmi
|
||||
- stripe
|
||||
# - trustpay
|
||||
- worldline
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
@ -39,12 +48,13 @@ jobs:
|
||||
env:
|
||||
ADMIN_API_KEY: ${{ secrets.INTEG_ADMIN_API_KEY }}
|
||||
BASE_URL: ${{ secrets.INTEG_BASE_URL }}
|
||||
MERCHANT_ID: ${{ secrets.STRIPE_GATEWAY_MERCHANT_ID }}
|
||||
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 }}
|
||||
GPAY_CERTIFICATE: ${{ secrets.STRIPE_GPAY_CERTIFICATE }}
|
||||
GPAY_CERTIFICATE_KEYS: ${{ secrets.STRIPE_GPAY_CERTIFICATE_KEYS }}
|
||||
shell: bash
|
||||
run: ./scripts/postman_test_automation.sh ${{ matrix.connector }}
|
||||
uses: nick-fields/retry@v2
|
||||
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": {
|
||||
"_postman_id": "faf79340-e864-41f2-afe8-c87d2b593060",
|
||||
"_postman_id": "789922f3-108b-4c10-82c7-f03dd6c60059",
|
||||
"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)",
|
||||
"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"
|
||||
},
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"},
|
||||
"item": [
|
||||
{
|
||||
"name": "Health check",
|
||||
@ -2494,7 +2491,7 @@
|
||||
],
|
||||
"body": {
|
||||
"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": {
|
||||
"raw": {
|
||||
"language": "json"
|
||||
@ -11479,8 +11476,8 @@
|
||||
"",
|
||||
"// Response body should have value \"connector error\" for \"error type\"",
|
||||
"if (jsonData?.error?.type) {",
|
||||
"pm.test(\"[POST]::/payments - Content check if value for 'error.type' matches 'connector'\", function() {",
|
||||
" pm.expect(jsonData.error.type).to.eql(\"connector\");",
|
||||
"pm.test(\"[POST]::/payments - Content check if value for 'error.type' matches 'invalid_request'\", function() {",
|
||||
" pm.expect(jsonData.error.type).to.eql(\"invalid_request\");",
|
||||
"})};"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
@ -11579,8 +11576,14 @@
|
||||
"",
|
||||
"// Response body should have value \"connector error\" for \"error type\"",
|
||||
"if (jsonData?.error?.type) {",
|
||||
"pm.test(\"[POST]::/payments - Content check if value for 'error.type' matches 'connector'\", function() {",
|
||||
" pm.expect(jsonData.error.type).to.eql(\"connector\");",
|
||||
"pm.test(\"[POST]::/payments - Content check if value for 'error.type' matches 'invalid_request'\", function() {",
|
||||
" 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"
|
||||
|
||||
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>]
|
||||
# api_key = "HeadKey of <connector_name>"
|
||||
|
||||
API_KEY=$(echo "${result}" | awk -F ' = ' '$1 == "api_key" { print $2 }')
|
||||
KEY1=$(echo "${result}" | awk -F ' = ' '$1 == "key1" { print $2 }')
|
||||
API_SECRET=$(echo "${result}" | awk -F ' = ' '$1 == "api_secret" { print $2 }')
|
||||
|
||||
# Keys are set as variables since some API Keys for connectors such as ACI
|
||||
# are Base64 encoded and require "Bearer" to be prefixed such as "Bearer Skst45645gey5r#&$==".
|
||||
# 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
|
||||
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"
|
||||
elif [[ -n "${API_KEY}" && -n "${KEY1}" && -n "${API_SECRET}" ]]; then
|
||||
KEY_TYPE="SignatureKey"
|
||||
elif [[ -n "${API_KEY}" && -n "${KEY1}" && -n "${KEY2}" && -n "${API_SECRET}" ]]; then
|
||||
KEY_TYPE="MultiAuthKey"
|
||||
else
|
||||
KEY_TYPE="Invalid"
|
||||
fi
|
||||
@ -38,50 +45,22 @@ get_api_keys() {
|
||||
CONNECTOR_NAME="${1}"
|
||||
KEY_TYPE=""
|
||||
|
||||
API_KEY=""
|
||||
API_SECRET=""
|
||||
KEY1=""
|
||||
|
||||
# Function call
|
||||
get_api_keys "${CONNECTOR_NAME}"
|
||||
COLLECTION_PATH=$(path_generation "${CONNECTOR_NAME}")
|
||||
get_api_keys "${CONNECTOR_NAME}"
|
||||
|
||||
# Run Newman collection
|
||||
case "$KEY_TYPE" in
|
||||
"HeaderKey" )
|
||||
args=(
|
||||
--env-var "admin_api_key=${ADMIN_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}")
|
||||
[[ -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[@]}"
|
||||
;;
|
||||
"BodyKey" )
|
||||
args=(
|
||||
--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
|
||||
# Newman runner
|
||||
# Depending on the conditions satisfied, variables are added. Since certificates of stripe have already
|
||||
# been added to the postman collection, those conditions are set to true and collections that have
|
||||
# variables set up for certificate, will consider those variables and will fail.
|
||||
newman run "${COLLECTION_PATH}" \
|
||||
--env-var "admin_api_key=${ADMIN_API_KEY}" \
|
||||
--env-var "baseUrl=${BASE_URL}" \
|
||||
--env-var "connector_api_key=${API_KEY}" \
|
||||
$(if [[ "${KEY_TYPE}" == BodyKey ]]; then echo --env-var "connector_key1=${KEY1}"; fi) \
|
||||
$(if [[ "${KEY_TYPE}" == SignatureKey ]]; then echo --env-var "connector_key1=${KEY1}" --env-var "connector_api_secret=${API_SECRET}"; fi) \
|
||||
$(if [[ "${KEY_TYPE}" == MultiAuthKey ]]; then echo --env-var "connector_key1=${KEY1}" --env-var "connector_key2=${KEY2}" --env-var "connector_api_secret=${API_SECRET}"; fi) \
|
||||
$(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) \
|
||||
$(if [[ -n "${GPAY_CERTIFICATE_KEYS}" ]]; then echo --env-var "certificate_keys=${GPAY_CERTIFICATE_KEYS}"; fi) \
|
||||
--delay-request 5
|
||||
|
||||
Reference in New Issue
Block a user