-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): add postman collection and newman github CI runner (#42)
- Loading branch information
1 parent
e4dc7b3
commit cff19cf
Showing
28 changed files
with
583 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: Run postman tests | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- "releases/*" | ||
pull_request: | ||
merge_group: | ||
types: [checks_requested] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
DATABASE_URL: postgres://db_user:db_pass@localhost/encryption_db | ||
USER: db_user | ||
PASSWORD: db_pass | ||
DB_NAME: encryption_db | ||
RUN_TESTS: ${{ ((github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name)) || (github.event_name == 'merge_group') }} | ||
|
||
jobs: | ||
runner: | ||
name: Run postman tests | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: "postgres:14.5" | ||
env: | ||
POSTGRES_USER: db_user | ||
POSTGRES_PASSWORD: db_pass | ||
POSTGRES_DB: encryption_db | ||
|
||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
steps: | ||
- name: Repository checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Skip tests for PRs from forks | ||
shell: bash | ||
if: ${{ env.RUN_TESTS == 'false' }} | ||
run: echo 'Skipping tests for PRs from forks' | ||
|
||
- name: Install Rust | ||
if: ${{ env.RUN_TESTS == 'true' }} | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: stable 2 weeks ago | ||
components: clippy | ||
|
||
- name: Build and Cache Rust Dependencies | ||
if: ${{ env.RUN_TESTS == 'true' }} | ||
uses: Swatinem/[email protected] | ||
|
||
- name: Install Diesel CLI with Postgres Support | ||
if: ${{ env.RUN_TESTS == 'true' }} | ||
uses: baptiste0928/[email protected] | ||
with: | ||
crate: diesel_cli | ||
features: postgres | ||
args: "--no-default-features" | ||
|
||
- name: Diesel migration run | ||
if: ${{ env.RUN_TESTS == 'true' }} | ||
shell: bash | ||
env: | ||
DATABASE_URL: postgres://db_user:db_pass@localhost:5432/encryption_db | ||
run: diesel migration run | ||
|
||
- name: Install newman from fork | ||
if: ${{ env.RUN_TESTS == 'true' }} | ||
run: npm install -g 'git+ssh://[email protected]:knutties/newman.git#feature/newman-dir' | ||
|
||
- name: Build project | ||
if: ${{ env.RUN_TESTS == 'true' }} | ||
run: cargo build --package cripta --bin cripta | ||
|
||
- name: Setup Local Server | ||
if: ${{ env.RUN_TESTS == 'true' }} | ||
run: | | ||
target/debug/cripta & | ||
SERVER_PID=$! | ||
COUNT=0 | ||
while ! nc -z localhost 5000; do | ||
if [ $COUNT -gt 12 ]; then | ||
echo "Server did not start within a reasonable time. Exiting." | ||
kill ${SERVER_PID} | ||
exit 1 | ||
else | ||
COUNT=$((COUNT+1)) | ||
sleep 10 | ||
fi | ||
done | ||
- name: Run Tests | ||
if: ${{ env.RUN_TESTS == 'true' }} | ||
env: | ||
BASE_URL: "http://localhost:5000" | ||
shell: bash | ||
run: newman dir-run postman/collection-dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
/target | ||
node_modules/ | ||
.env |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "hyperswitch-encryption-utility", | ||
"version": "0.1.0", | ||
"private": true, | ||
"description": "This is just to run automated newman tests for this service" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"info": { | ||
"_postman_id": "811976d7-1bd9-4e8d-ab77-4f903d6652f7", | ||
"name": "collection-dir", | ||
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json", | ||
"_exporter_id": "17145261" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"childrenOrder": [ | ||
"Create Key", | ||
"Encrypt Data", | ||
"Decrypt Data", | ||
"Rotate Key", | ||
"Transfer Key" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"variable":[ | ||
{ | ||
"key": "base_url", | ||
"value": "http://localhost:5000", | ||
"type": "string" | ||
}, | ||
{ | ||
"key":"tenant_id", | ||
"value":"public", | ||
"type":"text" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"eventOrder": ["event.test.js"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pm.test("Create Key - Status code is 200", function () { | ||
pm.response.to.have.status(200); | ||
}); | ||
|
||
(function () { | ||
let jsonData = pm.response.json(); | ||
pm.environment.set("key_version", jsonData.key_version); | ||
pm.environment.set("identifier", JSON.stringify(jsonData.identifier)); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"auth": { | ||
"type": "noauth" | ||
}, | ||
"method": "POST", | ||
"header": [ | ||
|
||
{ | ||
"key": "X-Tenant-ID", | ||
"value": "{{tenant_id}}", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
}, | ||
"raw_json_formatted": { | ||
"data_identifier": "User", | ||
"key_identifier": "123" | ||
} | ||
}, | ||
"url": "{{base_url}}/key/create" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"eventOrder": ["event.test.js"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pm.test("Decrypt Data - Status code is 200", function () { | ||
pm.response.to.have.status(200); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"auth": { | ||
"type": "noauth" | ||
}, | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "X-Tenant-ID", | ||
"value": "{{tenant_id}}", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
}, | ||
"raw_json_formatted": { | ||
"data_identifier": "User", | ||
"key_identifier": "123", | ||
"data": { | ||
"value": "{{value}}" | ||
} | ||
} | ||
}, | ||
"url": "{{base_url}}/data/decrypt" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"eventOrder": ["event.test.js"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pm.test("Decrypt Data - Status code is 200", function () { | ||
pm.response.to.have.status(200); | ||
}); | ||
var response = pm.response.json(); | ||
|
||
pm.environment.set("value", response.data.value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"auth": { | ||
"type": "noauth" | ||
}, | ||
"method": "POST", | ||
"header": [ | ||
|
||
{ | ||
"key": "X-Tenant-ID", | ||
"value": "{{tenant_id}}", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
}, | ||
"raw_json_formatted": { | ||
"data_identifier": "User", | ||
"key_identifier": "123", | ||
"data": { | ||
"value": "U2VjcmV0RGF0YQo=" | ||
} | ||
} | ||
}, | ||
"url": "{{base_url}}/data/encrypt" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"eventOrder": ["event.test.js"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pm.test("Decrypt Data - Status code is 200", function () { | ||
pm.response.to.have.status(200); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"auth": { | ||
"type": "noauth" | ||
}, | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "X-Tenant-ID", | ||
"value": "{{tenant_id}}", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
}, | ||
"raw_json_formatted": { | ||
"data_identifier": "User", | ||
"key_identifier": "123" | ||
} | ||
}, | ||
"url": "{{base_url}}/key/rotate" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"eventOrder": ["event.test.js"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pm.test("Decrypt Data - Status code is 200", function () { | ||
pm.response.to.have.status(200); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"auth": { | ||
"type": "noauth" | ||
}, | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "X-Tenant-ID", | ||
"value": "{{tenant_id}}", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
}, | ||
"raw_json_formatted": { | ||
"data_identifier": "User", | ||
"key_identifier": "123", | ||
"key": "VGhpcyBpcyAzMiBieXRlcyBmb3Igc3VyZSBub3chISE=" | ||
} | ||
}, | ||
"url": "{{base_url}}/key/transfer" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
Oops, something went wrong.