Skip to content

Commit 9671ac3

Browse files
committed
Compatibility test SecurityScheme
1 parent f39abab commit 9671ac3

10 files changed

+396
-0
lines changed

core/src/main/java/org/openapitools/openapidiff/core/model/ChangedSecurityScheme.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public DiffResult isCoreChanged() {
4444
&& !changedBearerFormat
4545
&& !changedOpenIdConnectUrl
4646
&& (changedScopes == null || changedScopes.getIncreased().isEmpty())) {
47+
48+
// TODO: Dead code removal opportunity for changedType and changedIn. It appears that
49+
// SecuritySchemaDiff will never be given the chance to detect differences TYPE and
50+
// IN differences because that case has already been detected and filtered out by
51+
// SecurityRequirementsDiff and recorded as a dropped requirement in
52+
// ChangedSecurityRequirements.
53+
4754
return DiffResult.COMPATIBLE;
4855
}
4956
return DiffResult.INCOMPATIBLE;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 SecuritySchemeBCTest {
10+
private final String BASE = "bc_security_scheme_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_scheme_changed_but_compatible.yaml");
20+
}
21+
22+
@Test
23+
public void bearerFormatChanged() {
24+
assertOpenApiBackwardIncompatible(BASE, "bc_security_scheme_bearer_format_changed.yaml");
25+
}
26+
27+
@Test
28+
public void inChanged() {
29+
assertOpenApiBackwardIncompatible(BASE, "bc_security_scheme_in_changed.yaml");
30+
}
31+
32+
@Test
33+
public void openIdConnectUrlChanged() {
34+
assertOpenApiBackwardIncompatible(BASE, "bc_security_scheme_open_id_connect_url_changed.yaml");
35+
}
36+
37+
@Test
38+
public void schemeChanged() {
39+
assertOpenApiBackwardIncompatible(BASE, "bc_security_scheme_scheme_changed.yaml");
40+
}
41+
42+
@Test
43+
public void typeChanged() {
44+
assertOpenApiBackwardIncompatible(BASE, "bc_security_scheme_type_changed.yaml");
45+
}
46+
47+
@Test
48+
public void scopesIncreased() {
49+
assertOpenApiBackwardIncompatible(BASE, "bc_security_scheme_scopes_increased.yaml");
50+
}
51+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
- basic-scheme-1: []
19+
- apikey-scheme-1: []
20+
- openidconnect-scheme-1: []
21+
- oauth2-scheme-1:
22+
- "scope1"
23+
- "scope2"
24+
components:
25+
securitySchemes:
26+
apikey-scheme-1:
27+
type: apiKey
28+
name: api_key
29+
in: header
30+
basic-scheme-1:
31+
type: http
32+
openidconnect-scheme-1:
33+
type: openIdConnect
34+
openIdConnectUrl: https://example.com/api/openidconnect
35+
oauth2-scheme-1:
36+
type: oauth2
37+
flows:
38+
implicit:
39+
authorizationUrl: https://example.com/api/oauth/dialog
40+
scopes:
41+
scope1: scope1 description
42+
scope2: scope2 description
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
- basic-scheme-1: []
19+
- apikey-scheme-1: []
20+
- openidconnect-scheme-1: []
21+
- oauth2-scheme-1:
22+
- "scope1"
23+
- "scope2"
24+
components:
25+
securitySchemes:
26+
apikey-scheme-1:
27+
type: apiKey
28+
name: api_key
29+
in: header
30+
basic-scheme-1:
31+
type: http
32+
bearerFormat: myBearerFormat
33+
openidconnect-scheme-1:
34+
type: openIdConnect
35+
openIdConnectUrl: https://example.com/api/openidconnect
36+
oauth2-scheme-1:
37+
type: oauth2
38+
flows:
39+
implicit:
40+
authorizationUrl: https://example.com/api/oauth/dialog
41+
scopes:
42+
scope1: scope1 description
43+
scope2: scope2 description
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
- basic-scheme-1: []
19+
- apikey-scheme-1: []
20+
- openidconnect-scheme-1: []
21+
- oauth2-scheme-1:
22+
- "scope1"
23+
components:
24+
securitySchemes:
25+
apikey-scheme-1:
26+
type: apiKey
27+
name: api_key
28+
in: header
29+
basic-scheme-1:
30+
type: http
31+
openidconnect-scheme-1:
32+
type: openIdConnect
33+
openIdConnectUrl: https://example.com/api/openidconnect
34+
oauth2-scheme-1:
35+
type: oauth2
36+
flows:
37+
implicit:
38+
authorizationUrl: https://example.com/api/oauth/dialog
39+
scopes:
40+
scope1: scope1 description
41+
scope2: scope2 description
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
- basic-scheme-1: []
19+
- apikey-scheme-1: []
20+
- openidconnect-scheme-1: []
21+
- oauth2-scheme-1:
22+
- "scope1"
23+
- "scope2"
24+
components:
25+
securitySchemes:
26+
apikey-scheme-1:
27+
type: apiKey
28+
name: api_key
29+
in: query
30+
basic-scheme-1:
31+
type: http
32+
openidconnect-scheme-1:
33+
type: openIdConnect
34+
openIdConnectUrl: https://example.com/api/openidconnect
35+
oauth2-scheme-1:
36+
type: oauth2
37+
flows:
38+
implicit:
39+
authorizationUrl: https://example.com/api/oauth/dialog
40+
scopes:
41+
scope1: scope1 description
42+
scope2: scope2 description
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
- basic-scheme-1: []
19+
- apikey-scheme-1: []
20+
- openidconnect-scheme-1: []
21+
- oauth2-scheme-1:
22+
- "scope1"
23+
- "scope2"
24+
components:
25+
securitySchemes:
26+
apikey-scheme-1:
27+
type: apiKey
28+
name: api_key
29+
in: header
30+
basic-scheme-1:
31+
type: http
32+
openidconnect-scheme-1:
33+
type: openIdConnect
34+
openIdConnectUrl: https://example.com/api/openidconnect2
35+
oauth2-scheme-1:
36+
type: oauth2
37+
flows:
38+
implicit:
39+
authorizationUrl: https://example.com/api/oauth/dialog
40+
scopes:
41+
scope1: scope1 description
42+
scope2: scope2 description
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
- basic-scheme-1: []
19+
- apikey-scheme-1: []
20+
- openidconnect-scheme-1: []
21+
- oauth2-scheme-1:
22+
- "scope1"
23+
- "scope2"
24+
components:
25+
securitySchemes:
26+
apikey-scheme-1:
27+
type: apiKey
28+
name: api_key
29+
in: header
30+
basic-scheme-1:
31+
type: http
32+
scheme: Digest
33+
openidconnect-scheme-1:
34+
type: openIdConnect
35+
openIdConnectUrl: https://example.com/api/openidconnect
36+
oauth2-scheme-1:
37+
type: oauth2
38+
flows:
39+
implicit:
40+
authorizationUrl: https://example.com/api/oauth/dialog
41+
scopes:
42+
scope1: scope1 description
43+
scope2: scope2 description
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
- basic-scheme-1: []
19+
- apikey-scheme-1: []
20+
- openidconnect-scheme-1: []
21+
- oauth2-scheme-1:
22+
- "scope1"
23+
- "scope2"
24+
- "scope3"
25+
components:
26+
securitySchemes:
27+
apikey-scheme-1:
28+
type: apiKey
29+
name: api_key
30+
in: header
31+
basic-scheme-1:
32+
type: http
33+
openidconnect-scheme-1:
34+
type: openIdConnect
35+
openIdConnectUrl: https://example.com/api/openidconnect
36+
oauth2-scheme-1:
37+
type: oauth2
38+
flows:
39+
implicit:
40+
authorizationUrl: https://example.com/api/oauth/dialog
41+
scopes:
42+
scope1: scope1 description
43+
scope2: scope2 description

0 commit comments

Comments
 (0)