@@ -1845,9 +1845,13 @@ def generate_saml_response(
1845
1845
with {email}, {first_name}, {last_name} placeholders, that can
1846
1846
be filled out with the data we want.
1847
1847
"""
1848
- name_parts = name .split (" " )
1849
- first_name = name_parts [0 ]
1850
- last_name = name_parts [1 ]
1848
+ if name :
1849
+ name_parts = name .split (" " )
1850
+ first_name = name_parts [0 ]
1851
+ last_name = name_parts [1 ]
1852
+ else :
1853
+ first_name = ""
1854
+ last_name = ""
1851
1855
1852
1856
extra_attrs = ""
1853
1857
for extra_attr_name , extra_attr_values in extra_attributes .items ():
@@ -1877,6 +1881,29 @@ def generate_saml_response(
1877
1881
def get_account_data_dict (self , email : str , name : str ) -> Dict [str , Any ]:
1878
1882
return dict (email = email , name = name )
1879
1883
1884
+ def test_auth_registration_with_no_name_provided (self ) -> None :
1885
+ """
1886
+ The SAMLResponse may not actually provide name values, which is considered
1887
+ unexpected behavior for most social backends, but SAML is an exception. The
1888
+ signup flow should proceed normally, without pre-filling the name in the
1889
+ registration form.
1890
+ """
1891
+
1892
+ subdomain = "zulip"
1893
+ realm = get_realm ("zulip" )
1894
+ account_data_dict = self .get_account_data_dict (email = email , name = "" )
1895
+ result = self .social_auth_test (account_data_dict , subdomain = subdomain , is_signup = True )
1896
+ self .stage_two_of_registration (
1897
+ result ,
1898
+ realm ,
1899
+ subdomain ,
1900
+ email ,
1901
+ "" ,
1902
+ "Full Name" ,
1903
+ skip_registration_form = False ,
1904
+ expect_full_name_prepopulated = False ,
1905
+ )
1906
+
1880
1907
def test_social_auth_no_key (self ) -> None :
1881
1908
"""
1882
1909
Since in the case of SAML there isn't a direct equivalent of CLIENT_KEY_SETTING,
0 commit comments