@@ -34,55 +34,90 @@ void main() {
3434 });
3535
3636 group ('enroll' , () {
37- test ('totp' , () async {
38- await client.signInWithPassword (password: password, email: email1);
39-
40- final res = await client.mfa
41- .enroll (issuer: 'MyFriend' , friendlyName: 'MyFriendName' );
42- final uri = Uri .parse (res.totp! .uri);
43-
44- expect (res.type, FactorType .totp);
45- expect (uri.queryParameters['issuer' ], 'MyFriend' );
46- expect (uri.scheme, 'otpauth' );
47- });
48-
49- test ('phone' , () async {
50- await client.signInWithPassword (password: password, email: email1);
51-
52- expect (
53- () => client.mfa
54- .enroll (factorType: FactorType .phone, phone: '+1234567890' ),
55- throwsA (isA <AuthApiException >().having (
56- (e) => e.message,
57- 'message' ,
58- 'MFA enroll is disabled for Phone' ,
59- )),
60- );
61- });
62-
63- test (
64- 'throws ArgumentError when phone factor type is used without phone number' ,
65- () async {
66- expect (
67- () => client.mfa.enroll (factorType: FactorType .phone),
68- throwsA (isA <ArgumentError >().having (
69- (e) => e.message,
70- 'message' ,
71- 'Phone number is required for phone factor type' ,
72- )),
73- );
37+ group ('deprecated method' , () {
38+ test ('totp' , () async {
39+ await client.signInWithPassword (password: password, email: email1);
40+
41+ final res = await client.mfa.enroll (
42+ issuer: 'MyFriend' ,
43+ friendlyName: 'MyFriendName' ,
44+ );
45+ final uri = Uri .parse (res.totp! .uri);
46+
47+ expect (res.type, FactorType .totp);
48+ expect (uri.queryParameters['issuer' ], 'MyFriend' );
49+ expect (uri.scheme, 'otpauth' );
50+ });
51+
52+ test ('phone' , () async {
53+ await client.signInWithPassword (password: password, email: email1);
54+
55+ expect (
56+ () => client.mfa.enroll (
57+ factorType: FactorType .phone,
58+ phone: '+1234567890' ,
59+ ),
60+ throwsA (isA <AuthApiException >().having (
61+ (e) => e.message,
62+ 'message' ,
63+ 'MFA enroll is disabled for Phone' ,
64+ )),
65+ );
66+ });
67+
68+ test ('throws ArgumentError when invalid arguments are provided' ,
69+ () async {
70+ expect (
71+ () => client.mfa.enroll (factorType: FactorType .phone),
72+ throwsA (isA <ArgumentError >().having (
73+ (e) => e.message,
74+ 'message' ,
75+ 'Invalid arguments, expected either phone or issuer.' ,
76+ )),
77+ );
78+
79+ expect (
80+ () => client.mfa.enroll (factorType: FactorType .totp),
81+ throwsA (isA <ArgumentError >().having (
82+ (e) => e.message,
83+ 'message' ,
84+ 'Invalid arguments, expected either phone or issuer.' ,
85+ )),
86+ );
87+ });
7488 });
7589
76- test ('throws ArgumentError when totp factor type is used without issuer' ,
77- () async {
78- expect (
79- () => client.mfa.enroll (factorType: FactorType .totp),
80- throwsA (isA <ArgumentError >().having (
81- (e) => e.message,
82- 'message' ,
83- 'Issuer is required for totp factor type' ,
84- )),
85- );
90+ group ('enrollWithParams' , () {
91+ test ('totp' , () async {
92+ await client.signInWithPassword (password: password, email: email1);
93+
94+ final res = await client.mfa.enrollWithParams (
95+ TOTPEnrollParams (
96+ issuer: 'MyFriend' ,
97+ friendlyName: 'MyFriendName' ,
98+ ),
99+ );
100+ final uri = Uri .parse (res.totp! .uri);
101+
102+ expect (res.type, FactorType .totp);
103+ expect (uri.queryParameters['issuer' ], 'MyFriend' );
104+ expect (uri.scheme, 'otpauth' );
105+ });
106+
107+ test ('phone' , () async {
108+ await client.signInWithPassword (password: password, email: email1);
109+
110+ expect (
111+ () => client.mfa.enrollWithParams (
112+ PhoneEnrollParams (phone: '+1234567890' ),
113+ ),
114+ throwsA (isA <AuthApiException >().having (
115+ (e) => e.message,
116+ 'message' ,
117+ 'MFA enroll is disabled for Phone' ,
118+ )),
119+ );
120+ });
86121 });
87122 });
88123
0 commit comments