Skip to content
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

Can not use atob function because of different built-in libraries #86

Open
fourcolor opened this issue Sep 29, 2022 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@fourcolor
Copy link
Contributor

I use many atob function in my postman collection; indeed, it not work in k6 script. However I found that I can easily fix it by using the k6/encoding module.

import { b64decode } from "k6/encoding";
const atob = (str) => {
  return b64decode(str, "rawstd", "s");
};

I want to ask is there any plan to support this kind of problem?
e.g. crypto-js -> k6/crypto

@thim81
Copy link
Collaborator

thim81 commented Nov 12, 2022

hi @fourcolor,

Do I understand correctly, that you want to add the atob() function when it is detected in the Postman collection?

Do you have an example of a Postman collection where you used the atob function?

@thim81 thim81 added the enhancement New feature or request label Nov 12, 2022
@fourcolor
Copy link
Contributor Author

  1. Yes
  2. Here is the example
pm.test("Living JWT token", function () {
    let jsonData = pm.response.json();
    let Playload = JSON.parse(atob(jsonData.JWT.split(".")[1]));
    let iat = new Number(Playload.iat);
    let exp = new Number(Playload.exp);
    let dateToSecond = Math.ceil(Date.now()/1000);
    //check JWT token was issued in the past and expire in the future which means it is an effect token for now
    pm.expect(dateToSecond).to.be.within(iat,exp);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants