{
  "v": 2,
  "name": "secret-envs-coll",
  "folders": [],
  "requests": [
    {
      "v": "3",
      "auth": {
        "authType": "none",
        "authActive": true
      },
      "body": {
        "body": null,
        "contentType": null
      },
      "name": "test-secret-headers",
      "method": "GET",
      "params": [],
      "headers": [
        {
          "key": "Secret-Header-Key",
          "value": "<<secretHeaderValue>>",
          "active": true
        }
      ],
      "requestVariables": [],
      "endpoint": "<<echoHoppBaseURL>>/headers",
      "testScript": "pw.test(\"Successfully parses secret variable holding the header value\", () => {\n    const secretHeaderValue = pw.env.get(\"secretHeaderValue\")\n    pw.expect(secretHeaderValue).toBe(\"secret-header-value\")\n    \n    if (secretHeaderValue) {\n      pw.expect(pw.response.body.headers[\"secret-header-key\"]).toBe(secretHeaderValue)\n    }\n\n    pw.expect(pw.env.get(\"secretHeaderValueFromPreReqScript\")).toBe(\"secret-header-value\")\n})",
      "preRequestScript": "const secretHeaderValueFromPreReqScript = pw.env.get(\"secretHeaderValue\")\npw.env.set(\"secretHeaderValueFromPreReqScript\", secretHeaderValueFromPreReqScript)"
    },
    {
      "v": "3",
      "auth": {
        "authType": "none",
        "authActive": true
      },
      "body": {
        "body": "{\n  \"secretBodyKey\": \"<<secretBodyValue>>\"\n}",
        "contentType": "application/json"
      },
      "name": "test-secret-body",
      "method": "POST",
      "params": [],
      "headers": [],
      "requestVariables": [],
      "endpoint": "<<echoHoppBaseURL>>/post",
      "testScript": "pw.test(\"Successfully parses secret variable holding the request body value\", () => {\n    const secretBodyValue = pw.env.get(\"secretBodyValue\")\n    pw.expect(secretBodyValue).toBe(\"secret-body-value\")\n  \n    if (secretBodyValue) {\n      pw.expect(JSON.parse(pw.response.body.data).secretBodyKey).toBe(secretBodyValue)\n    }\n\n    pw.expect(pw.env.get(\"secretBodyValueFromPreReqScript\")).toBe(\"secret-body-value\")\n})",
      "preRequestScript": "const secretBodyValueFromPreReqScript = pw.env.get(\"secretBodyValue\")\npw.env.set(\"secretBodyValueFromPreReqScript\", secretBodyValueFromPreReqScript)"
    },
    {
      "v": "3",
      "auth": {
        "authType": "none",
        "authActive": true
      },
      "body": {
        "body": null,
        "contentType": null
      },
      "name": "test-secret-query-params",
      "method": "GET",
      "params": [
        {
          "key": "secretQueryParamKey",
          "value": "<<secretQueryParamValue>>",
          "active": true
        }
      ],
      "headers": [],
      "requestVariables": [],
      "endpoint": "<<echoHoppBaseURL>>",
      "testScript": "pw.test(\"Successfully parses secret variable holding the query param value\", () => {\n    const secretQueryParamValue = pw.env.get(\"secretQueryParamValue\")\n    pw.expect(secretQueryParamValue).toBe(\"secret-query-param-value\")\n    \n    if (secretQueryParamValue) {\n      pw.expect(pw.response.body.args.secretQueryParamKey).toBe(secretQueryParamValue)\n    }\n\n    pw.expect(pw.env.get(\"secretQueryParamValueFromPreReqScript\")).toBe(\"secret-query-param-value\")\n})",
      "preRequestScript": "const secretQueryParamValueFromPreReqScript = pw.env.get(\"secretQueryParamValue\")\npw.env.set(\"secretQueryParamValueFromPreReqScript\", secretQueryParamValueFromPreReqScript)"
    },
    {
      "v": "3",
      "auth": {
        "authType": "basic",
        "password": "<<secretBasicAuthPassword>>",
        "username": "<<secretBasicAuthUsername>>",
        "authActive": true
      },
      "body": {
        "body": null,
        "contentType": null
      },
      "name": "test-secret-basic-auth",
      "method": "GET",
      "params": [],
      "headers": [],
      "requestVariables": [],
      "endpoint": "<<httpbinBaseURL>>/basic-auth/<<secretBasicAuthUsername>>/<<secretBasicAuthPassword>>",
      "testScript": "pw.test(\"Successfully parses secret variables holding basic auth credentials\", () => {\n\tconst secretBasicAuthUsername = pw.env.get(\"secretBasicAuthUsername\")\n  \tconst secretBasicAuthPassword = pw.env.get(\"secretBasicAuthPassword\")\n\n    pw.expect(secretBasicAuthUsername).toBe(\"test-user\")\n    pw.expect(secretBasicAuthPassword).toBe(\"test-pass\")\n\n    // The endpoint at times results in a `502` bad gateway\n    if (pw.response.status !== 200) {\n      return\n    }\n\n    if (secretBasicAuthUsername && secretBasicAuthPassword) {\n      const { authenticated, user } = pw.response.body\n      pw.expect(authenticated).toBe(true)\n      pw.expect(user).toBe(secretBasicAuthUsername)\n    }\n});",
      "preRequestScript": ""
    },
    {
      "v": "3",
      "auth": {
        "token": "<<secretBearerToken>>",
        "authType": "bearer",
        "password": "testpassword",
        "username": "testuser",
        "authActive": true
      },
      "body": {
        "body": null,
        "contentType": null
      },
      "name": "test-secret-bearer-auth",
      "method": "GET",
      "params": [],
      "headers": [],
      "requestVariables": [],
      "endpoint": "<<httpbinBaseURL>>/bearer",
      "testScript": "pw.test(\"Successfully parses secret variable holding the bearer token\", () => {\n    const secretBearerToken = pw.env.get(\"secretBearerToken\")\n  const preReqSecretBearerToken = pw.env.get(\"preReqSecretBearerToken\")\n\n    pw.expect(secretBearerToken).toBe(\"test-token\")\n\n    // Safeguard to prevent test failures due to the endpoint\n    if (pw.response.status !== 200) {\n      return\n    }\n\n    if (secretBearerToken) { \n      pw.expect(pw.response.body.token).toBe(secretBearerToken)\n      pw.expect(preReqSecretBearerToken).toBe(\"test-token\")\n    }\n});",
      "preRequestScript": "const secretBearerToken = pw.env.get(\"secretBearerToken\")\npw.env.set(\"preReqSecretBearerToken\", secretBearerToken)"
    },
    {
      "v": "3",
      "auth": {
        "authType": "none",
        "authActive": true
      },
      "body": {
        "body": null,
        "contentType": null
      },
      "name": "test-secret-fallback",
      "method": "GET",
      "params": [],
      "headers": [],
      "requestVariables": [],
      "endpoint": "<<echoHoppBaseURL>>",
      "testScript": "pw.test(\"Returns an empty string if the value for a secret environment variable is not found in the system environment\", () => {\n  pw.expect(pw.env.get(\"nonExistentValueInSystemEnv\")).toBe(\"\")\n})",
      "preRequestScript": ""
    }
  ],
  "auth": {
    "authType": "inherit",
    "authActive": false
  },
  "headers": []
}