Skip to content

Instantly share code, notes, and snippets.

@narayanpai1
Last active April 12, 2021 21:11
Show Gist options
  • Save narayanpai1/35b8a21280e6867eca95f4007097f458 to your computer and use it in GitHub Desktop.
Save narayanpai1/35b8a21280e6867eca95f4007097f458 to your computer and use it in GitHub Desktop.
Final Code Submission of my GSoC project

Newman Login Feature: Final Code Submission

Organization: Postman

Mentor: Udit Vasu

Overview

Newman is a command-line Collection Runner for Postman. It allows us to run and test a collection of APIs directly from the command line. It is used with continuous integration servers and build systems to test and monitor different APIs.

Before the start of this project, there was no way for users to run collections stored in Postman-Cloud directly from the CLI. The only procedure to do this was to manually copy the collection from Postman into a local file and feed that file as the input.

My project bridges this gap between Postman and Newman by enabling direct access to Postman-Cloud. This is done by providing two commands: login and logout to store and delete authentication-related data and by using these data in the run command.

In addition to this, the project integrates the feature of configuration files and environment variables to the app that can be used to change the app settings.

Work done during the period

The following features were added along with the corresponding tests and documentation to Newman under this project. These features are merged with the branch under development and will be released shortly in the upcoming version of Newman.

  • Configuration files (PR 2395, 2433)

    These files act as a way to store default options related to each command in the form of JSON data.

  • Newman login command (PR 2409, 2397, 2443, 2486)

    This command is used by the user to store the Postman API key to access Postman-cloud resources. To securely store this API Key, the command also provides the facility of a passkey. If the API Key is stored with the use of passkey, further accesses to the API Key will require the user to provide this passkey.

    Following this procedure, the user can directly use Postman-Cloud resources from its ID as follows:

    $ newman run $collection_id

    When there is already an API Key stored, it allows us to store the API Key as an alias. This API Key can then be referenced from other commands through this alias.

  • Newman logout command (PR 2401)

    This command allows the user to delete a stored API Key. It provides the user with the list of aliases to choose from if there are more than one API Keys stored.

  • postman-api-key-alias option for run command (PR 2416)

    This option allows the user to specify the API key to be used during the run command as follows.

  • sync-environment option for the run command (PR 2447 ,2474)

    This option allows the user to update the environment in Postman-Cloud with the resultant environment.

  • Environment variables (PR 2416)

    This feature lets the user specify session related settings like Postman API Key to be used or the Alias of the Postman API Key to be used.

The documentation for all these features was added in PR 2495.

In addition to this, I also worked on postman-echo-nock. This module is used to mock different API endpoints in Postman-Echo. It is still under development. Once developed completely, this module can be used to improve the speed of tests in different Postman modules as Postman-Echo APIs are frequently used to test out different features. My contribution to this module includes mocking some endpoints, fixing some bugs and adding lint and unit tests to the code.

List of commits I added to this repository: 48a149d, cc461ea, dc7d790, c4e2b0b, 2b77bcc, 4975070, 34bb400, 07de6fe, 0553a20, 662000e, 33ec679.

Future Scope

  • The API for importing run history is currently under development. Once that is available, Newman runs can be synced with the Postman history using the login feature. This will allow users to view previous Newman runs, monitor them and also share it within the Postman Workspace.

  • An interactive run command can also be developed to let users select Postman Collection to be run and/or Postman Environment to be used. Since the groundwork for dealing with Postman APIs is already laid out, this feature can be easily built onto that.

Acknowledgments

I would like to thank my mentor for providing me with constant support throughout the project. The weekly sync-ups really helped me in sorting out any difficulties faced, improving my coding practice and planning next steps. I look forward to contributing and learning more from the organization.

@gauravdas014
Copy link

Is the API for importing run history available now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment