Skip to content

Commit 1d87314

Browse files
authored
Merge pull request #61 from eadwinCode/restored_commented_test
restored commented tests
2 parents 41cb12a + c6d2157 commit 1d87314

File tree

1 file changed

+78
-78
lines changed

1 file changed

+78
-78
lines changed

tests/test_guard.py

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -124,84 +124,84 @@ def auth_demo_endpoint(request=Req()):
124124
HTTP_401_UNAUTHORIZED,
125125
BODY_UNAUTHORIZED_DEFAULT,
126126
),
127-
# (
128-
# "/apikeyquery-injectable?key=querysecretkey",
129-
# {},
130-
# 200,
131-
# dict(authentication="querysecretkey"),
132-
# ),
133-
# ("/apikeyheader", {}, HTTP_401_UNAUTHORIZED, BODY_UNAUTHORIZED_DEFAULT),
134-
# (
135-
# "/apikeyheader",
136-
# dict(headers={"key": "headersecretkey"}),
137-
# 200,
138-
# dict(authentication="headersecretkey"),
139-
# ),
140-
# ("/apikeycookie", {}, HTTP_401_UNAUTHORIZED, BODY_UNAUTHORIZED_DEFAULT),
141-
# (
142-
# "/apikeycookie",
143-
# dict(cookies={"key": "cookiesecretkey"}),
144-
# 200,
145-
# dict(authentication="cookiesecretkey"),
146-
# ),
147-
# ("/basic", {}, HTTP_401_UNAUTHORIZED, BODY_UNAUTHORIZED_DEFAULT),
148-
# (
149-
# "/basic",
150-
# dict(headers={"Authorization": "Basic YWRtaW46c2VjcmV0"}),
151-
# 200,
152-
# dict(authentication="admin"),
153-
# ),
154-
# (
155-
# "/basic",
156-
# dict(headers={"Authorization": "YWRtaW46c2VjcmV0"}),
157-
# 200,
158-
# dict(authentication="admin"),
159-
# ),
160-
# (
161-
# "/basic",
162-
# dict(headers={"Authorization": "Basic invalid"}),
163-
# HTTP_401_UNAUTHORIZED,
164-
# {"detail": "Invalid authentication credentials"},
165-
# ),
166-
# (
167-
# "/basic",
168-
# dict(headers={"Authorization": "some invalid value"}),
169-
# HTTP_401_UNAUTHORIZED,
170-
# BODY_UNAUTHORIZED_DEFAULT,
171-
# ),
172-
# ("/bearer", {}, 401, BODY_UNAUTHORIZED_DEFAULT),
173-
# (
174-
# "/bearer",
175-
# dict(headers={"Authorization": "Bearer bearertoken"}),
176-
# 200,
177-
# dict(authentication="bearertoken"),
178-
# ),
179-
# (
180-
# "/bearer",
181-
# dict(headers={"Authorization": "Invalid bearertoken"}),
182-
# HTTP_401_UNAUTHORIZED,
183-
# {"detail": "Invalid authentication credentials"},
184-
# ),
185-
# ("/digest", {}, 401, BODY_UNAUTHORIZED_DEFAULT),
186-
# (
187-
# "/digest",
188-
# dict(headers={"Authorization": "Digest digesttoken"}),
189-
# 200,
190-
# dict(authentication="digesttoken"),
191-
# ),
192-
# (
193-
# "/digest",
194-
# dict(headers={"Authorization": "Invalid digesttoken"}),
195-
# HTTP_401_UNAUTHORIZED,
196-
# {"detail": "Invalid authentication credentials"},
197-
# ),
198-
# ("/customexception", {}, HTTP_401_UNAUTHORIZED, BODY_UNAUTHORIZED_DEFAULT),
199-
# (
200-
# "/customexception",
201-
# dict(headers={"key": "headersecretkey"}),
202-
# 200,
203-
# dict(authentication="headersecretkey"),
204-
# ),
127+
(
128+
"/apikeyquery-injectable?key=querysecretkey",
129+
{},
130+
200,
131+
dict(authentication="querysecretkey"),
132+
),
133+
("/apikeyheader", {}, HTTP_401_UNAUTHORIZED, BODY_UNAUTHORIZED_DEFAULT),
134+
(
135+
"/apikeyheader",
136+
dict(headers={"key": "headersecretkey"}),
137+
200,
138+
dict(authentication="headersecretkey"),
139+
),
140+
("/apikeycookie", {}, HTTP_401_UNAUTHORIZED, BODY_UNAUTHORIZED_DEFAULT),
141+
(
142+
"/apikeycookie",
143+
dict(cookies={"key": "cookiesecretkey"}),
144+
200,
145+
dict(authentication="cookiesecretkey"),
146+
),
147+
("/basic", {}, HTTP_401_UNAUTHORIZED, BODY_UNAUTHORIZED_DEFAULT),
148+
(
149+
"/basic",
150+
dict(headers={"Authorization": "Basic YWRtaW46c2VjcmV0"}),
151+
200,
152+
dict(authentication="admin"),
153+
),
154+
(
155+
"/basic",
156+
dict(headers={"Authorization": "YWRtaW46c2VjcmV0"}),
157+
200,
158+
dict(authentication="admin"),
159+
),
160+
(
161+
"/basic",
162+
dict(headers={"Authorization": "Basic invalid"}),
163+
HTTP_401_UNAUTHORIZED,
164+
{"detail": "Invalid authentication credentials"},
165+
),
166+
(
167+
"/basic",
168+
dict(headers={"Authorization": "some invalid value"}),
169+
HTTP_401_UNAUTHORIZED,
170+
BODY_UNAUTHORIZED_DEFAULT,
171+
),
172+
("/bearer", {}, 401, BODY_UNAUTHORIZED_DEFAULT),
173+
(
174+
"/bearer",
175+
dict(headers={"Authorization": "Bearer bearertoken"}),
176+
200,
177+
dict(authentication="bearertoken"),
178+
),
179+
(
180+
"/bearer",
181+
dict(headers={"Authorization": "Invalid bearertoken"}),
182+
HTTP_401_UNAUTHORIZED,
183+
{"detail": "Invalid authentication credentials"},
184+
),
185+
("/digest", {}, 401, BODY_UNAUTHORIZED_DEFAULT),
186+
(
187+
"/digest",
188+
dict(headers={"Authorization": "Digest digesttoken"}),
189+
200,
190+
dict(authentication="digesttoken"),
191+
),
192+
(
193+
"/digest",
194+
dict(headers={"Authorization": "Invalid digesttoken"}),
195+
HTTP_401_UNAUTHORIZED,
196+
{"detail": "Invalid authentication credentials"},
197+
),
198+
("/customexception", {}, HTTP_401_UNAUTHORIZED, BODY_UNAUTHORIZED_DEFAULT),
199+
(
200+
"/customexception",
201+
dict(headers={"key": "headersecretkey"}),
202+
200,
203+
dict(authentication="headersecretkey"),
204+
),
205205
],
206206
)
207207
def test_auth(path, kwargs, expected_code, expected_body):

0 commit comments

Comments
 (0)