Skip to content

Commit

Permalink
add auth type TableauIDWithMFA
Browse files Browse the repository at this point in the history
  • Loading branch information
jacalata committed Jun 14, 2024
1 parent 8a42f75 commit 675c469
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tabcmd/commands/user/user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,13 @@ def to_tsc_user(self) -> TSC.UserItem:
"Unlicensed",
]

auth_types = ["Local", TSC.UserItem.Auth.SAML, TSC.UserItem.Auth.OpenID, TSC.UserItem.Auth.ServerDefault, "TableauId"]
auth_types = [
"Local",
TSC.UserItem.Auth.SAML,
TSC.UserItem.Auth.OpenID,
TSC.UserItem.Auth.ServerDefault,
TSC.UserItem.Auth.TableauIDWithMFA,
]


# username, password, display_name, license, admin_level, publishing, email, auth type
Expand Down Expand Up @@ -116,9 +122,8 @@ def set_auth_arg(parser):
choices=auth_types,
type=case_insensitive_string_type(auth_types),
# default="TableauID", # default is Local for on-prem, TableauID for Online. Does the server apply the default?
help="Assigns the authentication type for all users in the CSV file. \
For Tableau Online, TYPE may be TableauID (default) or SAML. \
For Tableau Server, TYPE may be Local (default) or SAML.",
help="Assigns the authentication type for all users in the CSV file. Possible roles: "
+ ", ".join(auth_types),
)
return parser

Expand Down
20 changes: 20 additions & 0 deletions tests/parsers/test_parser_create_site_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,23 @@ def test_create_site_user_parser_role(self):
mock_args = [commandname, "users.csv", "--site", "site-name"]
args = self.parser_under_test.parse_args(mock_args)
assert args.site_name == "site-name", args

def test_create_site_user_parser_auth_Default(self):
with mock.patch("builtins.open", mock.mock_open(read_data="test")):
mock_args = [commandname, "users.csv", "--site", "site-name", "--auth-type", "ServerDefault"]
args = self.parser_under_test.parse_args(mock_args)
assert args.site_name == "site-name", args
assert args.auth_type == "ServerDefault", args

def test_create_site_user_parser_auth_MFA(self):
with mock.patch("builtins.open", mock.mock_open(read_data="test")):
mock_args = [commandname, "users.csv", "--site", "site-name", "--auth-type", "TableauIDWithMFA"]
args = self.parser_under_test.parse_args(mock_args)
assert args.site_name == "site-name", args
assert args.auth_type == "TableauIDWithMFA", args

def test_create_site_user_parser_auth_TAbId_NotAvailable(self):
with mock.patch("builtins.open", mock.mock_open(read_data="test")):
mock_args = [commandname, "users.csv", "--site", "site-name", "--auth-type", "TableauId"]
with self.assertRaises(SystemExit):
args = self.parser_under_test.parse_args(mock_args)

0 comments on commit 675c469

Please sign in to comment.