Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.

QAware GmbH
QAware GmbHQAware GmbH
qaware.de
Endlich gute API Tests
Boldly Testing APIs Where No One Has
Tested Before
Ildikó Tárkányi
ildiko.tarkanyi@qaware.de
Ildikó Tárkányi
Senior Software Engineer @ QAware GmbH 2
QAware
Sonja Wegner
Lead Software Architect @ QAware GmbH 3
QAware
API Tests
5
QAware
6
QAware
7
QAware
8
QAware
9
QAware
10
QAware
11
QAware
12
QAware
Spezifikation/Schema Testing
14
QAware
openValidation
16
QAware
17
QAware
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
responses:
'200':
description: Speaker added successfully
18
QAware
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
x-ov-rules:
culture: en
rule: |
IF Name IS NOT Ildikó Tárkányi
AND Email DOES NOT CONTAIN @qaware.de
THEN Please register with your full name and business e-mail address
responses:
'200':
description: Speaker added successfully
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
x-ov-rules:
culture: en
rule: |
IF Name IS NOT Ildikó Tárkányi
AND Email DOES NOT CONTAIN @qaware.de
THEN Please register with your full name and business e-mail address
responses:
'200':
description: Speaker added successfully
19
QAware
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
responses:
'200':
description: Speaker added successfully
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
IF Name IS NOT Ildikó Tárkányi
AND Email DOES NOT CONTAIN @qaware.de
THEN Please register with your full name and business e-mail address
responses:
'200':
description: Speaker added successfully
20
QAware
Schlüsselwörter
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
x-ov-rules:
culture: en
rule: |
responses:
'200':
description: Speaker added successfully
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
IF Name IS NOT Ildikó Tárkányi
AND Email DOES NOT CONTAIN @qaware.de
THEN Please register with your full name and business e-mail address
responses:
'200':
description: Speaker added successfully
21
QAware
Schlüsselwörter
Schema-Attribute
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
x-ov-rules:
culture: en
rule: |
responses:
'200':
description: Speaker added successfully
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
IF Name IS NOT Ildikó Tárkányi
AND Email DOES NOT CONTAIN @qaware.de
THEN Please register with your full name and business e-mail address
responses:
'200':
description: Speaker added successfully
22
QAware
Schlüsselwörter
Schema-Attribute
Operanden
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
x-ov-rules:
culture: en
rule: |
responses:
'200':
description: Speaker added successfully
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
IF Name IS NOT Ildikó Tárkányi
AND Email DOES NOT CONTAIN @qaware.de
THEN Please register with your full name and business e-mail address
responses:
'200':
description: Speaker added successfully
23
QAware
Schlüsselwörter
Schema-Attribute
Operanden
domänenspezifische Operatoren
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
x-ov-rules:
culture: en
rule: |
responses:
'200':
description: Speaker added successfully
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
IF Name IS NOT Ildikó Tárkányi
AND Email DOES NOT CONTAIN @qaware.de
THEN Please register with your full name and business e-mail address
responses:
'200':
description: Speaker added successfully
24
QAware
Fehlermeldung
Schlüsselwörter
Schema-Attribute
Operanden
domänenspezifische Operatoren
openapi: 3.0.3
info:
version: 1.0.0
title: Conference Management Service
paths:
/speakers:
post:
requestBody:
content:
application/json:
schema:
properties:
Name:
type: string
Email:
type: number
x-ov-rules:
culture: en
rule: |
responses:
'200':
description: Speaker added successfully
Stoplight - Spectral
26
QAware
27
QAware
extends: ["spectral:oas", "spectral:asyncapi"]
formats: ["oas3"]
documentationUrl: https://www.example.com/docs/api-style-guide.md
parserOptions:
duplicateKeys: warn # error is the default value
aliases:
Paths:
- "$.paths[*]~"
rules:
paths-kebab-case:
description: Paths should be kebab-case.
message: "{{property}} should be kebab-case (lower-case and separated with hyphens)"
severity: warn
formats: ["oas3"]
given: "#Paths"
then:
function: pattern
functionOptions:
match: "^(/|[a-z0-9-.]+|{[a-zA-Z0-9_]+})+$"
28
QAware
extends: ["spectral:oas", "spectral:asyncapi"]
formats: ["oas3"]
documentationUrl: https://www.example.com/docs/api-style-guide.md
parserOptions:
duplicateKeys: warn # error is the default value
aliases:
Paths:
- "$.paths[*]~"
rules:
paths-kebab-case:
description: Paths should be kebab-case.
message: "{{property}} should be kebab-case (lower-case and separated with hyphens)"
severity: warn
formats: ["oas3"]
given: "#Paths"
then:
function: pattern
functionOptions:
match: "^(/|[a-z0-9-.]+|{[a-zA-Z0-9_]+})+$"
29
QAware
extends: ["spectral:oas", "spectral:asyncapi"]
formats: ["oas3"]
documentationUrl: https://www.example.com/docs/api-style-guide.md
parserOptions:
duplicateKeys: warn # error is the default value
aliases:
Paths:
- "$.paths[*]~"
rules:
paths-kebab-case:
description: Paths should be kebab-case.
message: "{{property}} should be kebab-case (lower-case and separated with hyphens)"
severity: warn
formats: ["oas3"]
given: "#Paths"
then:
function: pattern
functionOptions:
match: "^(/|[a-z0-9-.]+|{[a-zA-Z0-9_]+})+$"
30
QAware
B:.
├───stoplight
│
└───spectral
.spectral.yaml
myOpenAPI.yaml
B:stoplightspectral> spectral lint myOpenAPI.yaml
8:10 warning operation-description Operation "description" must be present and non-empty string.
paths./speakers.post
8:10 warning operation-operationId Operation must have "operationId".
paths./speakers.post
8:10 warning operation-tags Operation must have non-empty "tags" array.
paths./speakers.post
✖ 3 problems (0 errors, 3 warnings, 0 infos, 0 hints)
31
QAware
Contract Testing
33
QAware
34
QAware
pact
36
QAware
{
"metadata": {...},
"provider": {
"name": "speaker-provider"
},
"consumer": {
"name": "speaker-consumer"
},
"interactions": [
{
"description": "A GET request for a speaker",
"request": {
"method": "GET",
"path": "/speakers/some-name"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"body": {
"name": "some-name",
"email": "some-email"
}
}
},
{...}
]
}
37
QAware
1
2
3
4
38
QAware
@PactTestFor(providerName = "speaker-provider", hostInterface = "localhost")
public class SpeakerProviderPactTest {
@Pact(consumer = "agenda-consumer", provider = "speaker-provider")
public V4Pact createPactForSpeakerInteractions(PactDslWithProvider builder) {
PactDslJsonBody newSpeakerRequestBody = new PactDslJsonBody();
newSpeakerRequestBody.stringValue("name", "new-name")
.stringValue("email", "new-email")
.closeObject();
return builder
.uponReceiving("A POST request to add a speaker")
.path("/speakers")
.method(HttpMethod.POST)
.headers("Content-Type", "application/json")
.body(newSpeakerRequestBody)
.willRespondWith()
.status(204)
.toPact(V4Pact.class);
}
}
39
QAware
@Test
@PactTestFor
public void testSpeakerInteractions() {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
String jsonBody = "{"name": "new-name", "email": "new-email"}";
ResponseEntity<String> postResponse = new RestTemplate().exchange(
mockProvider.getUrl() + "/speakers",
HttpMethod.POST,
new HttpEntity<>(jsonBody, httpHeaders),
String.class
);
assertThat(postResponse.getStatusCode().value()).isEqualTo(204);
}
40
QAware
41
QAware
@Provider("speaker-provider")
@PactFolder("pacts")
class SpeakerProviderPactTest {
@BeforeEach
void setup(PactVerificationContext context) {
context.setTarget(new HttpTestTarget("localhost", 8080));
}
@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
void pactVerificationTestTemplate(PactVerificationContext context) {
context.verifyInteraction();
}
}
42
QAware
43
QAware
44
QAware
@Provider("speaker-provider")
@PactBroker(url = "http://localhost:9292")
class SpeakerProviderPactTest {
@BeforeEach
void setup(PactVerificationContext context) {
context.setTarget(new HttpTestTarget("localhost", 8080));
}
@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
void pactVerificationTestTemplate(PactVerificationContext context) {
context.verifyInteraction();
}
}
45
QAware
Trace-Testing
47
QAware
Tracetest
49
QAware
50
QAware
51
QAware
52
QAware
53
QAware
54
QAware
type: Test
spec:
id: Ugtm74WIg
name: speakers - POST
description: Create new speaker
trigger:
type: http
httpRequest:
method: POST
url: http://provider-service:8080/speakers
body: "{n "name": "some-name",n "email": "some-email"n}"
headers:
- key: Content-Type
value: application/json
specs:
- selector: span[tracetest.span.type="http"]
name: "Http span: response status code is 204"
assertions:
- attr:http.status_code = 204
- selector: span[tracetest.span.type="database"]
name: "Database span: processing time is less than 100ms"
assertions:
- attr:tracetest.span.duration < 100ms
- selector: span[tracetest.span.type="general" name="Tracetest trigger"]
name: "Trigger span: response time is less than 200ms"
assertions:
- attr:tracetest.span.duration < 200ms
55
QAware
B:.
├───tracetest
speakers_post.yaml
PS B:api-testing-demotracetest> tracetest run test --file speakers_post.yaml --output pretty
✔ speakers - POST (http://localhost:11633/test/Ugtm74WIg/run/42/test) - trace id: af60f652b4097a13120f001df3da4edd
✔ Http span: response status code is 204
✔ Database span: processing time is less than 100ms
✔ Trigger span: response time is less than 200ms
56
QAware
qaware.de
QAware GmbH
Aschauer Straße 32
81549 München
Tel. +49 89 232315-0
info@qaware.de
twitter.com/qaware
linkedin.com/company/qaware-gmbh
xing.com/companies/qawaregmbh
slideshare.net/qaware
github.com/qaware
Conclusion and Q&A
1 de 57

Recomendados

AWSug.nl Meetup @ New10 - SAM por
AWSug.nl Meetup @ New10 - SAMAWSug.nl Meetup @ New10 - SAM
AWSug.nl Meetup @ New10 - SAMMartijn van Dongen
110 vistas47 diapositivas
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard por
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardHow I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardSV Ruby on Rails Meetup
556 vistas123 diapositivas
Rails3 changesets por
Rails3 changesetsRails3 changesets
Rails3 changesetsWen-Tien Chang
1.3K vistas31 diapositivas
Deep dive on Serverless application development por
Deep dive on Serverless application developmentDeep dive on Serverless application development
Deep dive on Serverless application developmentAmazon Web Services
2.2K vistas46 diapositivas
Building Serverless Backends with AWS Lambda and Amazon API Gateway por
Building Serverless Backends with AWS Lambda and Amazon API GatewayBuilding Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API GatewayAmazon Web Services
2.8K vistas31 diapositivas
Academy PRO: Querying Elasticsearch por
Academy PRO: Querying ElasticsearchAcademy PRO: Querying Elasticsearch
Academy PRO: Querying ElasticsearchBinary Studio
107 vistas31 diapositivas

Más contenido relacionado

Similar a Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.

apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret por
apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauretapidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret
apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauretapidays
86 vistas110 diapositivas
Kasten securing access to your kubernetes applications por
Kasten securing access to your kubernetes applicationsKasten securing access to your kubernetes applications
Kasten securing access to your kubernetes applicationsLibbySchulze
159 vistas25 diapositivas
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs por
 Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbsAWS Chicago
378 vistas50 diapositivas
KNATIVE - DEPLOY, AND MANAGE MODERN CONTAINER-BASED SERVERLESS WORKLOADS por
KNATIVE - DEPLOY, AND MANAGE MODERN CONTAINER-BASED SERVERLESS WORKLOADSKNATIVE - DEPLOY, AND MANAGE MODERN CONTAINER-BASED SERVERLESS WORKLOADS
KNATIVE - DEPLOY, AND MANAGE MODERN CONTAINER-BASED SERVERLESS WORKLOADSElad Hirsch
47 vistas84 diapositivas
Ams adapters por
Ams adaptersAms adapters
Ams adaptersBruno Alló Bacarini
264 vistas62 diapositivas
Working with PowerVC via its REST APIs por
Working with PowerVC via its REST APIsWorking with PowerVC via its REST APIs
Working with PowerVC via its REST APIsJoe Cropper
2.6K vistas43 diapositivas

Similar a Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.(20)

apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret por apidays
apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauretapidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret
apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret
apidays86 vistas
Kasten securing access to your kubernetes applications por LibbySchulze
Kasten securing access to your kubernetes applicationsKasten securing access to your kubernetes applications
Kasten securing access to your kubernetes applications
LibbySchulze159 vistas
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs por AWS Chicago
 Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
AWS Chicago378 vistas
KNATIVE - DEPLOY, AND MANAGE MODERN CONTAINER-BASED SERVERLESS WORKLOADS por Elad Hirsch
KNATIVE - DEPLOY, AND MANAGE MODERN CONTAINER-BASED SERVERLESS WORKLOADSKNATIVE - DEPLOY, AND MANAGE MODERN CONTAINER-BASED SERVERLESS WORKLOADS
KNATIVE - DEPLOY, AND MANAGE MODERN CONTAINER-BASED SERVERLESS WORKLOADS
Elad Hirsch47 vistas
Working with PowerVC via its REST APIs por Joe Cropper
Working with PowerVC via its REST APIsWorking with PowerVC via its REST APIs
Working with PowerVC via its REST APIs
Joe Cropper2.6K vistas
Ninad cucumber rails por ninad23p
Ninad cucumber railsNinad cucumber rails
Ninad cucumber rails
ninad23p492 vistas
How to Write IAC for Serverless por Ryan Jones
How to Write IAC for ServerlessHow to Write IAC for Serverless
How to Write IAC for Serverless
Ryan Jones119 vistas
Presentation kyushu-2018 por masahitojp
Presentation kyushu-2018Presentation kyushu-2018
Presentation kyushu-2018
masahitojp568 vistas
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-... por Daniel Bryant
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
Daniel Bryant368 vistas
Software as a Service workshop / Unlocked: the Hybrid Cloud 12th May 2014 por Rackspace Academy
Software as a Service workshop / Unlocked: the Hybrid Cloud 12th May 2014Software as a Service workshop / Unlocked: the Hybrid Cloud 12th May 2014
Software as a Service workshop / Unlocked: the Hybrid Cloud 12th May 2014
Rackspace Academy1.2K vistas
Building an aws sdk for Perl - Granada Perl Workshop 2014 por Jose Luis Martínez
Building an aws sdk for Perl - Granada Perl Workshop 2014Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014
Jose Luis Martínez1.3K vistas
Apache Kafka - Scalable Message-Processing and more ! por Guido Schmutz
Apache Kafka - Scalable Message-Processing and more !Apache Kafka - Scalable Message-Processing and more !
Apache Kafka - Scalable Message-Processing and more !
Guido Schmutz873 vistas
AWS Lambda with Serverless Framework and Java por Manish Pandit
AWS Lambda with Serverless Framework and JavaAWS Lambda with Serverless Framework and Java
AWS Lambda with Serverless Framework and Java
Manish Pandit2.4K vistas
Document Conversion & Retrieve and Rank 一問一答 por Hisashi Komine
Document Conversion & Retrieve and Rank 一問一答Document Conversion & Retrieve and Rank 一問一答
Document Conversion & Retrieve and Rank 一問一答
Hisashi Komine1.1K vistas
Mасштабирование микросервисов на Go, Matt Heath (Hailo) por Ontico
Mасштабирование микросервисов на Go, Matt Heath (Hailo)Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Ontico2.6K vistas
CloudFormation experience por Vitebsk Miniq
CloudFormation experienceCloudFormation experience
CloudFormation experience
Vitebsk Miniq189 vistas
OpenShift Meetup - Tokyo - Service Mesh and Serverless Overview por María Angélica Bracho
OpenShift Meetup - Tokyo - Service Mesh and Serverless OverviewOpenShift Meetup - Tokyo - Service Mesh and Serverless Overview
OpenShift Meetup - Tokyo - Service Mesh and Serverless Overview

Más de QAware GmbH

Make Developers Fly: Principles for Platform Engineering por
Make Developers Fly: Principles for Platform EngineeringMake Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform EngineeringQAware GmbH
10 vistas44 diapositivas
Der Tod der Testpyramide? – Frontend-Testing mit Playwright por
Der Tod der Testpyramide? – Frontend-Testing mit PlaywrightDer Tod der Testpyramide? – Frontend-Testing mit Playwright
Der Tod der Testpyramide? – Frontend-Testing mit PlaywrightQAware GmbH
7 vistas34 diapositivas
Was kommt nach den SPAs por
Was kommt nach den SPAsWas kommt nach den SPAs
Was kommt nach den SPAsQAware GmbH
6 vistas47 diapositivas
Cloud Migration mit KI: der Turbo por
Cloud Migration mit KI: der Turbo Cloud Migration mit KI: der Turbo
Cloud Migration mit KI: der Turbo QAware GmbH
18 vistas23 diapositivas
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See... por
 Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See... Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...QAware GmbH
17 vistas13 diapositivas
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster por
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster QAware GmbH
16 vistas31 diapositivas

Más de QAware GmbH(20)

Make Developers Fly: Principles for Platform Engineering por QAware GmbH
Make Developers Fly: Principles for Platform EngineeringMake Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform Engineering
QAware GmbH10 vistas
Der Tod der Testpyramide? – Frontend-Testing mit Playwright por QAware GmbH
Der Tod der Testpyramide? – Frontend-Testing mit PlaywrightDer Tod der Testpyramide? – Frontend-Testing mit Playwright
Der Tod der Testpyramide? – Frontend-Testing mit Playwright
QAware GmbH7 vistas
Was kommt nach den SPAs por QAware GmbH
Was kommt nach den SPAsWas kommt nach den SPAs
Was kommt nach den SPAs
QAware GmbH6 vistas
Cloud Migration mit KI: der Turbo por QAware GmbH
Cloud Migration mit KI: der Turbo Cloud Migration mit KI: der Turbo
Cloud Migration mit KI: der Turbo
QAware GmbH18 vistas
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See... por QAware GmbH
 Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See... Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
QAware GmbH17 vistas
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster por QAware GmbH
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
QAware GmbH16 vistas
Kubernetes with Cilium in AWS - Experience Report! por QAware GmbH
Kubernetes with Cilium in AWS - Experience Report!Kubernetes with Cilium in AWS - Experience Report!
Kubernetes with Cilium in AWS - Experience Report!
QAware GmbH45 vistas
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP por QAware GmbH
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAPKontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP
QAware GmbH20 vistas
Blue turns green! Approaches and technologies for sustainable K8s clusters. por QAware GmbH
Blue turns green! Approaches and technologies for sustainable K8s clusters.Blue turns green! Approaches and technologies for sustainable K8s clusters.
Blue turns green! Approaches and technologies for sustainable K8s clusters.
QAware GmbH32 vistas
Per Anhalter zu Cloud Nativen API Gateways por QAware GmbH
Per Anhalter zu Cloud Nativen API GatewaysPer Anhalter zu Cloud Nativen API Gateways
Per Anhalter zu Cloud Nativen API Gateways
QAware GmbH30 vistas
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster por QAware GmbH
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
QAware GmbH22 vistas
How to speed up Spring Integration Tests por QAware GmbH
How to speed up Spring Integration TestsHow to speed up Spring Integration Tests
How to speed up Spring Integration Tests
QAware GmbH21 vistas
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster por QAware GmbH
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-ClusterAus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
QAware GmbH42 vistas
Cloud Migration – Eine Strategie die funktioniert por QAware GmbH
Cloud Migration – Eine Strategie die funktioniertCloud Migration – Eine Strategie die funktioniert
Cloud Migration – Eine Strategie die funktioniert
QAware GmbH28 vistas
Policy Driven Microservices mit Open Policy Agent por QAware GmbH
Policy Driven Microservices mit Open Policy AgentPolicy Driven Microservices mit Open Policy Agent
Policy Driven Microservices mit Open Policy Agent
QAware GmbH15 vistas
Make Developers Fly: Principles for Platform Engineering por QAware GmbH
Make Developers Fly: Principles for Platform EngineeringMake Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform Engineering
QAware GmbH61 vistas
Security Lab: OIDC in der Praxis por QAware GmbH
Security Lab: OIDC in der PraxisSecurity Lab: OIDC in der Praxis
Security Lab: OIDC in der Praxis
QAware GmbH19 vistas
Die nächsten 100 Microservices por QAware GmbH
Die nächsten 100 MicroservicesDie nächsten 100 Microservices
Die nächsten 100 Microservices
QAware GmbH14 vistas
Enterprise-level Kubernetes Security mit Open Source Tools - geht das? por QAware GmbH
Enterprise-level Kubernetes Security mit Open Source Tools - geht das?Enterprise-level Kubernetes Security mit Open Source Tools - geht das?
Enterprise-level Kubernetes Security mit Open Source Tools - geht das?
QAware GmbH33 vistas
Put the ‘Auto’ in Autoscaling – Make Kubernetes VPA and HPA work together for... por QAware GmbH
Put the ‘Auto’ in Autoscaling – Make Kubernetes VPA and HPA work together for...Put the ‘Auto’ in Autoscaling – Make Kubernetes VPA and HPA work together for...
Put the ‘Auto’ in Autoscaling – Make Kubernetes VPA and HPA work together for...
QAware GmbH20 vistas

Último

Benefits in Software Development por
Benefits in Software DevelopmentBenefits in Software Development
Benefits in Software DevelopmentJohn Valentino
6 vistas15 diapositivas
Electronic AWB - Electronic Air Waybill por
Electronic AWB - Electronic Air Waybill Electronic AWB - Electronic Air Waybill
Electronic AWB - Electronic Air Waybill Freightoscope
6 vistas1 diapositiva
Introduction to Maven por
Introduction to MavenIntroduction to Maven
Introduction to MavenJohn Valentino
7 vistas10 diapositivas
Bootstrapping vs Venture Capital.pptx por
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptxZeljko Svedic
16 vistas17 diapositivas
Introduction to Gradle por
Introduction to GradleIntroduction to Gradle
Introduction to GradleJohn Valentino
7 vistas7 diapositivas
Mobile App Development Company por
Mobile App Development CompanyMobile App Development Company
Mobile App Development CompanyRichestsoft
5 vistas6 diapositivas

Último(20)

Electronic AWB - Electronic Air Waybill por Freightoscope
Electronic AWB - Electronic Air Waybill Electronic AWB - Electronic Air Waybill
Electronic AWB - Electronic Air Waybill
Freightoscope 6 vistas
Bootstrapping vs Venture Capital.pptx por Zeljko Svedic
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptx
Zeljko Svedic16 vistas
Mobile App Development Company por Richestsoft
Mobile App Development CompanyMobile App Development Company
Mobile App Development Company
Richestsoft 5 vistas
Quality Engineer: A Day in the Life por John Valentino
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the Life
John Valentino10 vistas
predicting-m3-devopsconMunich-2023-v2.pptx por Tier1 app
predicting-m3-devopsconMunich-2023-v2.pptxpredicting-m3-devopsconMunich-2023-v2.pptx
predicting-m3-devopsconMunich-2023-v2.pptx
Tier1 app14 vistas
Ports-and-Adapters Architecture for Embedded HMI por Burkhard Stubert
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMI
Burkhard Stubert35 vistas
Dapr Unleashed: Accelerating Microservice Development por Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski16 vistas
Streamlining Your Business Operations with Enterprise Application Integration... por Flexsin
Streamlining Your Business Operations with Enterprise Application Integration...Streamlining Your Business Operations with Enterprise Application Integration...
Streamlining Your Business Operations with Enterprise Application Integration...
Flexsin 5 vistas
Top-5-production-devconMunich-2023.pptx por Tier1 app
Top-5-production-devconMunich-2023.pptxTop-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptx
Tier1 app10 vistas
Introduction to Git Source Control por John Valentino
Introduction to Git Source ControlIntroduction to Git Source Control
Introduction to Git Source Control
John Valentino8 vistas
JioEngage_Presentation.pptx por admin125455
JioEngage_Presentation.pptxJioEngage_Presentation.pptx
JioEngage_Presentation.pptx
admin1254559 vistas
Understanding HTML terminology por artembondar5
Understanding HTML terminologyUnderstanding HTML terminology
Understanding HTML terminology
artembondar58 vistas

Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.

  • 1. qaware.de Endlich gute API Tests Boldly Testing APIs Where No One Has Tested Before Ildikó Tárkányi ildiko.tarkanyi@qaware.de
  • 2. Ildikó Tárkányi Senior Software Engineer @ QAware GmbH 2 QAware
  • 3. Sonja Wegner Lead Software Architect @ QAware GmbH 3 QAware
  • 17. 17 QAware openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number responses: '200': description: Speaker added successfully
  • 18. 18 QAware openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number x-ov-rules: culture: en rule: | IF Name IS NOT Ildikó Tárkányi AND Email DOES NOT CONTAIN @qaware.de THEN Please register with your full name and business e-mail address responses: '200': description: Speaker added successfully
  • 19. openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number x-ov-rules: culture: en rule: | IF Name IS NOT Ildikó Tárkányi AND Email DOES NOT CONTAIN @qaware.de THEN Please register with your full name and business e-mail address responses: '200': description: Speaker added successfully 19 QAware openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number responses: '200': description: Speaker added successfully
  • 20. openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number IF Name IS NOT Ildikó Tárkányi AND Email DOES NOT CONTAIN @qaware.de THEN Please register with your full name and business e-mail address responses: '200': description: Speaker added successfully 20 QAware Schlüsselwörter openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number x-ov-rules: culture: en rule: | responses: '200': description: Speaker added successfully
  • 21. openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number IF Name IS NOT Ildikó Tárkányi AND Email DOES NOT CONTAIN @qaware.de THEN Please register with your full name and business e-mail address responses: '200': description: Speaker added successfully 21 QAware Schlüsselwörter Schema-Attribute openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number x-ov-rules: culture: en rule: | responses: '200': description: Speaker added successfully
  • 22. openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number IF Name IS NOT Ildikó Tárkányi AND Email DOES NOT CONTAIN @qaware.de THEN Please register with your full name and business e-mail address responses: '200': description: Speaker added successfully 22 QAware Schlüsselwörter Schema-Attribute Operanden openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number x-ov-rules: culture: en rule: | responses: '200': description: Speaker added successfully
  • 23. openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number IF Name IS NOT Ildikó Tárkányi AND Email DOES NOT CONTAIN @qaware.de THEN Please register with your full name and business e-mail address responses: '200': description: Speaker added successfully 23 QAware Schlüsselwörter Schema-Attribute Operanden domänenspezifische Operatoren openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number x-ov-rules: culture: en rule: | responses: '200': description: Speaker added successfully
  • 24. openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number IF Name IS NOT Ildikó Tárkányi AND Email DOES NOT CONTAIN @qaware.de THEN Please register with your full name and business e-mail address responses: '200': description: Speaker added successfully 24 QAware Fehlermeldung Schlüsselwörter Schema-Attribute Operanden domänenspezifische Operatoren openapi: 3.0.3 info: version: 1.0.0 title: Conference Management Service paths: /speakers: post: requestBody: content: application/json: schema: properties: Name: type: string Email: type: number x-ov-rules: culture: en rule: | responses: '200': description: Speaker added successfully
  • 27. 27 QAware extends: ["spectral:oas", "spectral:asyncapi"] formats: ["oas3"] documentationUrl: https://www.example.com/docs/api-style-guide.md parserOptions: duplicateKeys: warn # error is the default value aliases: Paths: - "$.paths[*]~" rules: paths-kebab-case: description: Paths should be kebab-case. message: "{{property}} should be kebab-case (lower-case and separated with hyphens)" severity: warn formats: ["oas3"] given: "#Paths" then: function: pattern functionOptions: match: "^(/|[a-z0-9-.]+|{[a-zA-Z0-9_]+})+$"
  • 28. 28 QAware extends: ["spectral:oas", "spectral:asyncapi"] formats: ["oas3"] documentationUrl: https://www.example.com/docs/api-style-guide.md parserOptions: duplicateKeys: warn # error is the default value aliases: Paths: - "$.paths[*]~" rules: paths-kebab-case: description: Paths should be kebab-case. message: "{{property}} should be kebab-case (lower-case and separated with hyphens)" severity: warn formats: ["oas3"] given: "#Paths" then: function: pattern functionOptions: match: "^(/|[a-z0-9-.]+|{[a-zA-Z0-9_]+})+$"
  • 29. 29 QAware extends: ["spectral:oas", "spectral:asyncapi"] formats: ["oas3"] documentationUrl: https://www.example.com/docs/api-style-guide.md parserOptions: duplicateKeys: warn # error is the default value aliases: Paths: - "$.paths[*]~" rules: paths-kebab-case: description: Paths should be kebab-case. message: "{{property}} should be kebab-case (lower-case and separated with hyphens)" severity: warn formats: ["oas3"] given: "#Paths" then: function: pattern functionOptions: match: "^(/|[a-z0-9-.]+|{[a-zA-Z0-9_]+})+$"
  • 30. 30 QAware B:. ├───stoplight │ └───spectral .spectral.yaml myOpenAPI.yaml B:stoplightspectral> spectral lint myOpenAPI.yaml 8:10 warning operation-description Operation "description" must be present and non-empty string. paths./speakers.post 8:10 warning operation-operationId Operation must have "operationId". paths./speakers.post 8:10 warning operation-tags Operation must have non-empty "tags" array. paths./speakers.post ✖ 3 problems (0 errors, 3 warnings, 0 infos, 0 hints)
  • 35. pact
  • 36. 36 QAware { "metadata": {...}, "provider": { "name": "speaker-provider" }, "consumer": { "name": "speaker-consumer" }, "interactions": [ { "description": "A GET request for a speaker", "request": { "method": "GET", "path": "/speakers/some-name" }, "response": { "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "name": "some-name", "email": "some-email" } } }, {...} ] }
  • 38. 38 QAware @PactTestFor(providerName = "speaker-provider", hostInterface = "localhost") public class SpeakerProviderPactTest { @Pact(consumer = "agenda-consumer", provider = "speaker-provider") public V4Pact createPactForSpeakerInteractions(PactDslWithProvider builder) { PactDslJsonBody newSpeakerRequestBody = new PactDslJsonBody(); newSpeakerRequestBody.stringValue("name", "new-name") .stringValue("email", "new-email") .closeObject(); return builder .uponReceiving("A POST request to add a speaker") .path("/speakers") .method(HttpMethod.POST) .headers("Content-Type", "application/json") .body(newSpeakerRequestBody) .willRespondWith() .status(204) .toPact(V4Pact.class); } }
  • 39. 39 QAware @Test @PactTestFor public void testSpeakerInteractions() { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.APPLICATION_JSON); String jsonBody = "{"name": "new-name", "email": "new-email"}"; ResponseEntity<String> postResponse = new RestTemplate().exchange( mockProvider.getUrl() + "/speakers", HttpMethod.POST, new HttpEntity<>(jsonBody, httpHeaders), String.class ); assertThat(postResponse.getStatusCode().value()).isEqualTo(204); }
  • 41. 41 QAware @Provider("speaker-provider") @PactFolder("pacts") class SpeakerProviderPactTest { @BeforeEach void setup(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", 8080)); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } }
  • 44. 44 QAware @Provider("speaker-provider") @PactBroker(url = "http://localhost:9292") class SpeakerProviderPactTest { @BeforeEach void setup(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", 8080)); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } }
  • 54. 54 QAware type: Test spec: id: Ugtm74WIg name: speakers - POST description: Create new speaker trigger: type: http httpRequest: method: POST url: http://provider-service:8080/speakers body: "{n "name": "some-name",n "email": "some-email"n}" headers: - key: Content-Type value: application/json specs: - selector: span[tracetest.span.type="http"] name: "Http span: response status code is 204" assertions: - attr:http.status_code = 204 - selector: span[tracetest.span.type="database"] name: "Database span: processing time is less than 100ms" assertions: - attr:tracetest.span.duration < 100ms - selector: span[tracetest.span.type="general" name="Tracetest trigger"] name: "Trigger span: response time is less than 200ms" assertions: - attr:tracetest.span.duration < 200ms
  • 55. 55 QAware B:. ├───tracetest speakers_post.yaml PS B:api-testing-demotracetest> tracetest run test --file speakers_post.yaml --output pretty ✔ speakers - POST (http://localhost:11633/test/Ugtm74WIg/run/42/test) - trace id: af60f652b4097a13120f001df3da4edd ✔ Http span: response status code is 204 ✔ Database span: processing time is less than 100ms ✔ Trigger span: response time is less than 200ms
  • 57. qaware.de QAware GmbH Aschauer Straße 32 81549 München Tel. +49 89 232315-0 info@qaware.de twitter.com/qaware linkedin.com/company/qaware-gmbh xing.com/companies/qawaregmbh slideshare.net/qaware github.com/qaware Conclusion and Q&A