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 sur 57

Recommandé

AWSug.nl Meetup @ New10 - SAM par
AWSug.nl Meetup @ New10 - SAMAWSug.nl Meetup @ New10 - SAM
AWSug.nl Meetup @ New10 - SAMMartijn van Dongen
110 vues47 diapositives
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard par
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 vues123 diapositives
Rails3 changesets par
Rails3 changesetsRails3 changesets
Rails3 changesetsWen-Tien Chang
1.3K vues31 diapositives
Deep dive on Serverless application development par
Deep dive on Serverless application developmentDeep dive on Serverless application development
Deep dive on Serverless application developmentAmazon Web Services
2.2K vues46 diapositives
Building Serverless Backends with AWS Lambda and Amazon API Gateway par
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 vues31 diapositives
Academy PRO: Querying Elasticsearch par
Academy PRO: Querying ElasticsearchAcademy PRO: Querying Elasticsearch
Academy PRO: Querying ElasticsearchBinary Studio
107 vues31 diapositives

Contenu connexe

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

apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret par
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 vues110 diapositives
Kasten securing access to your kubernetes applications par
Kasten securing access to your kubernetes applicationsKasten securing access to your kubernetes applications
Kasten securing access to your kubernetes applicationsLibbySchulze
159 vues25 diapositives
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs par
 Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbsAWS Chicago
378 vues50 diapositives
KNATIVE - DEPLOY, AND MANAGE MODERN CONTAINER-BASED SERVERLESS WORKLOADS par
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 vues84 diapositives
Ams adapters par
Ams adaptersAms adapters
Ams adaptersBruno Alló Bacarini
264 vues62 diapositives
Working with PowerVC via its REST APIs par
Working with PowerVC via its REST APIsWorking with PowerVC via its REST APIs
Working with PowerVC via its REST APIsJoe Cropper
2.6K vues43 diapositives

Similaire à 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 par 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 vues
Kasten securing access to your kubernetes applications par LibbySchulze
Kasten securing access to your kubernetes applicationsKasten securing access to your kubernetes applications
Kasten securing access to your kubernetes applications
LibbySchulze159 vues
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs par 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 vues
KNATIVE - DEPLOY, AND MANAGE MODERN CONTAINER-BASED SERVERLESS WORKLOADS par 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 vues
Working with PowerVC via its REST APIs par 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 vues
Ninad cucumber rails par ninad23p
Ninad cucumber railsNinad cucumber rails
Ninad cucumber rails
ninad23p492 vues
How to Write IAC for Serverless par Ryan Jones
How to Write IAC for ServerlessHow to Write IAC for Serverless
How to Write IAC for Serverless
Ryan Jones119 vues
Presentation kyushu-2018 par masahitojp
Presentation kyushu-2018Presentation kyushu-2018
Presentation kyushu-2018
masahitojp568 vues
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-... par 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 vues
Software as a Service workshop / Unlocked: the Hybrid Cloud 12th May 2014 par 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 vues
Building an aws sdk for Perl - Granada Perl Workshop 2014 par 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
Apache Kafka - Scalable Message-Processing and more ! par 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 vues
AWS Lambda with Serverless Framework and Java par 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 vues
Document Conversion & Retrieve and Rank 一問一答 par Hisashi Komine
Document Conversion & Retrieve and Rank 一問一答Document Conversion & Retrieve and Rank 一問一答
Document Conversion & Retrieve and Rank 一問一答
Hisashi Komine1.1K vues
Mасштабирование микросервисов на Go, Matt Heath (Hailo) par Ontico
Mасштабирование микросервисов на Go, Matt Heath (Hailo)Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Ontico2.6K vues

Plus de QAware GmbH

Der Tod der Testpyramide? – Frontend-Testing mit Playwright par
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 vues34 diapositives
Was kommt nach den SPAs par
Was kommt nach den SPAsWas kommt nach den SPAs
Was kommt nach den SPAsQAware GmbH
5 vues47 diapositives
Cloud Migration mit KI: der Turbo par
Cloud Migration mit KI: der Turbo Cloud Migration mit KI: der Turbo
Cloud Migration mit KI: der Turbo QAware GmbH
18 vues23 diapositives
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See... par
 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
16 vues13 diapositives
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster par
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 vues31 diapositives
Kubernetes with Cilium in AWS - Experience Report! par
Kubernetes with Cilium in AWS - Experience Report!Kubernetes with Cilium in AWS - Experience Report!
Kubernetes with Cilium in AWS - Experience Report!QAware GmbH
45 vues17 diapositives

Plus de QAware GmbH(20)

