@@ -4,8 +4,8 @@ use std::{collections::HashMap, env, thread};
4
4
use supabase_auth:: {
5
5
error:: Error ,
6
6
models:: {
7
- AuthClient , LoginEmailOtpParams , LoginWithOAuthOptions , LoginWithSSO , LogoutScope ,
8
- ResendParams , ResetPasswordOptions , SignUpWithPasswordOptions , UpdatedUser ,
7
+ AuthClient , EmailSignUpResult , LoginEmailOtpParams , LoginWithOAuthOptions , LoginWithSSO ,
8
+ LogoutScope , ResendParams , ResetPasswordOptions , SignUpWithPasswordOptions , UpdatedUser ,
9
9
} ,
10
10
} ;
11
11
@@ -73,7 +73,7 @@ async fn sign_up_with_email_test_valid() {
73
73
..Default :: default ( )
74
74
} ;
75
75
76
- let session = auth_client
76
+ let result = auth_client
77
77
. sign_up_with_email_and_password ( demo_email. as_ref ( ) , demo_password, Some ( options) )
78
78
. await
79
79
. unwrap ( ) ;
@@ -82,19 +82,21 @@ async fn sign_up_with_email_test_valid() {
82
82
let one_minute = time:: Duration :: from_secs ( 60 ) ;
83
83
thread:: sleep ( one_minute) ;
84
84
85
- assert ! ( session. user. email == demo_email) ;
86
- assert ! ( session. user. user_metadata. name. unwrap( ) == "test" ) ;
87
- assert ! (
88
- session
89
- . user
90
- . user_metadata
91
- . custom
92
- . get( "test" )
93
- . unwrap( )
94
- . as_str( )
95
- . unwrap( )
96
- == "test"
97
- )
85
+ if let EmailSignUpResult :: SessionResult ( session) = result {
86
+ assert ! ( session. user. email == demo_email) ;
87
+ assert ! ( session. user. user_metadata. name. unwrap( ) == "test" ) ;
88
+ assert ! (
89
+ session
90
+ . user
91
+ . user_metadata
92
+ . custom
93
+ . get( "test" )
94
+ . unwrap( )
95
+ . as_str( )
96
+ . unwrap( )
97
+ == "test"
98
+ )
99
+ }
98
100
}
99
101
100
102
#[ tokio:: test]
@@ -164,8 +166,8 @@ fn login_with_oauth_test() {
164
166
skip_brower_redirect : Some ( true ) ,
165
167
} ;
166
168
167
- let response = auth_client
168
- . login_with_oauth ( supabase_auth:: models:: Provider :: Github , Some ( options) ) ;
169
+ let response =
170
+ auth_client . login_with_oauth ( supabase_auth:: models:: Provider :: Github , Some ( options) ) ;
169
171
170
172
if response. is_err ( ) {
171
173
println ! ( "SIGN IN WITH OAUTH TEST RESPONSE -- \n {:?}" , response) ;
@@ -191,8 +193,8 @@ fn sign_up_with_oauth_test() {
191
193
skip_brower_redirect : Some ( true ) ,
192
194
} ;
193
195
194
- let response = auth_client
195
- . sign_up_with_oauth ( supabase_auth:: models:: Provider :: Github , Some ( options) ) ;
196
+ let response =
197
+ auth_client . sign_up_with_oauth ( supabase_auth:: models:: Provider :: Github , Some ( options) ) ;
196
198
197
199
if response. is_err ( ) {
198
200
println ! ( "SIGN IN WITH OAUTH TEST RESPONSE -- \n {:?}" , response) ;
@@ -217,8 +219,7 @@ fn login_with_oauth_no_options_test() {
217
219
// eprintln!("{:?}", session.as_ref().unwrap_err())
218
220
// }
219
221
220
- let response = auth_client
221
- . login_with_oauth ( supabase_auth:: models:: Provider :: Github , None ) ;
222
+ let response = auth_client. login_with_oauth ( supabase_auth:: models:: Provider :: Github , None ) ;
222
223
223
224
println ! (
224
225
"SIGN IN WITH OAUTH \n NO OPTIONS TEST RESPONSE -- \n {:?}" ,
@@ -379,12 +380,12 @@ async fn resend_email_test() {
379
380
let demo_email = format ! ( "signup__{}@demo.com" , uuid) ;
380
381
let demo_password = "ciJUAojfZZYKfCxkiUWH" ;
381
382
382
- let session = auth_client
383
+ let result = auth_client
383
384
. sign_up_with_email_and_password ( & demo_email, demo_password, None )
384
385
. await ;
385
386
386
- if session . is_err ( ) {
387
- eprintln ! ( "{:?}" , session . as_ref( ) . unwrap_err( ) )
387
+ if result . is_err ( ) {
388
+ eprintln ! ( "{:?}" , result . as_ref( ) . unwrap_err( ) )
388
389
}
389
390
390
391
let credentials = ResendParams {
@@ -403,7 +404,14 @@ async fn resend_email_test() {
403
404
println ! ( "{:?}" , response)
404
405
}
405
406
406
- assert ! ( response. is_ok( ) && session. unwrap( ) . user. email == demo_email)
407
+ match result. unwrap ( ) {
408
+ EmailSignUpResult :: SessionResult ( session) => {
409
+ assert ! ( response. is_ok( ) && session. user. email == demo_email)
410
+ }
411
+ EmailSignUpResult :: ConfirmationResult ( email_sign_up_confirmation) => {
412
+ assert ! ( response. is_ok( ) && email_sign_up_confirmation. email. unwrap( ) == demo_email)
413
+ }
414
+ }
407
415
}
408
416
409
417
#[ tokio:: test]
0 commit comments