This is an automated email from the ASF dual-hosted git repository.
tysonnorris pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-client-js.git
The following commit(s) were added to refs/heads/master by this push:
new 5342fed Propagate __OW_TRANSACTION_ID if present (#208)
5342fed is described below
commit 5342feda8501ef6795dd9f33194e5feb68b47b22
Author: Tobias Bocanegra <[email protected]>
AuthorDate: Tue May 5 06:45:17 2020 +0900
Propagate __OW_TRANSACTION_ID if present (#208)
---
lib/client.js | 3 +++
test/unit/client.test.js | 11 +++++++++++
2 files changed, 14 insertions(+)
diff --git a/lib/client.js b/lib/client.js
index 504c7d5..e75bf40 100644
--- a/lib/client.js
+++ b/lib/client.js
@@ -182,6 +182,9 @@ class Client {
// identify namespace targeting a public/shared entity
parms.headers['x-namespace-id'] = this.options.namespace
}
+ if (process.env['__OW_TRANSACTION_ID']) {
+ parms.headers['x-request-id'] = process.env['__OW_TRANSACTION_ID']
+ }
if (this.options.proxy) {
parms.proxy = this.options.proxy
diff --git a/test/unit/client.test.js b/test/unit/client.test.js
index 99b5ca1..fff7630 100644
--- a/test/unit/client.test.js
+++ b/test/unit/client.test.js
@@ -201,6 +201,17 @@ test('should return request parameters with merged
options', async t => {
t.deepEqual(params.b, { bar: 'foo' })
})
+test('should return request parameters transaction id', async t => {
+ process.env['__OW_TRANSACTION_ID'] = 'example-transaction-id'
+ const client = new Client({ api_key: 'username:password', apihost: 'blah' })
+ const METHOD = 'get'
+ const PATH = 'some/path/to/resource'
+
+ const params = await client.params(METHOD, PATH)
+ t.is(params.headers['x-request-id'], 'example-transaction-id')
+ delete process.env['__OW_TRANSACTION_ID']
+})
+
test('should return request parameters with cert and key client options',
async t => {
const client = new Client({ api_key: 'username:password', apihost: 'blah',
cert: 'mycert=', key: 'mykey=' })
const METHOD = 'get'