[Backport 8.3] Use correct user-agent header by default (#1874)

Co-authored-by: Josh Mock <josh@joshmock.com>
This commit is contained in:
github-actions[bot]
2023-05-05 11:19:42 -05:00
committed by GitHub
parent cac4203919
commit 8a57dc0402
2 changed files with 13 additions and 1 deletions

View File

@ -432,3 +432,12 @@ test('caFingerprint can\'t be configured over http / 2', t => {
)
t.end()
})
test('user agent is in the correct format', t => {
const client = new Client({ node: 'http://localhost:9200' })
const agentRaw = client.transport[symbols.kHeaders]['user-agent'] || ''
const agentSplit = agentRaw.split(/\s+/)
t.equal(agentSplit[0].split('/')[0], 'elasticsearch-js')
t.ok(/^\d+\.\d+\.\d+/.test(agentSplit[0].split('/')[1]))
t.end()
})