-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(ci): add postman collection and newman github CI runner #42
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2c0ae68
initial test workflow
vkhinvasara 4eb4636
initial template 2
vkhinvasara e53676e
initial workflow check 3
vkhinvasara d79d49d
Basic tests added
vkhinvasara bc7a8bf
final event checks
vkhinvasara b9ee005
bump version to 0.1.0 and update Postman requests for data encryption…
vkhinvasara 06ecfbb
Final changes
vkhinvasara 381b41d
minor tweaks
vkhinvasara 65bb69f
tweak 2
vkhinvasara 0bb982e
initial test workflow
vkhinvasara d589fd7
tweak 2
vkhinvasara 761f957
Merge branch 'main' of https://github.com/vkhinvasara/hyperswitch-enc…
vkhinvasara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pixincreate Should we have this check if the repo is a fork? I understand this is to prevent malicious actors running checks on the repo. But this is also preventing this PR for example, to run postman tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! Yes, we can remove that check here and everywhere since there is no sensitive information like credentials.
Still, I feel like it is better to have it as it gives us the approval control.
What do you say?