Postman

Style Guide

Workspace Organization

As a general rule of thumb, we have a workspace in postman for every git repository.

Organizing workspaces in this way...

Environment Variables

Camel Casing

We use camel casing for naming environment variables. For example, baseUrl rather than BaseUrl, or base-url.

Name Standardization

Some environment variables will likely be used across several different workspaces and collections. For this reason, we want to have consistent names for certain variables. For example, for the domain of a given API we could name a variable several different things that are all great names like domain, origin, or baseUrl, but having a standardized name we use across all collections will help eliminate the need to figure out what the name is used in a particular collection or environment.

 

Running Tests in ADO Release Pipeline

Don't put credentials or keys for any Revver user in postman environment variables that have access to real customer data, or any other sensitive data in case these API keys were ever compromised.

You can run a Postman collection with a specific environment in an ADO release pipeline stage. The following steps can be taken to set this up.

  1. Click on the ... (three dots) icon next to the collection you want to run in the pipeline, which is outlined in BLUE in image 1.
  2. Select Run Collection option in the dropdown that appears, which is outlined in YELLOW in Image 1.
  3. In the right panel, in the Choose how to run your collection section, select Automate runs via CLI, which is outlined in RED in Image 1.
  4. In the bottom of the right panel, click the Configure command link, which is outlined in GREEN in Image 1.
  5. You will be taken to a new page.
  6. In the Choos the collections you want to run section, make sure the correct Collection and Environment are selected. This is outlined in ORANGE in image 2.
    1. You can select multiple collection / environment pairs if you wish
  7. In CI/CD configuration section, make sure Azure Pipelines and Windows is selected. This is outlined in PURPLE in image 2.
  8. You will need to generate a new API Key if you don't already have one setup. You can do this by clicking the Generate API Key button, outlined in PINK in image 2.
  9. In the azure pipeline stage that you wish to run the Postman tests in you will need to Powershell tasks. The first task will install the Postman CLI on the build agent, and the second task will authenticate with your API key and run the collection. On each task select the Inline type, and copy the scripts (highlighted in BROWN in image 2) into the script section of the task.
    1. In the second script you will need to replace $(POSTMAN_API_KEY) with your actual postman API key. 
Image 1

image.png

Image 2
image.pngImage 3

image.png

Environment Variables

after initial review the only consistent variables across the existing environments seem to be: 

depending on how auth happens it might be smart to also have as variables as well so that you can handle auth: