pyresttest icon indicating copy to clipboard operation
pyresttest copied to clipboard

Authentification doesn't work if auth_username/auth_password are empty strings

Open sebastiendarocha opened this issue 6 years ago • 0 comments

- test:
  - name: "Anonymous access to open data"
  - url: "/authenticated_realm"
  - auth_username: ""
  - auth_password: ""

This is what happens when you click "OK" on your navigator authentication popup for basic auth without giving credentials.

Pyresttest is meant to send an authorization header with "Basic Og==" (it's ":" base64 encoded). But it doesn't send any authorization header.

You can test it (getting the header) by visiting http://httpstat.us/401 with your navigator and seeing the headers of the requests when you click OK.

I've temporarily fixed this by replacing this line: https://github.com/svanoort/pyresttest/blob/d6985d4a90468025ab4f7ad5d002ec009eef9897/pyresttest/tests.py#L321 by:

        if self.auth_username  is not None and self.auth_password is not None:

sebastiendarocha avatar Aug 11 '18 14:08 sebastiendarocha