microsoft / dev-proxy

Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path.
https://aka.ms/devproxy
MIT License
471 stars 56 forks source link

[BUG]: Requests made to ignored URLs are not shown as passed through #848

Closed garrytrinder closed 1 month ago

garrytrinder commented 1 month ago

Description

You can ignore requests to a specific endpoint by using ! at the beginning of a URL in the urlsToWatch array, however requests made to the ignored URL as shown as passed through in the proxy output.

Expected behaviour

req   ╭ GET https://jsonplaceholder.typicode.com/posts/2
api   ╰ Passed through

Actual behaviour

No output is shown.

Steps to reproduce

Follow the steps in the Update URLs to watch section of the Get started with Dev Proxy tutorial.

Dev Proxy Version

0.19.1

Operating system (environment)

Windows

Shell

Windows PowerShell

Configuration file

{
  "$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v0.19.1/rc.schema.json",
  "plugins": [
    {
      "name": "RetryAfterPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll"
    },
    {
      "name": "GenericRandomErrorPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
      "configSection": "genericRandomErrorPlugin"
    }
  ],
  "urlsToWatch": [
    "!https://jsonplaceholder.typicode.com/posts/2",
    "https://jsonplaceholder.typicode.com/*"
  ],
  "genericRandomErrorPlugin": {
    "errorsFile": "devproxy-errors.json"
  },
  "rate": 50,
  "logLevel": "information",
  "newVersionNotification": "stable"
}

Additional Info

No response

garrytrinder commented 1 month ago

Looks like this is expected behaviour.

https://github.com/microsoft/dev-proxy/blob/70bb4f692d3ad090c6e44bb640f81bc8aa88dd86/dev-proxy-abstractions/PluginEvents.cs#L78-L82

The HasRequestUrlMatch method returns false for a URL that contains ! so the request is not passed through proxy.

We should update our tutorial to reflect this behaviour.

waldekmastykarz commented 1 month ago

Looking at the config file you shared in the issue, there doesn't seem to be any ignored URL. Copy/paste issue?

garrytrinder commented 1 month ago

Looking at the config file you shared in the issue, there doesn't seem to be any ignored URL. Copy/paste issue?

Yes, updated 👍

garrytrinder commented 1 month ago

PR raised to update tutorial to reflect behaviour https://github.com/MicrosoftDocs/microsoft-cloud-pr/pull/335