Skip to content
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

added postman ci workflow #20

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/postman.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Automated API tests using Postman CLI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
automated-api-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Install Postman CLI
run: |
curl -o- "https://dl-cli.pstmn.io/install/linux64.sh" | sh
- name: Login to Postman CLI
run: postman login --with-api-key ${{ secrets.POSTMAN_API_KEY }}
- name: Run API tests
run: |
postman collection run "31208196-ebe740bc-2741-48ef-bdb6-e9ad85e8d39a" --reporters cli,junit --global-var api_url=http://localhost:8081
4 changes: 4 additions & 0 deletions .postman/api
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
apis[] = {"apiId":"73c72b7f-85af-473f-ac2e-bbcd0e3bd2c2"}
configVersion = 1.0.0
type = api
20 changes: 20 additions & 0 deletions .postman/api_73c72b7f-85af-473f-ac2e-bbcd0e3bd2c2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
configVersion = 1.1.0
type = apiEntityData

[config]
id = 73c72b7f-85af-473f-ac2e-bbcd0e3bd2c2

[config.relations]

[config.relations.collections]
rootDirectory = postman/collections

[config.relations.collections.metaData]

[config.relations.apiDefinition]
files[] = {"path":"index.json","metaData":{}}

[config.relations.apiDefinition.metaData]
type = openapi:3
rootFiles[] = index.json
171 changes: 171 additions & 0 deletions Postman Collections/SW7-API-Tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
{
"info": {
"_postman_id": "ebe740bc-2741-48ef-bdb6-e9ad85e8d39a",
"name": "Test Setup",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
"name": "Add Room",
"event": [
{
"listen": "test",
"script": {
"id": "2e729a33-8d83-4858-8712-26fb7ce08576",
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Response time is less than 1 s\", () => {",
" pm.expect(pm.response.responseTime).to.be.below(1000);",
"});"
],
"type": "text/javascript"
}
},
{
"listen": "prerequest",
"script": {
"id": "c4edb5a8-8719-49f6-bcd9-87a73f956cee",
"exec": [
"let roomid = pm.environment.get(\"RoomId\")",
"roomid ++",
"pm.environment.set(\"RoomId\", roomid)"
],
"type": "text/javascript"
}
}
],
"id": "c2e1a61f-d755-43cc-8201-7fb289ef1c48",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"RoomId\": -1,\n \"Name\": \"Test room {{RoomId}}\",\n \"Description\": \"Postman Test Room\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": "http://127.0.0.1:8081/room/add"
},
"response": []
},
{
"name": "Unregistered Trackers",
"event": [
{
"listen": "prerequest",
"script": {
"id": "c1a422b3-cf2c-4c46-b21b-4faa7c4f7867",
"exec": [
"let bluetoothMac = pm.environment.get(\"TrackerBluetoothMac\")",
"let wifiMac = pm.environment.get(\"TrackerWifiMac\")",
"",
"bluetoothMac ++",
"wifiMac ++",
"",
"pm.environment.set(\"TrackerBluetoothMac\", bluetoothMac)",
"pm.environment.set(\"TrackerWifiMac\", wifiMac)",
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"id": "975300aa-dc06-4068-8d6b-6b388fe0ff09",
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Response time is less than 1 s\", () => {",
" pm.expect(pm.response.responseTime).to.be.below(1000);",
"});"
],
"type": "text/javascript"
}
}
],
"id": "299f1464-fc5c-43ab-9e1e-1f0775ddf58e",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"unregisteredTrackers\": [\n {\n \"wifiMacAddress\": \"{{TrackerWifiMac}}\",\n \"bluetoothMacAddress\": \"{{TrackerBluetoothMac}}\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": "http://127.0.0.1:8081/tracker/registration/unregistered"
},
"response": []
},
{
"name": "Register Tracker",
"event": [
{
"listen": "prerequest",
"script": {
"id": "17bcfeed-8473-43f7-8c52-d7209d650a54",
"exec": [
"let trackerid = pm.environment.get(\"TrackerId\")",
"trackerid ++",
"pm.environment.set(\"TrackerId\", trackerid)"
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"id": "30090c71-011c-4387-a08b-9ae5d5727388",
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Response time is less than 1 s\", () => {",
" pm.expect(pm.response.responseTime).to.be.below(1000);",
"});"
],
"type": "text/javascript"
}
}
],
"id": "ac735894-40df-41ca-8109-0feeb5dd0156",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"roomId\": {{TrackerId}},\n \"name\": \"Tracker {{TrackerId}}\",\n \"description\": \"string\",\n \"wifiMacAddress\": \"{{TrackerBluetoothMac}}\",\n \"bluetoothMacAddress\": \"{{TrackerWifiMac}}\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": "http://127.0.0.1:8081/tracker/add"
},
"response": []
}
]
}
119 changes: 119 additions & 0 deletions index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Sample API",
"description": "Buy or rent spacecrafts"
},
"paths": {
"/spacecrafts/{spacecraftId}": {
"parameters": [
{
"name": "spacecraftId",
"description": "The unique identifier of the spacecraft",
"in": "path",
"required": true,
"schema": {
"$ref": "#/components/schemas/SpacecraftId"
}
}
],
"get": {
"summary": "Read a spacecraft",
"responses": {
"200": {
"description": "The spacecraft corresponding to the provided `spacecraftId`",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Spacecraft"
}
}
}
},
"404": {
"description": "No spacecraft found for the provided `spacecraftId`",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"500": {
"description": "Unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"SpacecraftId": {
"description": "The unique identifier of a spacecraft",
"type": "string"
},
"Spacecraft": {
"type": "object",
"required": [
"id",
"name",
"type"
],
"properties": {
"id": {
"$ref": "#/components/schemas/SpacecraftId"
},
"name": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"capsule",
"probe",
"satellite",
"spaceplane",
"station"
]
},
"description": {
"type": "string"
}
}
},
"Error": {
"type": "object",
"required": [
"message"
],
"properties": {
"message": {
"description": "A human readable error message",
"type": "string"
}
}
}
},
"securitySchemes": {
"ApiKey": {
"type": "apiKey",
"in": "header",
"name": "X-Api-Key"
}
}
},
"security": [
{
"ApiKey": []
}
]
}
Loading