Skip to content

Commit 2849f0e

Browse files
committed
test(evp-proxy): use forwarded discovery header
1 parent 9e65ee9 commit 2849f0e

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

packages/dd-trace/src/evp_proxy/discovery.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const TRAILING_SLASHES = /\/+$/
4949
* @param {object} agentInfo - Agent `/info` response
5050
* @param {object} options - Selection options
5151
* @param {string[]} options.supportedPaths - Supported paths in preference order
52-
* @param {string[]} [options.requiredHeaders] - Headers that the proxy must forward to intake. Do not include
53-
* routing headers that the Agent consumes, such as X-Datadog-EVP-Subdomain.
52+
* @param {string[]} [options.requiredHeaders] - Headers that the proxy must forward unchanged to intake. Each
53+
* header must appear in `evp_proxy_allowed_headers`. Do not include routing headers that the Agent consumes.
5454
* @returns {string|undefined} Selected normalized path
5555
*/
5656
function selectEVPProxyPath (agentInfo, { supportedPaths, requiredHeaders = [] } = {}) {
@@ -103,8 +103,8 @@ function selectEVPProxyPath (agentInfo, { supportedPaths, requiredHeaders = [] }
103103
* @param {URL} url - Configured Agent URL
104104
* @param {object} options - Selection options
105105
* @param {string[]} options.supportedPaths - Supported paths in preference order
106-
* @param {string[]} [options.requiredHeaders] - Headers that the proxy must forward to intake. Do not include
107-
* routing headers that the Agent consumes, such as X-Datadog-EVP-Subdomain.
106+
* @param {string[]} [options.requiredHeaders] - Headers that the proxy must forward unchanged to intake. Each
107+
* header must appear in `evp_proxy_allowed_headers`. Do not include routing headers that the Agent consumes.
108108
* @param {(error: Error|null, route?: {url: URL, basePath: string}) => void} callback - Result callback
109109
* @returns {void}
110110
*/

packages/dd-trace/test/evp_proxy/discovery.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('EVP proxy discovery', () => {
1010
const url = new URL('http://localhost:8126')
1111
const options = {
1212
supportedPaths: ['/evp_proxy/v4', '/evp_proxy/v2'],
13-
requiredHeaders: ['X-Datadog-EVP-Subdomain'],
13+
requiredHeaders: ['Content-Type'],
1414
}
1515

1616
let discoverEVPProxy
@@ -35,7 +35,7 @@ describe('EVP proxy discovery', () => {
3535
it('uses caller preference order and normalizes trailing slashes', () => {
3636
const path = selectEVPProxyPath({
3737
endpoints: ['/evp_proxy/v2/', '/evp_proxy/v4/'],
38-
evp_proxy_allowed_headers: ['x-datadog-evp-subdomain'],
38+
evp_proxy_allowed_headers: ['content-type'],
3939
}, options)
4040

4141
assert.strictEqual(path, '/evp_proxy/v4')
@@ -64,7 +64,7 @@ describe('EVP proxy discovery', () => {
6464
it('rejects a malformed allowed-header field', () => {
6565
const path = selectEVPProxyPath({
6666
endpoints: ['/evp_proxy/v2'],
67-
evp_proxy_allowed_headers: 'X-Datadog-EVP-Subdomain',
67+
evp_proxy_allowed_headers: 'Content-Type',
6868
}, options)
6969

7070
assert.strictEqual(path, undefined)
@@ -73,7 +73,7 @@ describe('EVP proxy discovery', () => {
7373
it('rejects a missing required header', () => {
7474
const path = selectEVPProxyPath({
7575
endpoints: ['/evp_proxy/v2'],
76-
evp_proxy_allowed_headers: ['Content-Type'],
76+
evp_proxy_allowed_headers: ['Accept-Encoding'],
7777
}, options)
7878

7979
assert.strictEqual(path, undefined)
@@ -88,7 +88,7 @@ describe('EVP proxy discovery', () => {
8888
it('fetches information only when discovery is called', (done) => {
8989
fetchAgentInfo.yields(null, {
9090
endpoints: ['/evp_proxy/v2'],
91-
evp_proxy_allowed_headers: ['X-Datadog-EVP-Subdomain'],
91+
evp_proxy_allowed_headers: ['content-type'],
9292
})
9393

9494
sinon.assert.notCalled(fetchAgentInfo)

0 commit comments

Comments
 (0)