function assertConfigReq (t, req) { const url = new URL(req.url, 'relative:///') t.equal(req.method, 'GET', 'should make a GET request') t.equal(url.pathname, '/config/v1/agents', 'should send request to /config/v1/agents') t.equal(url.search, '?service.name=my-service-name&service.environment=development', 'should encode query in query params') t.equal(req.headers.authorization, 'Bearer secret', 'should add secret token') t.equal(req.headers['user-agent'], `my-user-agent ${pkg.name}/${pkg.version} ${process.release.name}/${process.versions.node}`, 'should add proper User-Agent') }
it('append params to the existing querystring for a specified domain', function(done) { request(buildApp({ proxyAllDomains: true, appendParamToQueryString: { "example.com": [{ "regexPattern": ".", "params": { "foo": "bar" } }] } }))[methodName]('/example.com?already=here') .expect(200) .expect(function() { const hitUrl = new URL(fakeRequest.calls.argsFor(0)[0].url) expect(hitUrl.search).toBe('?already=here&foo=bar'); }) .end(assert(done)); });
hostname: _url.hostname, port: _url.port, path: `${_url.pathname}${_url.search}`, method: 'POST', headers: {
hostname: _url.hostname, port: _url.port, path: `${_url.pathname}${_url.search}`, method: 'GET', headers: {
hostname: _url.hostname, port: _url.port, path: `${_url.pathname}${_url.search}`, method: 'GET', headers: {
it('append multiple params to the querystring for a specified domain', function(done) { request(buildApp({ proxyAllDomains: true, appendParamToQueryString: { "example.com": [{ "regexPattern": ".", "params": { "foo": "bar", "another": "val" } }] } }))[methodName]('/example.com') .expect(200) .expect(function() { const hitUrl = new URL(fakeRequest.calls.argsFor(0)[0].url) expect(hitUrl.search).toBe('?foo=bar&another=val'); }) .end(assert(done)); });