FlowFuse / nr-project-nodes

A set of Node-RED nodes for inter-project communication within the FlowFuse platform
Apache License 2.0
5 stars 0 forks source link

Proxy support #81

Closed Steve-Mcl closed 3 months ago

Steve-Mcl commented 3 months ago

closes #80

Description

tests added

utils
    getWSProxyAgent
      ✔ should return null when there are no env vars set
      ✔ should not proxy any requests if they are excluded by no_local
      ✔ should return a HttpProxyAgent when http_proxy is set and the URL is ws://
      ✔ should return a HttpsProxyAgent when https_proxy is set and the URL is wss://
      ✔ should set http proxy options
      ✔ should set https proxy options
    getHTTPProxyAgent
      ✔ should return an agent object without any http or https proxy when env vars are not set
      ✔ should not proxy any requests if they are excluded by no_local
      ✔ should return an agent object with http property when http_proxy is set and no_proxy is not in scope
      ✔ should return an agent object with http property when http_proxy is set
      ✔ should return an agent object with https property when https_proxy is set
      ✔ should set http proxy options
      ✔ should set https proxy options

  project-link node
    proxy
      got
        ✔ should not add proxy to GOT instance if env vars are not set
        ✔ should not add proxy to GOT instance if no_proxy is configured to include forge domain
        ✔ should not add proxy to GOT instance for http request if http_proxy is unset
        ✔ should not add proxy to GOT instance for https request if https_proxy is unset
        ✔ should add http proxy to GOT instance if env vars are set
        ✔ should add https proxy to GOT instance if env vars are set
      MQTT
        ✔ should not add proxy to MQTT if env vars are not set
        ✔ should not add proxy to MQTT if no_proxy includes target domain
        ✔ should add http proxy to MQTT if env vars are set
        ✔ should add https proxy to MQTT if env vars are set

Related Issue(s)

80

https://github.com/FlowFuse/device-agent/issues/268

Checklist

Labels

Steve-Mcl commented 3 months ago

Ben spoke up about possible environments where setting a proxy may be necessary for access to external resources but not the forge backend (and vice versa)

We discussed the implementation should be aware of the no_proxy env var or perhaps use separate env vars (e.g. ff_device_http_proxy).

Supporting no_proxy was determined to be the most obvious first choice since it does not need describing or documenting due to being a well known "thing".

Switching PR to draft while I evaluate the options.

Steve-Mcl commented 3 months ago

@hardillb this is now ready for local testing.

NOTE: I am leaving this in draft until #82 is resolved (Piotra is looking into that)

Steve-Mcl commented 3 months ago

@hardillb #82 now merged and I have pulled in main.

All tests are running and passing.

Switched out of draft.

Special thanks to @ppawlowski