def test_delete_inexistent_account(self):
        """
        deleting an inexistent account reports the expected failure

        """
        username, password = get_test_user_pass()
        app_url = get_test_app_url()

        token_manager = auth.TokenManager(username=username,
                                          password=password,
                                          app_url=app_url)

        try:
            accounts.delete_user('blah',
                                 token_manager=token_manager,
                                 app_url=app_url)

        except JutException as exception:
            self.assertIn('Account not found', exception.message)
    def test_create_and_delete_account(self):
        """
        verify we can correctly create and delete a new account

        """
        username, password = get_test_user_pass()
        app_url = get_test_app_url()

        token_manager = auth.TokenManager(username=username,
                                          password=password,
                                          app_url=app_url)

        if accounts.user_exists('jut-tools-user03',
                                token_manager=token_manager,
                                app_url=app_url):
            user03_token_manager = auth.TokenManager(username='******',
                                                     password='******',
                                                     app_url=app_url)

            accounts.delete_user('jut-tools-user03',
                                 token_manager=user03_token_manager,
                                 app_url=app_url)

        account = accounts.create_user('Jut Tools User #3',
                                       'jut-tools-user03',
                                       '*****@*****.**',
                                       'bigdata',
                                       token_manager=token_manager,
                                       app_url=app_url)

        self.assertIn('id', account)

        user03_token_manager = auth.TokenManager(username='******',
                                                 password='******',
                                                 app_url=app_url)

        accounts.delete_user('jut-tools-user03',
                             token_manager=user03_token_manager,
                             app_url=app_url)
Esempio n. 3
0
def delete_user_from_default_deployment(username, password):
    """
    """

    configuration = config.get_default()
    app_url = configuration['app_url']
    client_id = configuration['client_id']
    client_secret = configuration['client_secret']

    token_manager = auth.TokenManager(client_id=client_id,
                                      client_secret=client_secret,
                                      app_url=app_url)

    if accounts.user_exists(username,
                            token_manager=token_manager,
                            app_url=app_url):

        delete_token_manager = auth.TokenManager(username=username,
                                                 password=password,
                                                 app_url=app_url)

        accounts.delete_user(username,
                             token_manager=delete_token_manager,
                             app_url=app_url)