Skip to content

Fix failing tests related to middleware because of form validation #524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading