Skip to content

Commit

Permalink
add test for empty whitelist (no auth) #1094
Browse files Browse the repository at this point in the history
  • Loading branch information
tfranzel committed Nov 2, 2023
1 parent 6e48a70 commit 41fef03
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2266,6 +2266,20 @@ class XViewset(viewsets.ReadOnlyModelViewSet):
assert schema['paths']['/x/']['get']['security'] == [{'tokenAuth': []}, {}]


@mock.patch(
'drf_spectacular.settings.spectacular_settings.AUTHENTICATION_WHITELIST', []
)
def test_authentication_empty_whitelist(no_warnings):
class XViewset(viewsets.ReadOnlyModelViewSet):
serializer_class = SimpleSerializer
queryset = SimpleModel.objects.none()
authentication_classes = [BasicAuthentication, TokenAuthentication]

schema = generate_schema('/x', XViewset)
assert 'securitySchemes' not in schema['components']
assert schema['paths']['/x/']['get']['security'] == [{}]


def test_request_response_raw_schema_annotation(no_warnings):
@extend_schema(
request={'application/pdf': {'type': 'string', 'format': 'binary'}},
Expand Down

0 comments on commit 41fef03

Please sign in to comment.