Skip to content

Commit 6801e22

Browse files
Merge pull request #524 from deepjyoti30Alt/fix/failing-tests-related-to-middleware
Fix failing tests related to middleware because of form validation
2 parents 742d4cb + beae75c commit 6801e22

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

tests/test_middleware.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414

15-
from pytest import fixture, mark
16-
from supertokens_python import InputAppInfo, SupertokensConfig, init
17-
from supertokens_python.framework.fastapi import get_middleware
18-
from supertokens_python.recipe import emailpassword, session, passwordless
1915
import json
2016

2117
from fastapi import FastAPI
18+
from pytest import fixture, mark
19+
20+
from supertokens_python import InputAppInfo, SupertokensConfig, init
21+
from supertokens_python.framework.fastapi import get_middleware
22+
from supertokens_python.recipe import emailpassword, passwordless, session
2223
from tests.testclient import TestClientWithNoCookieJar as TestClient
23-
from tests.utils import clean_st, reset, setup_st, start_st, sign_up_request
24+
from tests.utils import clean_st, reset, setup_st, sign_up_request, start_st
2425

2526

2627
def setup_function(_):
@@ -61,7 +62,9 @@ async def test_rid_with_session_and_non_existent_api_in_session_recipe_still_hit
6162
start_st()
6263

6364
response = driver_config_client.post(url="/auth/signin", headers={"rid": "session"})
64-
assert response.status_code == 400
65+
assert response.status_code == 200
66+
dict_response = json.loads(response.text)
67+
assert dict_response["status"] == "FIELD_ERROR"
6568

6669

6770
@mark.asyncio
@@ -84,7 +87,9 @@ async def test_no_rid_with_existent_API_does_not_give_404(
8487
start_st()
8588

8689
response = driver_config_client.post(url="/auth/signin")
87-
assert response.status_code == 400
90+
assert response.status_code == 200
91+
dict_response = json.loads(response.text)
92+
assert dict_response["status"] == "FIELD_ERROR"
8893

8994

9095
@mark.asyncio
@@ -109,7 +114,9 @@ async def test_rid_as_anticsrf_with_existent_API_does_not_give_404(
109114
response = driver_config_client.post(
110115
url="/auth/signin", headers={"rid": "anti-csrf"}
111116
)
112-
assert response.status_code == 400
117+
assert response.status_code == 200
118+
dict_response = json.loads(response.text)
119+
assert dict_response["status"] == "FIELD_ERROR"
113120

114121

115122
@mark.asyncio
@@ -132,7 +139,9 @@ async def test_random_rid_with_existent_API_does_hits_api(
132139
start_st()
133140

134141
response = driver_config_client.post(url="/auth/signin", headers={"rid": "random"})
135-
assert response.status_code == 400
142+
assert response.status_code == 200
143+
dict_response = json.loads(response.text)
144+
assert dict_response["status"] == "FIELD_ERROR"
136145

137146

138147
@mark.asyncio

0 commit comments

Comments
 (0)