Merge pull request '🎁 📝 Provide Postman collection for testing' (#60) from provide-collection-for-testing into master
continuous-integration/drone/push Build is passing Details

Reviewed-on: #60
pull/62/head
Alexis Drai 2 years ago
commit 15bb089e55

@ -9,19 +9,23 @@
* [WebSocket](#websocket)
* [API type choices](#api-type-choices)
* [API Gateway](#api-gateway)
* [Testing the app](#testing-the-app)
## Global architecture
---
### Concept
This application attempts to modelize a cat café, with cafés (called "bars" here), cats, and customers.
---
### REST API
Those three entities can be persisted via a REST API. They can also be updated, queried, and removed.
We used an ASP .NET Web API, with a Swagger configuration to visualize the interface.
---
### WebSocket
A WebSocket was set up to notify clients (who subscribe to it) whenever a Cat is `POST`ed.
@ -40,6 +44,7 @@ new WebSocket("wss://localhost:5003/gateway/ws").onmessage = function (event) {
- `"entity-created"` is a hard-coded event ID and should not be changed.
- you are free to change the content of the `Alert` itself, of course
---
### API type choices
#### REST API
@ -61,8 +66,11 @@ Since the connection is opened once and closed once, we avoid any performance lo
and closing a connection for each request-response cycle. Similarly, a server that uses a websocket
can reduce its load, because it is now pushing updates directly instead of being polled regularly by many clients.
---
### API Gateway
#### How to launch both projects
An [Ocelot](https://ocelot.readthedocs.io/en/latest/) API Gateway manages the whole system.
It can be started using Visual Studio if you first right-click the cat-cafe.sln Solution, and go to Properties.
@ -155,6 +163,19 @@ The gateway uses rate limiting to make sure that clients cannot send an all-incl
}
} ...
```
---
## Testing the app
0. Prepare to use Postman
1. Start both the `cat_cafe` and `ApiGateway` projects (you may refer to [this procedure](#how-to-launch-both-projects)). Two browser windows will open, which you will not need to use much.
2. Use whichever browser window to open a WebSocket, so that you will get notifications (you may refer to [that procedure](#websocket))
3. In Postman, inside a workspace, click the `Import` button in the top left corner. Then click `Choose files` and find the collection to import in `docs/Cat Café.postman_collection.json`, in this repo. Follow the procedure to save it.
4. Keep an eye on the browser window you used to open a WebSocket, and execute the requests in this imported collection. When using `POST`, you should get an alert in the browser window.
Notice that the REST API and the WebSocket are accessed through our API Gateway.
In a real-life scenario, we could use IP-blocking or firewalls to ensure that port 7229 can only be accessed by the app itself and the gateway.
---
## To contribute (workflow)

@ -0,0 +1,229 @@
{
"info": {
"_postman_id": "4448c1b2-03b7-4b34-9d5b-ee364ff17986",
"name": "Cat Café",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "25802734"
},
"item": [
{
"name": "Create cat 1",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"name\": \"Versailles\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://localhost:5003/gateway/cats",
"protocol": "https",
"host": [
"localhost"
],
"port": "5003",
"path": [
"gateway",
"cats"
]
}
},
"response": []
},
{
"name": "Create cat 2",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"name\": \"Llanfair­pwll­gwyn­gyll­go­gery­chwyrn­drobwll­llan­tysilio­gogo­goch\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://localhost:5003/gateway/cats",
"protocol": "https",
"host": [
"localhost"
],
"port": "5003",
"path": [
"gateway",
"cats"
]
}
},
"response": []
},
{
"name": "Create cat 3",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"name\": \"London\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://localhost:5003/gateway/cats",
"protocol": "https",
"host": [
"localhost"
],
"port": "5003",
"path": [
"gateway",
"cats"
]
}
},
"response": []
},
{
"name": "Read all cats",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://localhost:5003/gateway/cats",
"protocol": "https",
"host": [
"localhost"
],
"port": "5003",
"path": [
"gateway",
"cats"
]
}
},
"response": []
},
{
"name": "Read cat 2",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://localhost:5003/gateway/cats/2",
"protocol": "https",
"host": [
"localhost"
],
"port": "5003",
"path": [
"gateway",
"cats",
"2"
]
}
},
"response": []
},
{
"name": "Update cat 3",
"request": {
"method": "PUT",
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"id\": 3,\r\n \"name\": \"Camden Town\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://localhost:5003/gateway/cats/3",
"protocol": "https",
"host": [
"localhost"
],
"port": "5003",
"path": [
"gateway",
"cats",
"3"
]
}
},
"response": []
},
{
"name": "Read all cats",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://localhost:5003/gateway/cats",
"protocol": "https",
"host": [
"localhost"
],
"port": "5003",
"path": [
"gateway",
"cats"
]
}
},
"response": []
},
{
"name": "Delete cat 1",
"request": {
"method": "DELETE",
"header": [],
"url": {
"raw": "https://localhost:5003/gateway/cats/1",
"protocol": "https",
"host": [
"localhost"
],
"port": "5003",
"path": [
"gateway",
"cats",
"1"
]
}
},
"response": []
},
{
"name": "Read all cats",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://localhost:5003/gateway/cats",
"protocol": "https",
"host": [
"localhost"
],
"port": "5003",
"path": [
"gateway",
"cats"
]
}
},
"response": []
}
]
}
Loading…
Cancel
Save