Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTTP headers and custom data added in Custom Asserters not cleaned up

See original GitHub issue

Issue Description

Describe the bug I use Custom Asserter to add a header/custom data to an HTTP Request for some tests. I use AssertConvoBegin to attach it and AssertConvoEnd to remove it after the test. The problem is that if a test fails then AssertConvoEnd method isn’t triggered and the header/data isn’t removed - it is persistent in next convo tests and it makes them fail, because the handler method depends on the existence of this particular header/data.

To Reproduce It’s easier to show it. image

Expected behavior I expect the header/data to be removed even if the test fails. Maybe you have a different idea how to attach custom headers/data to some tests? Only to some, I don’t want them in all tests (I set the header Authorization in requestHook.js), but this is the only thing I want in all tests!

Botium Flavour:

  • Botium Box not used
  • Botium CLI not used
  • Botium Bindings 2.0.16

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

piotrjakcommented, Dec 19, 2019

everything is solved. thanks for helping. just one additional thing I changed. using container.pluginInstance.view.context.location instead of container.pluginInstance.view.location so I have all the additional fields added on the context object. a lil bit cleaner imo


module.exports = ({ requestOptions, context }) => {
  // set the authorization token for every request
  requestOptions.headers.Authorization = `Bearer ${process.env.TOKEN}`;

  if (context.location) {
    requestOptions.body.location = context.location;
piotrjakcommented, Dec 18, 2019

ah, ok. thanks for the snippet. I had LOGIC_HOOKS as a field under $.botium and not $.botium.capabilities. it works! but now I would have to convert SIMPLEREST_BODY_TEMPLATE and SIMPLEREST_HEADERS_TEMPLATE values to strings instead of objects (objects look cleaner in botium.json config) and use moustache templating.

is it possible to put the { lat, long } object somewhere so I can add the location field in requestHook? yes, there is. anything you add on container.pluginInstance.view object is added to an argument that is passed to requestHook function


Read more comments on GitHub >

github_iconTop Results From Across the Web

Back to Basics: Custom HTTP Response Header Manipulation ...
NET Core doesn't have an obvious, built-in way to add headers to every request. In this back to basics post I describe what...
Read more >
Custom HTTP Headers - KeyCDN Support
Custom HTTP headers are extremely useful for providing additional information. Learn more about using, naming, and implementing them.
Read more >
Default Headers and Cookies App Gateway Adds to the Request
By Default App Gateway adds header variables and cookies to any request forwarded to a protected enterprise applications. The following is a list...
Read more >
Server removes custom HTTP header fields - Stack Overflow
Actually, there is a pretty easy fix. The fault lays with fastcgi. You can just provide an .htaccess file with a rewrite rule...
Read more >
Custom Headers <customHeaders> | Microsoft Learn
IIS 8.5, The <customHeaders> element was not modified in IIS 8.5. ... In the Add Custom HTTP Response Header dialog box, set the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found