Skip to content

Commit 55500c5

Browse files
committed
Add more test coverage; update changelog
1 parent aab652c commit 55500c5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
## [unreleased]
1818

1919
### Added
20+
* #1185 Add middleware for adding access token to request
2021
* #1273 Add caching of loading of OIDC private key.
2122
* #1285 Add post_logout_redirect_uris field in application views.
2223

tests/test_auth_backends.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,15 @@ def test_middleware_wrong_headers(self):
195195
m(request)
196196
self.assertFalse(hasattr(request, "access_token"))
197197

198+
def test_middleware_token_does_not_exist(self):
199+
m = OAuth2ExtraTokenMiddleware(self.dummy_get_response)
200+
auth_headers = {
201+
"HTTP_AUTHORIZATION": "Bearer " + "badtokstr",
202+
}
203+
request = self.factory.get("/a-resource", **auth_headers)
204+
m(request)
205+
self.assertFalse(hasattr(request, "access_token"))
206+
198207
def test_middleware_success(self):
199208
m = OAuth2ExtraTokenMiddleware(self.dummy_get_response)
200209
auth_headers = {

0 commit comments

Comments
 (0)