title: Karate - Testing different environments - with or without API Gateway
body: <p>I am using two different environments to test - Dev env is without authentication (so we don't have to pass headers) and QA env is hosted on API Gateway. I was trying to design my tests such that the tests should be configurable to run in either of the environments. </p>
  
  <p>Here is what I have done:</p>
  
  <ol>
  <li><p>Defining Client Secret and Client Id in the Karate-config.js. Setting these two variables as null for dev.</p></li>
  <li><p>Calling a user-login scenario file to generate the authorization token (takes url, client_id and client_secret from the scenario file) and return token to the scenario file.</p>
  
  <p>Feature: Test using Karate</p>
  
  <pre><code>  Background:
      * configure ssl = true
      * url baseUrl
      * def token = call read('classpath:endpoints/user-login.feature')
      * def headerData = {Authorization: #(token.nextGen),Accept: 'application/json;v=1'}
      * headers headerData
  
    Scenario: Verify that status for retreiving endpoint
      Given path 'abc'
      When method get
      Then status 200
  </code></pre>
  
  <p>Feature: Get Token</p>
  
  <pre><code>Scenario: Get authorization header
    Given url 'https://api-it.cloud.xyz.com/oauth2/token?client_id=12121&amp;client_secret=12121&amp;grant_type=client_credentials'
    When method get
    Then status 200
    And def tokenType = response.token_type
    And def accessToken = response.access_token
    * def nextGen = tokenType + ' '+ accessToken
    * print nextGen
  </code></pre></li>
  </ol>
  
  <p>Any pointers on how to run tests with and without authentication on the same project will be appreciated. </p>