Der Tod der Testpyramide? – Frontend-Testing mit Playwright par 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 vues
Cloud Migration mit KI: der Turbo par QAware GmbH
Cloud Migration mit KI: der Turbo Cloud Migration mit KI: der Turbo
Cloud Migration mit KI: der Turbo
QAware GmbH18 vues
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See... par 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 GmbH16 vues
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster par 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 vues
Kubernetes with Cilium in AWS - Experience Report! par 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 vues
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP par 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 vues
Blue turns green! Approaches and technologies for sustainable K8s clusters. par 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 vues
Per Anhalter zu Cloud Nativen API Gateways par QAware GmbH
Per Anhalter zu Cloud Nativen API GatewaysPer Anhalter zu Cloud Nativen API Gateways
Per Anhalter zu Cloud Nativen API Gateways
QAware GmbH30 vues
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster par 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 vues
How to speed up Spring Integration Tests par QAware GmbH
How to speed up Spring Integration TestsHow to speed up Spring Integration Tests
How to speed up Spring Integration Tests
QAware GmbH21 vues
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster par 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 vues
Cloud Migration – Eine Strategie die funktioniert par QAware GmbH
Cloud Migration – Eine Strategie die funktioniertCloud Migration – Eine Strategie die funktioniert
Cloud Migration – Eine Strategie die funktioniert
QAware GmbH27 vues
Policy Driven Microservices mit Open Policy Agent par QAware GmbH
Policy Driven Microservices mit Open Policy AgentPolicy Driven Microservices mit Open Policy Agent
Policy Driven Microservices mit Open Policy Agent
QAware GmbH15 vues
Make Developers Fly: Principles for Platform Engineering par QAware GmbH
Make Developers Fly: Principles for Platform EngineeringMake Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform Engineering
QAware GmbH58 vues
Security Lab: OIDC in der Praxis par QAware GmbH
Security Lab: OIDC in der PraxisSecurity Lab: OIDC in der Praxis
Security Lab: OIDC in der Praxis
QAware GmbH19 vues
Die nächsten 100 Microservices par QAware GmbH
Die nächsten 100 MicroservicesDie nächsten 100 Microservices
Die nächsten 100 Microservices
QAware GmbH14 vues
Enterprise-level Kubernetes Security mit Open Source Tools - geht das? par 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 vues
Put the ‘Auto’ in Autoscaling – Make Kubernetes VPA and HPA work together for... par 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 GmbH19 vues
HTTP/3 und QUIC Making the internet faster par QAware GmbH
HTTP/3 und QUIC Making the internet fasterHTTP/3 und QUIC Making the internet faster
HTTP/3 und QUIC Making the internet faster
QAware GmbH37 vues

Dernier

DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ... par
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...Deltares
10 vues32 diapositives
Programming Field par
Programming FieldProgramming Field
Programming Fieldthehardtechnology
5 vues9 diapositives
Copilot Prompting Toolkit_All Resources.pdf par
Copilot Prompting Toolkit_All Resources.pdfCopilot Prompting Toolkit_All Resources.pdf
Copilot Prompting Toolkit_All Resources.pdfRiccardo Zamana
8 vues4 diapositives
MariaDB stored procedures and why they should be improved par
MariaDB stored procedures and why they should be improvedMariaDB stored procedures and why they should be improved
MariaDB stored procedures and why they should be improvedFederico Razzoli
8 vues32 diapositives
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... par
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Lisi Hocke
28 vues124 diapositives
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h... par
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...Deltares
5 vues31 diapositives

Dernier(20)

DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ... par Deltares
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...
Deltares10 vues
Copilot Prompting Toolkit_All Resources.pdf par Riccardo Zamana
Copilot Prompting Toolkit_All Resources.pdfCopilot Prompting Toolkit_All Resources.pdf
Copilot Prompting Toolkit_All Resources.pdf
MariaDB stored procedures and why they should be improved par Federico Razzoli
MariaDB stored procedures and why they should be improvedMariaDB stored procedures and why they should be improved
MariaDB stored procedures and why they should be improved
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... par Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke28 vues
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h... par Deltares
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...
Deltares5 vues
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge... par Deltares
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
Deltares17 vues
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with... par sparkfabrik
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik5 vues
DSD-INT 2023 The Danube Hazardous Substances Model - Kovacs par Deltares
DSD-INT 2023 The Danube Hazardous Substances Model - KovacsDSD-INT 2023 The Danube Hazardous Substances Model - Kovacs
DSD-INT 2023 The Danube Hazardous Substances Model - Kovacs
Deltares8 vues
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI... par Marc Müller
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Marc Müller37 vues
Navigating container technology for enhanced security by Niklas Saari par Metosin Oy
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas Saari
Metosin Oy13 vues
Software testing company in India.pptx par SakshiPatel82
Software testing company in India.pptxSoftware testing company in India.pptx
Software testing company in India.pptx
SakshiPatel827 vues
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J... par Deltares
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
Deltares9 vues
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... par Marc Müller
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
Marc Müller38 vues
A first look at MariaDB 11.x features and ideas on how to use them par Federico Razzoli
A first look at MariaDB 11.x features and ideas on how to use themA first look at MariaDB 11.x features and ideas on how to use them
A first look at MariaDB 11.x features and ideas on how to use them

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