示例#1
0
    def test_valid_client_id_and_client_secret(self):
        """
        given valid client id and secret values verify that we can use the
        toke manager to access account details
        """
        username, password = get_test_user_pass()
        app_url = get_test_app_url()

        #
        # you would provide a client_id and client_secret by retrieve them
        # from your jut profile but for unit testing we have to use the
        # token manager to retrieve such
        #
        token_manager = auth.TokenManager(username=username,
                                          password=password,
                                          app_url=app_url)

        authorization = authorizations.get_authorization(token_manager,
                                                         app_url=app_url)

        client_id = authorization['client_id']
        client_secret = authorization['client_secret']

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

        # use the token manager to retrieve the logged in user details
        account = accounts.get_logged_in_account(token_manager=token_manager,
                                                 app_url=app_url)

        self.assertEquals(account['username'], username)