vendredi 7 octobre 2016

Flask test doesn't populate request.authorization when username and password are URL encoded

I'm trying to use the following test:

def post_webhook(self, payload, **kwargs):
    webhook_username = 'test'
    webhook_password = 'test'

    webhook_url = 'http://{}:{}@localhost:8000/webhook_receive'
    webhook_receive = self.app.post(
        webhook_url.format(webhook_username, webhook_password),
        referrer='http://localhost:8000',
        json=payload)
    return webhook_receive.status_code

However the main issue is request.authorization is None. Though if I launch the server and use curl -X POST <webhook_url> or requests.post(<webhook_url>), then request.authorization is properly populated.

Trying to figure out the main issue of how to fix this problem.

Aucun commentaire:

Enregistrer un commentaire