pyresttest
pyresttest copied to clipboard
Enviroment variables for auth_username and auth_password
howdy, I've been combing the docs and code, is there a way to use environment variables for basic auth creds? I have something like this. Am I missing something?
- config:
- generators:
- 'username': {type: 'env_variable', variable_name: 'BASIC_USER_ID'}
- 'password': {type: 'env_variable', variable_name: 'BASIC_PASSWORD'}
...
- test:
- generator_binds: {username: username, password: password}
- auth_username: $username
- auth_password: $password
...
thank you!
I got the following to work
---
- config:
- testset: "Admin app tests"
- generators:
- 'apikey': {type: 'env_string', 'string': "$APIKEY"}
- test:
- name: "Fail without authentication"
- url: "/admin/users/list"
- expected_status: [400]
- test:
- generator_binds: {apikey: apikey}
- name: "Pass with authentication"
- url: "/admin/users/list"
- headers: {template: {"Authorization": "Bearer $apikey"}}
- expected_status: [200]
I think it's because of this line in the documentation:
Currently, templating is only supported for the request body, URL, and headers. There are technical challenges adding it everywhere, it's coming as part of a rewrite of framework internals.
Any update on if this is planned to change at least for authentication values any time soon?