@@ -37,6 +37,7 @@ def make_user(
3737 domain : str = "" ,
3838 fullname : str = "" ,
3939 email : str = "" ,
40+ idp_id : str = "" ,
4041) -> TSC .UserItem :
4142 user = TSC .UserItem (name , site_role or None )
4243 if auth_setting :
@@ -47,6 +48,8 @@ def make_user(
4748 user .fullname = fullname
4849 if email :
4950 user .email = email
51+ if idp_id :
52+ user .idp_configuration_id = idp_id
5053 return user
5154
5255
@@ -415,6 +418,7 @@ def test_bulk_add(self):
415418 make_user ("Frank" , "SiteAdministratorExplorer" , "TableauIDWithMFA" , email = "Frank@example.com" ),
416419 make_user ("Grace" , "SiteAdministratorCreator" , "SAML" , "example.com" , "Grace Example" , "gex@example.com" ),
417420 make_user ("Hank" , "Unlicensed" ),
421+ make_user ("Ivy" , "Unlicensed" , idp_id = "0123456789" ),
418422 ]
419423 with requests_mock .mock () as m :
420424 m .post (f"{ self .server .users .baseurl } /import" , text = BULK_ADD_XML .read_text ())
@@ -446,7 +450,11 @@ def test_bulk_add(self):
446450
447451 for user , xml_user in zip (users , xml_users ):
448452 assert user .name == xml_user .get ("name" )
449- assert xml_user .get ("authSetting" ) == (user .auth_setting or "ServerDefault" )
453+ if user .idp_configuration_id is None :
454+ assert xml_user .get ("authSetting" ) == (user .auth_setting or "ServerDefault" )
455+ else :
456+ assert xml_user .get ("idpConfigurationId" ) == user .idp_configuration_id
457+ assert xml_user .get ("authSetting" ) is None
450458
451459 csv_data = create_users_csv (users ).replace (b"\r \n " , b"\n " )
452460 assert csv_data .strip () == segments [0 ].split (b"\n \n " )[1 ].strip ()
@@ -505,3 +513,10 @@ def test_add_all(self) -> None:
505513 self .server .users .add_all (users )
506514
507515 assert mock_add .call_count == len (users )
516+
517+ def test_add_idp_and_auth_error (self ) -> None :
518+ self .server .version = "3.24"
519+ users = [make_user ("Alice" , "Viewer" , auth_setting = "SAML" , idp_id = "01234" )]
520+
521+ with pytest .raises (ValueError , match = "User cannot have both authSetting and idpConfigurationId." ):
522+ self .server .users .bulk_add (users )
0 commit comments