{
  "v": 2,
  "name": "secret-envs-persistence-coll",
  "folders": [],
  "requests": [
    {
      "v": "3",
      "auth": {
        "authType": "none",
        "authActive": true
      },
      "body": {
        "body": null,
        "contentType": null
      },
      "name": "test-secret-headers",
      "method": "GET",
      "params": [],
      "requestVariables": [],
      "headers": [
        {
          "key": "Secret-Header-Key",
          "value": "<<secretHeaderValue>>",
          "active": true
        }
      ],
      "endpoint": "<<echoHoppBaseURL>>",
      "testScript": "pw.test(\"Successfully parses secret variable holding the header value\", () => {\n    const secretHeaderValue = pw.env.getResolve(\"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.getResolve(\"secretHeaderValueFromPreReqScript\")).toBe(\"secret-header-value\")\n})",
      "preRequestScript": "pw.env.set(\"secretHeaderValue\", \"secret-header-value\")\n\nconst secretHeaderValueFromPreReqScript = pw.env.getResolve(\"secretHeaderValue\")\npw.env.set(\"secretHeaderValueFromPreReqScript\", secretHeaderValueFromPreReqScript)"
    },
    {
      "v": "3",
      "auth": {
        "authType": "none",
        "authActive": true
      },
      "body": {
        "body": null,
        "contentType": null
      },
      "name": "test-secret-headers-overrides",
      "method": "GET",
      "params": [],
      "requestVariables": [],
      "headers": [
        {
          "key": "Secret-Header-Key",
          "value": "<<secretHeaderValue>>",
          "active": true
        }
      ],
      "endpoint": "<<echoHoppBaseURL>>",
      "testScript": "pw.test(\"Value set at the pre-request script takes precedence\", () => {\n    const secretHeaderValue = pw.env.getResolve(\"secretHeaderValue\")\n    pw.expect(secretHeaderValue).toBe(\"secret-header-value-overriden\")\n    \n    if (secretHeaderValue) {\n      pw.expect(pw.response.body.headers[\"secret-header-key\"]).toBe(secretHeaderValue)\n    }\n\n    pw.expect(pw.env.getResolve(\"secretHeaderValueFromPreReqScript\")).toBe(\"secret-header-value-overriden\")\n})",
      "preRequestScript": "pw.env.set(\"secretHeaderValue\", \"secret-header-value-overriden\")\n\nconst secretHeaderValueFromPreReqScript = pw.env.getResolve(\"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": [],
      "requestVariables": [],
      "headers": [],
      "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 secretBodyValue = pw.env.get(\"secretBodyValue\")\n\nif (!secretBodyValue) { \n  pw.env.set(\"secretBodyValue\", \"secret-body-value\")\n}\n\nconst 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
        }
      ],
      "requestVariables": [],
      "headers": [],
      "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 secretQueryParamValue = pw.env.get(\"secretQueryParamValue\")\n\nif (!secretQueryParamValue) {\n  pw.env.set(\"secretQueryParamValue\", \"secret-query-param-value\")\n}\n\nconst 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": [],
      "requestVariables": [],
      "headers": [],
      "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": "let secretBasicAuthUsername = pw.env.get(\"secretBasicAuthUsername\")\n\nlet secretBasicAuthPassword = pw.env.get(\"secretBasicAuthPassword\")\n\nif (!secretBasicAuthUsername) {\n  pw.env.set(\"secretBasicAuthUsername\", \"test-user\")\n}\n\nif (!secretBasicAuthPassword) {\n  pw.env.set(\"secretBasicAuthPassword\", \"test-pass\")\n}"
    },
    {
      "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": [],
      "requestVariables": [],
      "headers": [],
      "endpoint": "<<httpbinBaseURL>>/bearer",
      "testScript": "pw.test(\"Successfully parses secret variable holding the bearer token\", () => {\n    const secretBearerToken = pw.env.resolve(\"<<secretBearerToken>>\")\n  const preReqSecretBearerToken = pw.env.resolve(\"<<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": "let secretBearerToken = pw.env.resolve(\"<<secretBearerToken>>\")\n\nif (!secretBearerToken) {\n  pw.env.set(\"secretBearerToken\", \"test-token\")\n  secretBearerToken = pw.env.resolve(\"<<secretBearerToken>>\")\n}\n\npw.env.set(\"preReqSecretBearerToken\", secretBearerToken)"
    }
  ],
  "auth": {
    "authType": "inherit",
    "authActive": false
  },
  "headers": []
}