25
25
26
26
from firebase_admin import auth
27
27
from firebase_admin import tenant_mgt
28
+ from firebase_admin import multi_factor_config_mgt
28
29
from integration import test_auth
29
30
30
31
35
36
36
37
@pytest .fixture (scope = 'module' )
37
38
def sample_tenant ():
39
+ mfa_object = multi_factor_config_mgt .MultiFactorConfig (
40
+ provider_configs = [multi_factor_config_mgt .ProviderConfig (
41
+ state = multi_factor_config_mgt .ProviderConfig .State .ENABLED ,
42
+ totp_provider_config = multi_factor_config_mgt .TOTPProviderConfig (
43
+ adjacent_intervals = 5
44
+ )
45
+ )]
46
+ )
38
47
tenant = tenant_mgt .create_tenant (
39
48
display_name = 'admin-python-tenant' ,
40
49
allow_password_sign_up = True ,
41
- enable_email_link_sign_in = True )
50
+ enable_email_link_sign_in = True ,
51
+ multi_factor_config = mfa_object )
42
52
yield tenant
43
53
tenant_mgt .delete_tenant (tenant .tenant_id )
44
54
55
+ def _assert_multi_factor_config (mfa_config ):
56
+ assert isinstance (mfa_config , multi_factor_config_mgt .MultiFactorServerConfig )
57
+ assert len (mfa_config .provider_configs ) == 1
58
+ assert isinstance (mfa_config .provider_configs , list )
59
+ for provider_config in mfa_config .provider_configs :
60
+ assert isinstance (provider_config , multi_factor_config_mgt .MultiFactorServerConfig .\
61
+ ProviderConfigServerConfig )
62
+ assert provider_config .state == 'ENABLED'
63
+ assert isinstance (provider_config .totp_provider_config ,
64
+ multi_factor_config_mgt .MultiFactorServerConfig .ProviderConfigServerConfig
65
+ .TOTPProviderServerConfig )
66
+ assert provider_config .totp_provider_config .adjacent_intervals == 5
45
67
46
68
@pytest .fixture (scope = 'module' )
47
69
def tenant_user (sample_tenant ):
@@ -59,6 +81,7 @@ def test_get_tenant(sample_tenant):
59
81
assert tenant .display_name == 'admin-python-tenant'
60
82
assert tenant .allow_password_sign_up is True
61
83
assert tenant .enable_email_link_sign_in is True
84
+ _assert_multi_factor_config (tenant .multi_factor_config )
62
85
63
86
64
87
def test_list_tenants (sample_tenant ):
@@ -76,8 +99,17 @@ def test_list_tenants(sample_tenant):
76
99
77
100
78
101
def test_update_tenant ():
102
+ mfa_object = multi_factor_config_mgt .MultiFactorConfig (
103
+ provider_configs = [multi_factor_config_mgt .ProviderConfig (
104
+ state = multi_factor_config_mgt .ProviderConfig .State .ENABLED ,
105
+ totp_provider_config = multi_factor_config_mgt .TOTPProviderConfig (
106
+ adjacent_intervals = 5
107
+ )
108
+ )]
109
+ )
79
110
tenant = tenant_mgt .create_tenant (
80
- display_name = 'py-update-test' , allow_password_sign_up = True , enable_email_link_sign_in = True )
111
+ display_name = 'py-update-test' , allow_password_sign_up = True , enable_email_link_sign_in = True ,
112
+ multi_factor_config = mfa_object )
81
113
try :
82
114
tenant = tenant_mgt .update_tenant (
83
115
tenant .tenant_id , display_name = 'updated-py-tenant' , allow_password_sign_up = False ,
@@ -87,6 +119,7 @@ def test_update_tenant():
87
119
assert tenant .display_name == 'updated-py-tenant'
88
120
assert tenant .allow_password_sign_up is False
89
121
assert tenant .enable_email_link_sign_in is False
122
+ _assert_multi_factor_config (tenant .multi_factor_config )
90
123
finally :
91
124
tenant_mgt .delete_tenant (tenant .tenant_id )
92
125
0 commit comments