@@ -719,6 +719,127 @@ async def test_optional_custom_field_without_input(driver_config_client: TestCli
719719 assert dict_response ["status" ] == "OK"
720720
721721
722+ @mark .asyncio
723+ async def test_non_optional_custom_field_with_boolean_value (
724+ driver_config_client : TestClient ,
725+ ):
726+ init (
727+ supertokens_config = SupertokensConfig ("http://localhost:3567" ),
728+ app_info = InputAppInfo (
729+ app_name = "SuperTokens Demo" ,
730+ api_domain = "http://api.supertokens.io" ,
731+ website_domain = "http://supertokens.io" ,
732+ api_base_path = "/auth" ,
733+ ),
734+ framework = "fastapi" ,
735+ recipe_list = [
736+ emailpassword .init (
737+ sign_up_feature = emailpassword .InputSignUpFeature (
738+ form_fields = [
739+ emailpassword .InputFormField ("autoVerify" , optional = False )
740+ ]
741+ )
742+ ),
743+ session .init (get_token_transfer_method = lambda _ , __ , ___ : "cookie" ),
744+ ],
745+ )
746+ start_st ()
747+
748+ response_1 = driver_config_client .post (
749+ url = "/auth/signup" ,
750+ headers = {"Content-Type" : "application/json" },
751+ json = {
752+ "formFields" : [
753+ {
"id" :
"email" ,
"value" :
"[email protected] " },
754+ {"id" : "password" , "value" : "validpassword123" },
755+ {"id" : "autoVerify" , "value" : False },
756+ ]
757+ },
758+ )
759+ assert response_1 .status_code == 200
760+ dict_response = json .loads (response_1 .text )
761+ assert dict_response ["status" ] == "OK"
762+
763+
764+ @mark .asyncio
765+ async def test_invalid_type_for_email_and_password (
766+ driver_config_client : TestClient ,
767+ ):
768+ init (
769+ supertokens_config = SupertokensConfig ("http://localhost:3567" ),
770+ app_info = InputAppInfo (
771+ app_name = "SuperTokens Demo" ,
772+ api_domain = "http://api.supertokens.io" ,
773+ website_domain = "http://supertokens.io" ,
774+ api_base_path = "/auth" ,
775+ ),
776+ framework = "fastapi" ,
777+ recipe_list = [
778+ emailpassword .init (
779+ sign_up_feature = emailpassword .InputSignUpFeature (form_fields = [])
780+ ),
781+ session .init (get_token_transfer_method = lambda _ , __ , ___ : "cookie" ),
782+ ],
783+ )
784+ start_st ()
785+
786+ response_1 = driver_config_client .post (
787+ url = "/auth/signup" ,
788+ headers = {"Content-Type" : "application/json" },
789+ json = {
790+ "formFields" : [
791+ {"id" : "email" , "value" : 123 },
792+ {"id" : "password" , "value" : "validpassword123" },
793+ ]
794+ },
795+ )
796+ assert response_1 .status_code == 400
797+ dict_response = json .loads (response_1 .text )
798+ assert dict_response ["message" ] == "email value must be a string"
799+
800+ response_1_signin = driver_config_client .post (
801+ url = "/auth/signin" ,
802+ headers = {"Content-Type" : "application/json" },
803+ json = {
804+ "formFields" : [
805+ {"id" : "email" , "value" : 123 },
806+ {"id" : "password" , "value" : "validpassword123" },
807+ ]
808+ },
809+ )
810+ assert response_1_signin .status_code == 400
811+ dict_response_signin = json .loads (response_1_signin .text )
812+ assert dict_response_signin ["message" ] == "email value must be a string"
813+
814+ response_2 = driver_config_client .post (
815+ url = "/auth/signup" ,
816+ headers = {"Content-Type" : "application/json" },
817+ json = {
818+ "formFields" : [
819+ {
"id" :
"email" ,
"value" :
"[email protected] " },
820+ {"id" : "password" , "value" : 12345 },
821+ ]
822+ },
823+ )
824+ assert response_2 .status_code == 400
825+ dict_response = json .loads (response_2 .text )
826+ assert dict_response ["message" ] == "password value must be a string"
827+
828+ response_2_signin = driver_config_client .post (
829+ url = "/auth/signin" ,
830+ headers = {"Content-Type" : "application/json" },
831+ json = {
832+ "formFields" : [
833+ {
"id" :
"email" ,
"value" :
"[email protected] " },
834+ {"id" : "password" , "value" : 12345 },
835+ ]
836+ },
837+ )
838+ assert response_2_signin .status_code == 400
839+ dict_response_signin = json .loads (response_2_signin .text )
840+ assert dict_response_signin ["message" ] == "password value must be a string"
841+
842+
722843@mark .asyncio
723844async def test_too_many_fields (driver_config_client : TestClient ):
724845 init (
0 commit comments