SvenskaSpel / har2locust

Convert HTTP Archive (.har file) to a Locust script
Other
149 stars 22 forks source link

How to elegantly handle the jwt token inside the header? #7

Open goodve opened 8 months ago

goodve commented 8 months ago
  with self.rest(
            "GET",
            "/api/xxxxx?systemId=7228a882ce2b4805aef2ba007f452ab2&time=1703906292335",
            headers={
                "Accept": "application/json, text/javascript, */*; q=0.01",
                "Authorization": "Bearer xxxxxxxxxx",
                "Referer": "xxxxx",
                "Sec-Fetch-Dest": "empty",
                "Sec-Fetch-Mode": "cors",
            },

Since every request contains "Authorization": "Bearer xxxxxxxxxxxx", is there a plugin that provides placeholders instead of me replacing them in my production code?

cyberw commented 8 months ago

There’s no plugin for that atm, but you could probably write one yourself (I’ll be happy to accept a PR) this example is a little complex but should get you started: https://github.com/SvenskaSpel/har2locust/blob/main/har2locust/extra_plugins/plugin_example.py