-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to extract from response body #99
Comments
Hi, I'm glad you're finding it useful, and thanks for reaching out with your question! The reason you're seeing issues is that templating must be explicitly declared for elements (it is not done automatically, for a couple reasons). I've got a good example of this in the content-test. So, for your case, the final test will look like: - test:
- name: "Logout"
- url: "/user/logout?token=$token"
- method: 'POST'
- headers: {template: {Authorization: "Bearer $token"}} One note: for headers, if you declare them as using a template, all values in the header map will be templated (header names and values), so if you're using $ signs in there, make sure to escape them with two $ signs (i.e. $$escaped). |
@jbouzekri ^^ reply above :-) |
Thanks for your prompt reply and sorry for my late one as I was in a meeting. Your solution works for the header (my use case) but it did not replace the $token in the url (just a test). Any idea why ? |
Yes, it also needs to be templated in the same fashion: I think it's time to add more templating in the examples and in main documentation (as well as in the advanced documentation, since people are using this feature a lot more than I initially thought (probably a good thing!). |
@jbouzekri Side note: you might find the docker containers I created for pyresttest development useful for other python work: https://github.com/svanoort/pyresttest/tree/master/docker I have documentation on how to use them in building and Jenkins workflows for using the docker images in python testing. |
Yes it is working. I am all set to add functionnal testing to an old api in a few minutes thanks to the clear and readable syntax of your YAML file. I will take a look at the additional reading you have provided. |
Hi,
Thanks for your awesome work.
I am trying to test the authentication/logout workflow of an API. When I login, it returns a token that I can use to logout.
This is my test file :
As you can see in the last test, I tried to set $token in both the header and as a GET param. But it is never replaced by the value extracted from the previous tracker.
Please find bellow the body of the response when login :
Thanks in advance
The text was updated successfully, but these errors were encountered: