Skip to content

Commit 3b66bac

Browse files
✅ Add security tests to e2e dummy.
1 parent 256e24c commit 3b66bac

File tree

3 files changed

+82
-2
lines changed

3 files changed

+82
-2
lines changed

tests/e2e/expected/dummy/dummy.yaml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
openapi: 3.0.2
22
info:
3-
title: subschemas
3+
title: dummy
44
description: 'test generating /components/schemas with sub-schemas'
55
version: 1.0.0
66
paths:
@@ -32,6 +32,33 @@ paths:
3232
required:
3333
- prop1
3434
required: true
35+
/custom-security:
36+
get:
37+
description: Operation with its own security defined
38+
operationId: customSecurity
39+
responses:
40+
default:
41+
content:
42+
application/json:
43+
schema:
44+
$ref: '#/components/schemas/all'
45+
description: ''
46+
security:
47+
- oauth:
48+
- read
49+
/insecure:
50+
get:
51+
description: Operation with no security requirements
52+
operationId: customSecurity
53+
responses:
54+
default:
55+
content:
56+
application/json:
57+
schema:
58+
$ref: '#/components/schemas/all'
59+
description: ''
60+
security: []
61+
3562

3663
components:
3764
schemas:

tests/e2e/expected/dummy/gen/test_dummy/client.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,29 @@ async def test_op(
5050
})
5151
]:
5252
pass
53+
54+
@get('/custom-security', security=[{'oauth': ['read']}])
55+
async def customSecurity(
56+
self: typing.Self,
57+
) -> typing.Annotated[
58+
Awaitable[test_dummy.components.schemas.all.schema.all],
59+
Responses({
60+
'default': {
61+
'application/json': test_dummy.components.schemas.all.schema.all,
62+
},
63+
})
64+
]:
65+
pass
66+
67+
@get('/insecure', security=[])
68+
async def customSecurity(
69+
self: typing.Self,
70+
) -> typing.Annotated[
71+
Awaitable[test_dummy.components.schemas.all.schema.all],
72+
Responses({
73+
'default': {
74+
'application/json': test_dummy.components.schemas.all.schema.all,
75+
},
76+
})
77+
]:
78+
pass

tests/e2e/init/dummy/dummy.yaml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
openapi: 3.0.2
22
info:
3-
title: subschemas
3+
title: dummy
44
description: 'test generating /components/schemas with sub-schemas'
55
version: 1.0.0
66
paths:
@@ -32,6 +32,33 @@ paths:
3232
required:
3333
- prop1
3434
required: true
35+
/custom-security:
36+
get:
37+
description: Operation with its own security defined
38+
operationId: customSecurity
39+
responses:
40+
default:
41+
content:
42+
application/json:
43+
schema:
44+
$ref: '#/components/schemas/all'
45+
description: ''
46+
security:
47+
- oauth:
48+
- read
49+
/insecure:
50+
get:
51+
description: Operation with no security requirements
52+
operationId: customSecurity
53+
responses:
54+
default:
55+
content:
56+
application/json:
57+
schema:
58+
$ref: '#/components/schemas/all'
59+
description: ''
60+
security: []
61+
3562

3663
components:
3764
schemas:

0 commit comments

Comments
 (0)