Skip to content

Commit f39abab

Browse files
committed
Compatibility test SecurityRequirements
1 parent 82ea15c commit f39abab

File tree

5 files changed

+159
-0
lines changed

5 files changed

+159
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.openapitools.openapidiff.core.backcompat;
2+
3+
import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiBackwardIncompatible;
4+
import static org.openapitools.openapidiff.core.TestUtils.assertSpecChangedButCompatible;
5+
import static org.openapitools.openapidiff.core.TestUtils.assertSpecUnchanged;
6+
7+
import org.junit.jupiter.api.Test;
8+
9+
public class SecurityRequirementsBCTest {
10+
private final String BASE = "bc_security_requirements_base.yaml";
11+
12+
@Test
13+
public void unchanged() {
14+
assertSpecUnchanged(BASE, BASE);
15+
}
16+
17+
@Test
18+
public void changedButCompatible() {
19+
assertSpecChangedButCompatible(BASE, "bc_security_requirements_changed_but_compatible.yaml");
20+
}
21+
22+
// TODO: Dropping *all* security requirements should be compatible. Refactor or document
23+
// reasoning. Context: OAS spec is clear that only one of the security requirement objects
24+
// need to be satisfied so it makes sense why dropping one could break a client that may
25+
// not yet support one of the remaining referenced security schemes. But dropping all
26+
// requirements should be compatible.
27+
@Test
28+
public void decreased() {
29+
assertOpenApiBackwardIncompatible(BASE, "bc_security_requirements_decreased.yaml");
30+
}
31+
32+
// TODO: A missing incompatible check seems to be if requirements increase from zero to 1 or more
33+
34+
@Test
35+
public void schemeTypeChanged() {
36+
assertOpenApiBackwardIncompatible(BASE, "bc_security_requirements_scheme_type_changed.yaml");
37+
}
38+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
openapi: 3.0.0
2+
info:
3+
description: myDesc
4+
title: myTitle
5+
version: 1.0.0
6+
paths:
7+
/widgets:
8+
get:
9+
operationId: listWidgets
10+
responses:
11+
'200':
12+
description: successful operation
13+
content:
14+
application/json:
15+
schema:
16+
type: string
17+
security:
18+
- my-scheme-1: []
19+
- my-scheme-2: []
20+
components:
21+
securitySchemes:
22+
my-scheme-1:
23+
type: http
24+
scheme: basic
25+
my-scheme-2:
26+
type: http
27+
scheme: basic
28+
my-scheme-3:
29+
type: http
30+
scheme: basic
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
openapi: 3.0.0
2+
info:
3+
description: myDesc
4+
title: myTitle
5+
version: 1.0.0
6+
paths:
7+
/widgets:
8+
get:
9+
operationId: listWidgets
10+
responses:
11+
'200':
12+
description: successful operation
13+
content:
14+
application/json:
15+
schema:
16+
type: string
17+
security:
18+
- my-scheme-1: []
19+
- my-scheme-2: []
20+
- my-scheme-3: []
21+
components:
22+
securitySchemes:
23+
my-scheme-1:
24+
type: http
25+
scheme: basic
26+
my-scheme-2:
27+
type: http
28+
scheme: basic
29+
my-scheme-3:
30+
type: http
31+
scheme: basic
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
openapi: 3.0.0
2+
info:
3+
description: myDesc
4+
title: myTitle
5+
version: 1.0.0
6+
paths:
7+
/widgets:
8+
get:
9+
operationId: listWidgets
10+
responses:
11+
'200':
12+
description: successful operation
13+
content:
14+
application/json:
15+
schema:
16+
type: string
17+
security:
18+
- my-scheme-1: []
19+
components:
20+
securitySchemes:
21+
my-scheme-1:
22+
type: http
23+
scheme: basic
24+
my-scheme-2:
25+
type: http
26+
scheme: basic
27+
my-scheme-3:
28+
type: http
29+
scheme: basic
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
openapi: 3.0.0
2+
info:
3+
description: myDesc
4+
title: myTitle
5+
version: 1.0.0
6+
paths:
7+
/widgets:
8+
get:
9+
operationId: listWidgets
10+
responses:
11+
'200':
12+
description: successful operation
13+
content:
14+
application/json:
15+
schema:
16+
type: string
17+
security:
18+
- my-scheme-1: []
19+
- my-scheme-2: []
20+
components:
21+
securitySchemes:
22+
my-scheme-1:
23+
type: apiKey
24+
name: api_key
25+
in: header
26+
my-scheme-2:
27+
type: http
28+
scheme: basic
29+
my-scheme-3:
30+
type: http
31+
scheme: basic

0 commit comments

Comments
 (0)