Skip to content

Commit bc8cd84

Browse files
committed
[FIX] fastapi_auth_partner: Adapt to FastAPI's strict content checking
1 parent ffbe23f commit bc8cd84

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

fastapi_auth_partner/tests/test_auth.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def _register_partner(self):
4545
with self._create_test_client() as test_client, self.new_mails() as new_mails:
4646
response: Response = test_client.post(
4747
"/auth/register",
48+
headers={
49+
"Content-Type": "application/json",
50+
},
4851
content=json.dumps(
4952
{
5053
"name": "Loriot",
@@ -59,6 +62,9 @@ def _register_partner(self):
5962
def _login(self, test_client, password="supersecret"):
6063
response: Response = test_client.post(
6164
"/auth/login",
65+
headers={
66+
"Content-Type": "application/json",
67+
},
6268
content=json.dumps(
6369
{
6470
"login": "loriot@example.org",
@@ -105,6 +111,9 @@ def test_request_reset_password(self):
105111
with self._create_test_client() as test_client, self.new_mails() as new_mails:
106112
response: Response = test_client.post(
107113
"/auth/request_reset_password",
114+
headers={
115+
"Content-Type": "application/json",
116+
},
108117
content=json.dumps({"login": "loriot@example.org"}),
109118
)
110119
self.assertEqual(response.status_code, status.HTTP_200_OK, response.text)
@@ -121,6 +130,9 @@ def test_request_reset_password(self):
121130
token = str(new_mails.body).split("token=")[1].split('">')[0]
122131
response: Response = test_client.post(
123132
"/auth/set_password",
133+
headers={
134+
"Content-Type": "application/json",
135+
},
124136
content=json.dumps(
125137
{
126138
"password": "megasecret",
@@ -155,6 +167,9 @@ def test_validate_email(self):
155167
with self._create_test_client() as test_client:
156168
response: Response = test_client.post(
157169
"/auth/validate_email",
170+
headers={
171+
"Content-Type": "application/json",
172+
},
158173
content=json.dumps({"token": token}),
159174
)
160175
self.assertEqual(response.status_code, status.HTTP_200_OK, response.text)

fastapi_auth_partner/tests/test_fastapi_auth_partner_demo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def _register_partner(self):
4848
return self.url_open(
4949
"/fastapi_auth_partner_demo/auth/register",
5050
timeout=1000,
51+
headers={
52+
"Content-Type": "application/json",
53+
},
5154
data=json.dumps(
5255
{
5356
"name": "Loriot",

0 commit comments

Comments
 (0)