Skip to content

How to handle authentication flows? #54

Answered by thim81
thim81 asked this question in Q&A
Discussion options

You must be logged in to vote

The pre-request scripts are supported in postman-to-k6, but the "pm.sendRequest" function would be more difficult, since this concept does not really exist in the K6 concepts.

As a work-around I do it like so:

  1. Create a seperate NodeJs script or bash script
  2. In the NodeJS script, it generates a Postman Environment file as result, with the necessary tokens
  3. Convert Postman to K6 with the generated Postman environment file
  4. Run generated K6 script

A simplified example of a packages.json contains the steps mentioned:

{
  "name": "api-k6",
  "version": "1.0.0",
  "description": "API - K6 testing suite",
  "scripts": {
    "generate:k6:api:oauth:token": "node api.pipeline.env.js",
    "generate:…

Replies: 1 comment

Comment options

thim81
Mar 28, 2022
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by thim81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant