Skip to content

Commit 445fac6

Browse files
committed
added some simple api exercises
1 parent a57689d commit 445fac6

File tree

2 files changed

+83
-3
lines changed

2 files changed

+83
-3
lines changed

challenger/src/main/resources/content/practice-sites.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,12 @@ These are full APIs online, which means you don't have to install anything and c
155155

156156
[Simple API](/practice-modes/simpleapi)
157157

158-
- [read our longer write up of Simple API here](/practice-sites/simpleapi)
158+
- [read our longer write up of Simple API with exercises here](/practice-sites/simpleapi)
159159
- An API for JSON and XML requests and responses.
160160
- A simple data structure to avoid personal data.
161161
- No Authentication required for updates.
162162
- Update requests are supported (`POST, PUT, DELETE`).
163+
- Two OpenAPI specification files: one for using the APi, one to support testing
163164

164165
---
165166

challenger/src/main/resources/content/practice-sites/simpleapi.md

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,86 @@ The API also supports both XML and JSON payloads by amending the `content-type`
7070

7171
## Exercises
7272

73-
Coming Soon.
73+
I've created a set of suggested exercises in case you need some prompting for practice.
7474

75+
### Exercise - Explore the Data in the Backend
7576

76-
77+
The SimpleAPI has a Data Explorer front end so that you can view the data in the backend.
78+
79+
- view the data to get a feel for the Entity that is used
80+
- [apichallenges.eviltester.com/simpleapi/gui/instances](https://apichallenges.eviltester.com/simpleapi/gui/instances?entity=item&database=__default)
81+
82+
### Exercise - Read the Documentation
83+
84+
The Simple API has:
85+
86+
- An [About Page](https://apichallenges.eviltester.com/practice-modes/simpleapi)
87+
- There is an ISBN generator here which might help when creating requests in the API to create and amend items
88+
- [Documentation](https://apichallenges.eviltester.com/simpleapi/docs)
89+
90+
### Exercise - try the Open API files in a Swagger UI
91+
92+
- Any Swagger UI can be used to load in the Open API files e.g.
93+
- Open the [PetStore Swagger UI](https://petstore.swagger.io/)
94+
- Paste into the url `[Explore]` field either of the [Simple API OpenAPI](/practice-modes/simpleapi-openapi) Urls
95+
- Normal `https://apichallenges.eviltester.com/simpleapi/docs/swagger`
96+
- Permissive `https://apichallenges.eviltester.com/simpleapi/docs/swagger?permissive`
97+
- Try each of the API files and see what difference they make to your testing e.g. the Permissive files does not have validation on the input parameters so you can explore more conditions.
98+
- OpenAPI files are designed for usage, not for testing, you should not rely on a Swagger UI for testing purposes.
99+
100+
### Exercise - Explore the `/items` endpoint
101+
102+
- The main endpoints `/items` will list all of the items in the system and allow creation of a new item
103+
- Explore these with `GET`, `OPTIONS`, `HEAD`
104+
- Try to create an item using `POST` on `/items`
105+
- if you don't know the format of the payload then copy one of hte item objects listed in the response of `GET /items`
106+
- you should not include an `id` in the `POST` request
107+
- the `isbn` field will need to be unique, you can generate a random `isbn` on this page or the [About](/practice-modes/simpleapi) page
108+
109+
110+
### Exercise - Explore the `/items/{id}` endpoint
111+
112+
- The individual endpoint `/item/{id}` will allow you to work with a single item using its id
113+
- Try to amend an item with `POST` on `/items/{id}` for an item that exists
114+
- Try to amend an item with `PUT` on `/items/{id}` for an item that exists
115+
- Try to delete an item with `DELETE` on `/items/{id}` for an item that exists
116+
- Check that the API responds with `404` when the item id does not exist
117+
118+
### Exercise - Explore the endpoints with all verbs
119+
120+
- CRUD operations are based around the `GET`, `PUT`, `POST` and `DELETE` verbs
121+
- Make sure you call the endpoints with other HTTP verbs e.g. `PATCH` and `TRACE`
122+
123+
### Exercise - Explore the `/items/{id}` field validations
124+
125+
- When you create or amend an item, check that the system enforces the validations for the fields listed in the documentation and the Open API spec
126+
- The ISBN must be unique in the system
127+
- The ISBN must match a specific format, try the different variations of the format
128+
- e.g. `384252925993-2`, `618-3051270614`, `9114-91-557340-1`, `2799488037490`
129+
- find more matching variations than the examples above
130+
- an easy only tool for generating values from Regex can be found [here](https://onlinetools.com/random/generate-random-data-from-regexp)
131+
- Check the field validations of the other fields as well
132+
133+
### Exercise - Explore the system data population validations
134+
135+
- The documentation says that there can be only 100 items, is that true?
136+
- What is the minimum number of items that can be in the system? Can it be brought down to 0, 1, 2, 3, ...?
137+
138+
### Exercise - Explore the random ISBN endpoint
139+
140+
- There is an endpoint for generating random ISBNs `GET /simpleapi/randomisbn`
141+
- Does it work they way you would expect?
142+
143+
### Exercise - Explore the `accept` header
144+
145+
- The Simple API supports both `JSON` and `XML`
146+
- You should be able to request `XML` as the response payload by using an `accept` header with the value `application/xml`
147+
- Do all endpoints and calls support this?
148+
149+
### Exercise - Explore the `content-type` header
150+
151+
- The Simple API supports both `JSON` and `XML`
152+
- You should be able to send request payloads as `XML` by using a `content-type` header with the value `application/xml`
153+
- Do all endpoints and calls support this?
154+
- Do you think you could mix and match `content-type` and `accept` so that you can send `JSON` and receive `XML`?
155+
- Could you send `XML` and receive `JSON`?

0 commit comments

Comments
 (0)