Example #1
0
def test_create_user_hits_correct_api_endpoint():
    responses.add(
        authenticate_user.method,
        authenticate_user.url,
    )
    assert isinstance(authenticate_user(), Response)
    assert authenticate_user().status_code == 200
Example #2
0
 def request_new_token():
     localhost = 'http://%s:%s' % settings.LOCALHOST
     query = dict(next=localhost, callback_url=oauth_callback.url)
     response = authenticate_user(query)
     authorization = handle(response)
     new_thread = Thread(target=listen_for_token)
     prompt_user(authorization)
     local_server = new_thread.run()
     local_server.join()
     log.info('Well done, you have a now token!')
Example #3
0
 def request_new_token():
     localhost = 'http://%s:%s' % settings.LOCALHOST
     query = dict(next=localhost, callback_url=oauth_callback.url)
     response = authenticate_user(query)
     authorization = handle(response)
     new_thread = Thread(target=listen_for_token)
     prompt_user(authorization)
     local_server = new_thread.run()
     local_server.join()
     log.info('Well done, you have a now token!')
Example #4
0
    def _request_authentication(self):
        """Ask Open-Spending if the token is valid.
        """
        query = dict(jwt=self.token)
        response = authenticate_user(params=query)
        authentication = handle(response)

        if not authentication['authenticated']:
            message = 'Token has expired: request a new one'
            log.error(message)
            raise InvalidToken(message)

        name = authentication['profile']['name']
        log.info('Hello %s! You are logged into Open-Spending', name)
        return authentication
Example #5
0
    def _request_authentication(self):
        """Ask Open-Spending if the token is valid.
        """
        query = dict(jwt=self.token)
        response = authenticate_user(params=query)
        authentication = handle(response)

        if not authentication['authenticated']:
            message = 'Token has expired: request a new one'
            log.error(message)
            raise InvalidToken(message)

        name = authentication['profile']['name']
        log.info('Hello %s! You are logged into Open-Spending', name)
        return authentication