Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Automated API tests using Postman CLI

on: push

jobs:
automated-api-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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 "53985486-f1b73652-140b-4afd-b365-23ae14516f39" -e "53985486-ae2364ed-fa80-59b7-8e3d-32deca3c4930" --report-events
17 changes: 17 additions & 0 deletions .postman/resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use this workspace to collaborate
workspace:
id: ""

localResources:
specs:
- ../contract/index.yaml

# Each entry here maps a local resource to one or more corresponding objects in Postman Cloud

cloudResources:
specs:
../contract/index.yaml: c45f6ab4-3160-48c3-bafe-117b7a29cb27
environments:
../postman/environments/Staging Environment.environment.yaml: 53985486-ae2364ed-fa80-59b7-8e3d-32deca3c4930
collections:
../postman/collections/User API Integration Tests: 53985486-f1b73652-140b-4afd-b365-23ae14516f39
11 changes: 11 additions & 0 deletions .postman/workflows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is a Workflow metadata file for defining entity relationships in this workspace.
# Each workflow defines relations between entities and may include optional behavior/settings.
# The Paths are relative to the .postman directory (avoid absolute paths).
# Keep relation entries explicit and avoid duplicate pairs within the same workflow.
# This file is declarative metadata and does not execute workflows by itself.
workflows:
syncSpecToCollection:
- spec: ../contract/index.yaml
collection: ../postman/collections/User API Integration Tests
options:
syncExamples: false
1 change: 1 addition & 0 deletions contract/index.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
openapi: 3.0.0
info:
description: for practice
title: User API
version: 1.0.0
paths:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$kind: collection
name: User API Integration Tests
description: for practice
auth:
- id: b3545068-2904-4059-8969-97cfdaad729c
type: apikey
name: apikey auth
credentials:
key: X-API-Key
value: "{{apiKey}}"
in: header
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$kind: collection
order: 1000
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$kind: collection
order: 1000
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
$kind: http-example
request:
url: "{{baseUrl}}/v1/users/login"
method: POST
headers:
- key: Content-Type
value: application/json
- key: Accept
value: application/json
- key: X-API-Key
value: <API Key>
description: "Added as a part of security scheme: apikey"
body:
type: json
content: |-
{
"username": "string",
"password": "string"
}
response:
statusCode: 500
statusText: Internal Server Error
headers:
Content-Type: application/json
body:
type: json
content: |-
{
"message": "string"
}
order: 3000
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
$kind: http-example
request:
url: "{{baseUrl}}/v1/users/login"
method: POST
headers:
- key: Content-Type
value: application/json
- key: Accept
value: application/json
- key: X-API-Key
value: <API Key>
description: "Added as a part of security scheme: apikey"
body:
type: json
content: |-
{
"username": "string",
"password": "string"
}
response:
statusCode: 401
statusText: Unauthorized
headers:
Content-Type: application/json
body:
type: json
content: |-
{
"message": "string"
}
order: 2000
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
$kind: http-example
request:
url: "{{baseUrl}}/v1/users/login"
method: POST
headers:
- key: Content-Type
value: application/json
- key: Accept
value: application/json
- key: X-API-Key
value: <API Key>
description: "Added as a part of security scheme: apikey"
body:
type: json
content: |-
{
"username": "string",
"password": "string"
}
response:
statusCode: 200
statusText: OK
headers:
Content-Type: application/json
body:
type: json
content: |-
{
"id": 9115,
"username": "string",
"token": "string"
}
order: 1000
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$kind: collection
order: 2000
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
$kind: http-request
name: Log in a user
url: "{{baseUrl}}/v1/users/login"
method: POST
headers:
Content-Type: application/json
Accept: application/json
body:
type: json
content: |-
{
"username": "{{username}}",
"password": "{{password}}"
}
scripts:
- type: afterResponse
code: |-
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
language: text/javascript
examples: ./.resources/Log in a user.resources/examples
order: 1000
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
$kind: http-example
request:
url: "{{baseUrl}}/v1/users/register"
method: POST
headers:
- key: Content-Type
value: application/json
- key: Accept
value: application/json
- key: X-API-Key
value: <API Key>
description: "Added as a part of security scheme: apikey"
body:
type: json
content: |-
{
"username": "string",
"password": "string"
}
response:
statusCode: 500
statusText: Internal Server Error
headers:
Content-Type: application/json
body:
type: json
content: |-
{
"message": "string"
}
order: 2000
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
$kind: http-example
request:
url: "{{baseUrl}}/v1/users/register"
method: POST
headers:
- key: Content-Type
value: application/json
- key: Accept
value: application/json
- key: X-API-Key
value: <API Key>
description: "Added as a part of security scheme: apikey"
body:
type: json
content: |-
{
"username": "string",
"password": "string"
}
response:
statusCode: 201
statusText: Created
headers:
Content-Type: application/json
body:
type: json
content: |-
{
"id": 9115,
"username": "string",
"token": "string"
}
order: 1000
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$kind: collection
order: 1000
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$kind: http-request
name: Register a new user
url: "{{baseUrl}}/v1/users/register"
method: POST
headers:
Content-Type: application/json
Accept: application/json
body:
type: json
content: |-
{
"username": "{{$randomUserName}}",
"password": "{{$randomPassword}}"
}
scripts:
- type: afterResponse
code: |
pm.test("Status code is 201", function () {
pm.response.to.have.status(201);
});

const jsonData = pm.response.json();
pm.variables.set("username", jsonData.username);
pm.variables.set("id", jsonData.id);
const requestBody = JSON.parse(pm.request.body)
pm.variables.set("password", requestBody.password);
language: text/javascript
examples: ./.resources/Register a new user.resources/examples
order: 1000
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
$kind: http-example
request:
url: "{{baseUrl}}/v1/users/:id"
method: DELETE
headers:
- key: Accept
value: application/json
- key: X-API-Key
value: <API Key>
description: "Added as a part of security scheme: apikey"
pathVariables:
id: "9696"
body:
type: text
content: ""
response:
statusCode: 500
statusText: Internal Server Error
headers:
Content-Type: application/json
body:
type: json
content: |-
{
"message": "string"
}
order: 2000
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
$kind: http-example
request:
url: "{{baseUrl}}/v1/users/:id"
method: DELETE
headers:
- key: Accept
value: application/json
- key: X-API-Key
value: <API Key>
description: "Added as a part of security scheme: apikey"
pathVariables:
id: "9696"
body:
type: text
content: ""
response:
statusCode: 200
statusText: OK
headers:
Content-Type: application/json
body:
type: json
content: |-
{
"message": "string"
}
order: 1000
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
$kind: http-example
request:
url: "{{baseUrl}}/v1/users/:id"
method: GET
headers:
- key: Accept
value: application/json
- key: X-API-Key
value: <API Key>
description: "Added as a part of security scheme: apikey"
pathVariables:
id: "9696"
body:
type: text
content: ""
response:
statusCode: 500
statusText: Internal Server Error
headers:
Content-Type: application/json
body:
type: json
content: |-
{
"message": "string"
}
order: 3000
Loading
Loading