Forum Discussion

mmoser18's avatar
mmoser18
Frequent Contributor
8 years ago
Solved

Adding HTTP-headers to ALL test-cases of a test-suite (or several test-suites)?

We had to change the authentication mechanism for several web-applications that we developed. That means that for all our test-cases I now need to include a set of additional HTTP-headers to each and every call. Since our Test-suite covers a couple of hundreds of test cases adding these into each and every request seems like quite a monstrous task!

And there isn't even some copy-paste mechanism, i.e. I would have to clicke-di-click myself through the UI for a thousand times? NO way!

 

Is there a way to add common HTTP-headers (e.g. something like:

     "Authorization: ${#Project#Access_Token}"

to ALL requests (or "Steps") of a test suite?

 

Ideally one wouldn't even have to add that to each individual request but there would be a common place to define those in single place and these headers would then be injected into all requests (visible maybe only in the RAW view).

 

Second-best solution would be to at least script the addition (and update/deletion) of those headers so one doesn't have to do that all in the GUI.

 

Are there any such helpers available?

 

14 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Access_token is something pre-defined fixed value or it should be fetched using a service call? Then add that to all the further service calls?
    • mmoser18's avatar
      mmoser18
      Frequent Contributor

      Access_token is a project-level custom property. It is always fetched and updated in a test-case at the very begin of my test-suites and is then valid and used during the entire execution of that test suite.

      • nmrao's avatar
        nmrao
        Champion Level 3

        So, as you already mentioned, you need to get it and save it as Project level custom property say ACCESS_TOKEN.

        Then, In your case there are two options.

        Either you need to add the predefined Header property using property expansion to all the required steps say ${#Project#ACCESS_TOKEN}. So, yes, the header needs to be to added to all existing test requests and for the new test requests as well which you will be adding in the future.

        Or add ACCESS_TOKEN as header for each out going request programatically. Not only that, but also requires a feature called Events (which is part of pro edition) or an extension for Open source edition mentioned here.