Skip to content

Commit

Permalink
Merge pull request #524 from deepjyoti30Alt/fix/failing-tests-related…
Browse files Browse the repository at this point in the history
…-to-middleware

Fix failing tests related to middleware because of form validation
  • Loading branch information
rishabhpoddar authored Sep 3, 2024
2 parents 742d4cb + beae75c commit 6801e22
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
# License for the specific language governing permissions and limitations
# under the License.

from pytest import fixture, mark
from supertokens_python import InputAppInfo, SupertokensConfig, init
from supertokens_python.framework.fastapi import get_middleware
from supertokens_python.recipe import emailpassword, session, passwordless
import json

from fastapi import FastAPI
from pytest import fixture, mark

from supertokens_python import InputAppInfo, SupertokensConfig, init
from supertokens_python.framework.fastapi import get_middleware
from supertokens_python.recipe import emailpassword, passwordless, session
from tests.testclient import TestClientWithNoCookieJar as TestClient
from tests.utils import clean_st, reset, setup_st, start_st, sign_up_request
from tests.utils import clean_st, reset, setup_st, sign_up_request, start_st


def setup_function(_):
Expand Down Expand Up @@ -61,7 +62,9 @@ async def test_rid_with_session_and_non_existent_api_in_session_recipe_still_hit
start_st()

response = driver_config_client.post(url="/auth/signin", headers={"rid": "session"})
assert response.status_code == 400
assert response.status_code == 200
dict_response = json.loads(response.text)
assert dict_response["status"] == "FIELD_ERROR"


@mark.asyncio
Expand All @@ -84,7 +87,9 @@ async def test_no_rid_with_existent_API_does_not_give_404(
start_st()

response = driver_config_client.post(url="/auth/signin")
assert response.status_code == 400
assert response.status_code == 200
dict_response = json.loads(response.text)
assert dict_response["status"] == "FIELD_ERROR"


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


@mark.asyncio
Expand All @@ -132,7 +139,9 @@ async def test_random_rid_with_existent_API_does_hits_api(
start_st()

response = driver_config_client.post(url="/auth/signin", headers={"rid": "random"})
assert response.status_code == 400
assert response.status_code == 200
dict_response = json.loads(response.text)
assert dict_response["status"] == "FIELD_ERROR"


@mark.asyncio
Expand Down

0 comments on commit 6801e22

Please sign in to comment.