Skip to content

Commit cb540c1

Browse files
committed
feat: Add tests for backward compatibility
1 parent b2d6ac2 commit cb540c1

12 files changed

Lines changed: 268 additions & 56 deletions

File tree

.github/workflows/build.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ jobs:
2929
run: mvn clean package -f address-validation-service/pom.xml -Dservice.name=address-validation-service
3030

3131
- name: Build with Docker
32-
run: docker compose build
32+
run: docker compose -f backward-compatibility/docker-compose.yaml build
3333

3434
- name: Start with Docker
35-
run: docker compose up -d
35+
run: docker compose -f backward-compatibility/docker-compose.yaml up -d
3636

3737
- name: Stop Docker Containers
38-
run: docker compose down
38+
run: docker compose -f backward-compatibility/docker-compose.yaml down
39+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
!.gitattributes
66
/keycloak/*
77
target/
8+
!.devcontainer
89
*.iml

README.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,26 @@
22

33
Herzlich willkommen zum Workshop API Design.
44

5-
## Übungen
5+
## Übung: Mehrere Versionen zur Verfügung stellen
66

7-
### API Design
7+
### Ausgangssituation
88

9-
- [OpenAPI](https://github.com/openknowledge/workshop-api-design/tree/openapi)
10-
- [Mocking](https://github.com/openknowledge/workshop-api-design/tree/wiremock)
11-
- [AsyncAPI](https://github.com/openknowledge/workshop-api-design/tree/asyncapi)
9+
Im Ordner `backward-compatibility` befinded sich eine `docker-compose.yaml`.
1210

13-
### API Testing
11+
Der Mock-Server kann unter [Wiremock](http://localhost:7070) aufgerufen werden.
12+
Er kann über die [Swagger UI](http://localhost:6060) bedient werden.
1413

15-
- [Pact](https://github.com/openknowledge/workshop-api-design/tree/pact-mock-server)
16-
- [Pact Pipeline](https://github.com/openknowledge/workshop-api-design/tree/pact)
14+
Getestet werden kann die API über [Hurl](https://hurl.dev/) (siehe Ordner `hurl`).
1715

18-
### API Security
16+
### Aufgabe
1917

20-
- [JWT](https://github.com/openknowledge/workshop-api-design/tree/jwt)
21-
- [OAuth2](https://github.com/openknowledge/workshop-api-design/tree/oauth2)
22-
- [OAuth2 mit PKCE](https://github.com/openknowledge/workshop-api-design/tree/oauth2-pkce)
18+
Konfiguriere den Wiremock-Server so, dass er die Version 1.0, 1.1 und 2.0
19+
des Billing Services zur Verfügung stellt.
2320

24-
### API Governance
21+
#### Hinweis
2522

26-
- [Linting](https://github.com/openknowledge/workshop-api-design/tree/linting)
23+
Nach jeder Änderung muss der Server neu gestartet werden.
2724

28-
### API Management
25+
### Ziel
2926

30-
- [Rate Limiting](https://github.com/openknowledge/workshop-api-design/tree/rate-limiting)
31-
- [Backstage](https://github.com/openknowledge/workshop-api-design/tree/backstage)
32-
33-
### API Operation
34-
35-
- [Observability](https://github.com/openknowledge/workshop-api-design/tree/observability)
36-
37-
### API Evolution
38-
39-
- [Versioning](https://github.com/openknowledge/workshop-api-design/tree/versioning)
27+
Alle Hurl-Tests sind (gleichzeitig) erfolgreich.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
services:
2+
3+
nginx:
4+
image: nginx:1.27.1
5+
ports:
6+
- "6060:80"
7+
volumes:
8+
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
9+
10+
swagger-ui:
11+
image: swaggerapi/swagger-ui:v5.17.7
12+
volumes:
13+
- "./swagger-ui:/usr/share/nginx/html/doc"
14+
environment:
15+
API_URL: "doc/openapi.yaml"
16+
17+
wiremock:
18+
image: wiremock/wiremock:3.5.4
19+
volumes:
20+
- "./wiremock:/home/wiremock"
21+
ports:
22+
- "7070:8080"
23+
24+
hurl:
25+
image: ghcr.io/orange-opensource/hurl:4.3.0
26+
command: "--retry 5 --test /home/address-1.0.hurl /home/address-1.1.hurl /home/address-2.0.hurl"
27+
volumes:
28+
- "./hurl:/home"
29+
depends_on:
30+
- wiremock
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
GET http://wiremock:8080/billing-addresses/0815
2+
Accept: application/vnd.de.openknowledge.onlineshop.v1+json
3+
4+
HTTP 200
5+
[Asserts]
6+
jsonpath "$.street.streetName" == "Am Rundtörn"
7+
jsonpath "$.street.houseNumber" == "30"
8+
jsonpath "$.city" == "26135 Oldenburg"
9+
10+
GET http://wiremock:8080/billing-addresses/0815
11+
Accept: application/json
12+
13+
HTTP 200
14+
[Asserts]
15+
jsonpath "$.street.streetName" == "Am Rundtörn"
16+
jsonpath "$.street.houseNumber" == "30"
17+
jsonpath "$.city" == "26135 Oldenburg"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
GET http://wiremock:8080/billing-addresses/0815
2+
Accept: application/json
3+
4+
HTTP 200
5+
[Asserts]
6+
jsonpath "$.addressLine1" == "Am Rundtörn 30"
7+
jsonpath "$.addressLine2" == ""
8+
jsonpath "$.location.zipCode" == "26135"
9+
jsonpath "$.location.cityName" == "Oldenburg"
10+
11+
GET http://wiremock:8080/billing-addresses/0815
12+
Accept: application/vnd.de.openknowledge.onlineshop.v1+json
13+
14+
HTTP 200
15+
[Asserts]
16+
jsonpath "$.addressLine1" == "Am Rundtörn 30"
17+
jsonpath "$.addressLine2" == ""
18+
jsonpath "$.location.zipCode" == "26135"
19+
jsonpath "$.location.cityName" == "Oldenburg"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
GET http://wiremock:8080/billing-addresses/0815
2+
Accept: application/vnd.de.openknowledge.onlineshop.v2+json
3+
4+
HTTP 200
5+
[Asserts]
6+
jsonpath "$.addressLine1" == "Am Rundtörn 30"
7+
jsonpath "$.addressLine2" == ""
8+
jsonpath "$.location.zipCode" == "26135"
9+
jsonpath "$.location.cityName" == "Oldenburg"
10+
jsonpath "$.street" not exists
11+
jsonpath "$.street.streetName" not exists
12+
jsonpath "$.street.houseNumber" not exists
13+
jsonpath "$.city" not exists
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
events {}
2+
3+
http {
4+
5+
server {
6+
listen 80;
7+
8+
location /billing-addresses/ {
9+
proxy_pass http://wiremock:8080;
10+
}
11+
location / {
12+
proxy_pass http://swagger-ui:8080/;
13+
}
14+
}
15+
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Billing Service
4+
version: 2.0.0
5+
servers:
6+
- url: http://localhost:6060
7+
paths:
8+
/billing-addresses/{customer_number}:
9+
get:
10+
operationId: getBillingAddress
11+
parameters:
12+
- explode: false
13+
in: path
14+
name: customer_number
15+
required: true
16+
schema:
17+
type: string
18+
responses:
19+
"200":
20+
description: The billing address of the customer
21+
content:
22+
application/json:
23+
schema:
24+
$ref: '#/components/schemas/AddressV1'
25+
example:
26+
street:
27+
streetName: "Am Rundtörn"
28+
houseNumber: "30"
29+
city: "26135 Oldenburg"
30+
application/vnd.de.openknowledge.onlineshop.v1+json:
31+
schema:
32+
$ref: '#/components/schemas/AddressV1'
33+
application/vnd.de.openknowledge.onlineshop.v2+json:
34+
schema:
35+
$ref: '#/components/schemas/Address'
36+
put:
37+
operationId: setBillingAddress
38+
parameters:
39+
- explode: false
40+
in: path
41+
name: customer_number
42+
required: true
43+
schema:
44+
type: string
45+
requestBody:
46+
content:
47+
application/json:
48+
schema:
49+
$ref: '#/components/schemas/AddressV1'
50+
example:
51+
addressLine1: "Am Rundtörn 30"
52+
addressLine2: ""
53+
location:
54+
zipCode: "26135"
55+
cityName: "Oldenburg"
56+
application/vnd.de.openknowledge.onlineshop.v1+json:
57+
schema:
58+
$ref: '#/components/schemas/AddressV1'
59+
application/vnd.de.openknowledge.onlineshop.v2+json:
60+
schema:
61+
$ref: '#/components/schemas/Address'
62+
responses:
63+
"204":
64+
description: Address was changed
65+
components:
66+
schemas:
67+
AddressV1:
68+
example:
69+
addressLine1: "Am Rundtörn 30"
70+
addressLine2: ""
71+
location:
72+
zipCode: "26135"
73+
cityName: "Oldenburg"
74+
properties:
75+
addressLine1:
76+
type: string
77+
addressLine2:
78+
type: string
79+
location:
80+
$ref: '#/components/schemas/Location'
81+
street:
82+
deprecated: true
83+
$ref: '#/components/schemas/Street'
84+
city:
85+
deprecated: true
86+
minLength: 1
87+
type: string
88+
required:
89+
- addressLine1
90+
- location
91+
Location:
92+
properties:
93+
zipCode:
94+
pattern: "\\d{5}"
95+
type: string
96+
cityName:
97+
minLength: 1
98+
type: string
99+
required:
100+
- zipCode
101+
- cityName
102+
Street:
103+
properties:
104+
streetName:
105+
minLength: 2
106+
type: string
107+
houseNumber:
108+
minLength: 1
109+
type: string
110+
required:
111+
- streetName
112+
- houseNumber
113+
Address:
114+
example:
115+
addressLine1: "Am Rundtörn 30"
116+
addressLine2: ""
117+
location:
118+
zipCode: "26135"
119+
cityName: "Oldenburg"
120+
properties:
121+
street:
122+
minLength: 2
123+
type: string
124+
house_number:
125+
minLength: 1
126+
type: string
127+
zip_code:
128+
pattern: "\\d{5}"
129+
type: string
130+
city:
131+
minLength: 1
132+
type: string
133+
required:
134+
- city
135+
- street
136+
- zip_code
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"street": {
3+
"streetName": "Am Rundtörn",
4+
"houseNumber": "30"
5+
},
6+
"city": "26135 Oldenburg"
7+
}

0 commit comments

Comments
 (0)