예제 #1
0
    def test_update_non_shareable(self):
        """
        Tests updating groups that are non-shareable.
        """
        self.create_common_users_and_groups()
        sync = SyncUserAndGroups(
            tsurl=TS_URL,
            username=TS_USER,
            password=TS_PASSWORD,
            disable_ssl=True,
        )
        auag = sync.get_all_users_and_groups()

        # Change Group 1 and Group 2 and verify change took.
        group1 = auag.get_group("Group 1")
        group1.visibility = Visibility.NON_SHAREABLE
        group2 = auag.get_group("Group 2")
        group2.visibility = Visibility.DEFAULT

        # sync updates
        sync.sync_users_and_groups(users_and_groups=auag)

        # verify changes
        auag = sync.get_all_users_and_groups()
        self.assertEqual(
            auag.get_group("Group 1").visibility, Visibility.NON_SHAREABLE)
        self.assertEqual(
            auag.get_group("Group 2").visibility, Visibility.DEFAULT)
        self.assertEqual(
            auag.get_group('Group "3"').visibility, Visibility.NON_SHAREABLE)
예제 #2
0
def main():
    """
    Synchronize users and groups with ThoughtSpot from a properly formatted Excel file.
    """
    args = parse_args()
    if valid_args(args):
        uags = UGXLSReader().read_from_excel(args.filename)
        sync = SyncUserAndGroups(
            tsurl=args.ts_url,
            username=args.username,
            password=args.password,
            disable_ssl=args.disable_ssl,
        )
        sync.sync_users_and_groups(users_and_groups=uags,
                                   remove_deleted=args.purge)
예제 #3
0
    def test_syncing_user_and_groups_without_password(self):
        """
        Tests adding users and groups to ThoughtSpot.
        """

        auag = UsersAndGroups()

        auag.add_group(
            Group(
                name="Group 1",
                display_name="This is Group 1",
                description="A group for testing.",
                group_names=[],
            ))
        auag.add_group(
            Group(
                name="Group 2",
                display_name="This is Group 2",
                description="Another group for testing.",
                group_names=["Group 1"],
            ))

        auag.add_user(
            User(
                name="User1",
                password="******",
                display_name="User 1",
                group_names=["Group 1"],
            ))
        auag.add_user(
            User(
                name="User2",
                password="******",
                display_name="User 2",
                group_names=["Group 1", "Group 2"],
            ))

        # only works on Bill's AWS instance.
        sync = SyncUserAndGroups(
            tsurl=TS_URL,
            username=TS_USER,
            password=TS_PASSWORD,
            global_password="******",
            disable_ssl=True,
        )
        sync.sync_users_and_groups(auag)
예제 #4
0
    def test_update_password(self):
        """
        Tests updating a user password.
        """

        sync = SyncUserAndGroups(
            tsurl=TS_URL,
            username=TS_USER,
            password=TS_PASSWORD,
            disable_ssl=True,
        )
        auag = UsersAndGroups()
        auag.add_user(
            User(name="userx", display_name="User X", password="******"))
        # sync updates
        sync.sync_users_and_groups(users_and_groups=auag)
        sync.update_user_password(userid="userx",
                                  currentpassword=TS_PASSWORD,
                                  password="******")
예제 #5
0
    def create_common_users_and_groups(self):
        """
        Creates a set of users and groups that can be used in multiple tests.
        """
        auag = UsersAndGroups()

        auag.add_group(
            Group(
                name="Group 1",
                display_name="This is Group 1",
                description="A group for testing.",
                group_names=[],
                visibility=Visibility.DEFAULT,
            ))
        auag.add_group(
            Group(
                name="Group 2",
                display_name="This is Group 2",
                description="Another group for testing.",
                group_names=["Group 1"],
                visibility=Visibility.NON_SHAREABLE,
            ))
        # Testing for ability to handle embedded quotes.
        auag.add_group(
            Group(
                name='Group "3"',
                display_name='This is Group "3"',
                description='Another "group" for testing.',
                group_names=["Group 1"],
                visibility=Visibility.NON_SHAREABLE,
            ))

        auag.add_user(
            User(
                name="User1",
                password="******",
                display_name="User 1",
                mail="*****@*****.**",
                group_names=["Group 1"],
            ))
        auag.add_user(
            User(
                name="User2",
                password="******",
                display_name="User 2",
                mail="*****@*****.**",
                group_names=["Group 1", "Group 2"],
                visibility=Visibility.NON_SHAREABLE,
            ))

        # Testing for ability to handle embedded quotes.
        auag.add_user(
            User(
                name='User "3"',
                password="******",
                display_name='User "3"',
                mail="*****@*****.**",
                group_names=['Group "3"'],
            ))

        print(auag)

        sync = SyncUserAndGroups(
            tsurl=TS_URL,
            username=TS_USER,
            password=TS_PASSWORD,
            disable_ssl=True,
        )
        sync.sync_users_and_groups(auag, remove_deleted=True)