MCPcopy
hub / github.com/request/request / addTests

Function addTests

tests/test-proxy.js:82–292  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80}
81
82function addTests () {
83 // If the `runTest` function is changed, run the following command and make
84 // sure both of these tests fail:
85 //
86 // TEST_PROXY_HARNESS=y node tests/test-proxy.js
87
88 if (process.env.TEST_PROXY_HARNESS) {
89 runTest('should fail with "proxy response should not be called"', {
90 proxy: s.url
91 }, false)
92
93 runTest('should fail with "proxy response should be called"', {
94 proxy: null
95 }, true)
96 } else {
97 // Run the real tests
98
99 runTest('basic proxy', {
100 proxy: s.url,
101 headers: {
102 'proxy-authorization': 'Token Fooblez'
103 }
104 }, function (t, req, res) {
105 t.equal(req.headers['proxy-authorization'], 'Token Fooblez')
106 })
107
108 runTest('proxy auth without uri auth', {
109 proxy: 'http://user:pass@localhost:' + s.port
110 }, function (t, req, res) {
111 t.equal(req.headers['proxy-authorization'], 'Basic dXNlcjpwYXNz')
112 })
113
114 // http: urls and basic proxy settings
115
116 runTest('HTTP_PROXY environment variable and http: url', {
117 env: { HTTP_PROXY: s.url }
118 }, true)
119
120 runTest('http_proxy environment variable and http: url', {
121 env: { http_proxy: s.url }
122 }, true)
123
124 runTest('HTTPS_PROXY environment variable and http: url', {
125 env: { HTTPS_PROXY: s.url }
126 }, false)
127
128 runTest('https_proxy environment variable and http: url', {
129 env: { https_proxy: s.url }
130 }, false)
131
132 // https: urls and basic proxy settings
133
134 runTest('HTTP_PROXY environment variable and https: url', {
135 env: { HTTP_PROXY: s.url },
136 url: 'https://google.com',
137 tunnel: false,
138 pool: false
139 }, true)

Callers 1

test-proxy.jsFile · 0.70

Calls 1

runTestFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…