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

Support Alternate Environments Format #67

Closed
pfunk1978 opened this issue Aug 3, 2022 · 6 comments · Fixed by #76
Closed

Support Alternate Environments Format #67

pfunk1978 opened this issue Aug 3, 2022 · 6 comments · Fixed by #76
Assignees
Labels
enhancement New feature or request

Comments

@pfunk1978
Copy link

As a CICD user I wish to pull my environments file from the following url and use it as the environments variables for conversion
https://api.getpostman.com/environment/{UUID}

Issue:

Environments file retrieved from the postman api differs from the environments file from a postman export process. The file retrieved from the API call has the following structure

{"environment":{"id":"redacted","name":"10.0.5.49-6.3.2.x","owner":"18142191","createdAt":"2022-08-03T16:16:01.000Z","updatedAt":"2022-08-03T16:43:57.000Z","values":[{"key":"host","value":"10.0.5.49","enabled":true},{"key":"port","value":"8081","enabled":true},{"key":"v7","value":"v7","enabled":true},{"key":"v6","value":"v6","enabled":true},{"key":"jwtIssuer","value":"redacted","enabled":true},{"key":"hmacKey","value":"redacted","enabled":true},{"key":"testUser","value":"testUser","enabled":true}],"isPublic":false}}

While the file from a regular export process has the following structure

{"id":"redacted","name":"10.0.5.49-6.3.2.x","values":[{"key":"host","value":"10.0.5.49","enabled":true},{"key":"port","value":"8081","enabled":true},{"key":"v7","value":"v7","enabled":true},{"key":"v6","value":"v6","enabled":true},{"key":"jwtIssuer","value":"redacted","enabled":true},{"key":"hmacKey","value":"redacted","enabled":true},{"key":"testUser","value":"testUser","enabled":true}]}

Currently I'm getting a environment.values is not iterable error

@thim81
Copy link
Collaborator

thim81 commented Aug 4, 2022

Hi @pfunk1978

The feature request seems like a very logical flow.

A couple of questions:

  • would you have the CI/CD download the file and next like to pass along the env file using a new parameter?
  • making the cli download the file via the api would also be a valuable extension, although that would require more work since it would introduce also api credentials and implementation of the postman api. Would this be what you would expect? Or would be starting with the 1st request be already a good step forward?

@pfunk1978
Copy link
Author

Hola @thim81,

I should also point out that the collections endpoint for postman API also returns an unusable json struct, which I didn't realize when I first wrote the ticket.

Currently I'm running curl as such and piping through jq to get the proper structure:

                sh "curl -s ${headers} https://api.getpostman.com/collections/${params.testingCollectionId} | jq '.collection' > tests/col.json"
                sh "curl -s ${headers} https://api.getpostman.com/environments/${params.environmentId} | jq '.environment' > tests/env.json" 

I have admin over my CI so I can install jq, but not everyone has that luxury. Maybe it would be better to be able to parse the above structs natively. IMHO adding in postman connectivity seems like bloat to me.

@thim81
Copy link
Collaborator

thim81 commented Aug 4, 2022

Hola @pfunk1978

Thanks for coming back with your input and based on it, it seems that feature can be scoped to properly parsing the Postman env file in a native manner.

As soon as I have some time, I'll review the API response to see how we can transform the Env response or support it natively.

Adding Postman API does not bring much added value, since the security and targeting which env to download would only make it more complicated and an additional hurdle.

@thim81
Copy link
Collaborator

thim81 commented Aug 10, 2022

Hola @pfunk1978 The PR is in the making.

I have made simple detection that will transform API environment & collection structure in a regular structure, by simply removing the wrapping element.

@thim81
Copy link
Collaborator

thim81 commented Aug 10, 2022

The PR has landed and the support for Postman API collection & environment files will be part of the upcoming postman-to-k6 release.

@thim81
Copy link
Collaborator

thim81 commented Aug 11, 2022

Closing the issue, since the latest postman-to-k6 version (1.8.5) contains this enhancement.

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
2 participants