openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestho...@apache.org
Subject [incubator-openwhisk-client-js] branch master updated: Add support for __OW_IGNORE_CERT env var (#110)
Date Mon, 30 Apr 2018 16:03:42 GMT
This is an automated email from the ASF dual-hosted git repository.

jamesthomas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-js.git


The following commit(s) were added to refs/heads/master by this push:
     new 0e21a0c  Add support for __OW_IGNORE_CERT env var (#110)
0e21a0c is described below

commit 0e21a0cf911bce284df6baead97a3cf037ee3583
Author: ScottChapman <scott@chapman.us>
AuthorDate: Mon Apr 30 12:03:39 2018 -0400

    Add support for __OW_IGNORE_CERT env var (#110)
    
    * Add support for __OW_IGNORE_CERT env var
---
 README.md                | 21 +++++++++++----------
 lib/client.js            |  6 +++++-
 test/unit/client.test.js |  3 +++
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 65671b3..cdaa050 100644
--- a/README.md
+++ b/README.md
@@ -81,11 +81,12 @@ _Client constructor supports the following mandatory parameters:_
 
 ### environment variables
 
-Client constructor will read values for the `apihost`, `namespace`, `api_key`, `apigw_token`
and `apigw_space_guid` options from the environment if the following parameters are set. Explicit
options have precedence over environment values.
+Client constructor will read values for the `apihost`, `namespace`, `api_key`, `ignore_certs`,
`apigw_token` and `apigw_space_guid` options from the environment if the following parameters
are set. Explicit options have precedence over environment values.
 
 - *__OW_API_HOST*
 - *__OW_NAMESPACE*
 - *__OW_API_KEY*
+- *__OW_IGNORE_CERTS*
 - *__OW_APIGW_TOKEN*
 - *__OW_APIGW_SPACE_SUID*
 
@@ -540,8 +541,8 @@ If your local environment is using self-signed certificates, you can use
the fol
 
 This will disable SSL/TLS verification for all SSL communication.
 
-Alternatively, you can run the `prepIntegrationTests.sh` script using guest credentials or
by specifying specific credentials.  
-Run the script with openwhisk credentials:  
+Alternatively, you can run the `prepIntegrationTests.sh` script using guest credentials or
by specifying specific credentials.
+Run the script with openwhisk credentials:
 ```bash
 $ ./test/integration/prepIntegrationTests.sh <your key in the form of ABCD:EFGH> <openwhisk
instance hostname> <openwhisk namespace> <api gatewaytoken>
 ```
@@ -550,14 +551,14 @@ The `prepIntegrationTests.sh` script is designed to give you feedback
if it dete
 ## Code-Coverage:
 
 You can customize how comprehensive the tests are over the code, and generate reports to
view the results by using
-the provided `code-coverage` commands below.  
+the provided `code-coverage` commands below.
 
-**Note:** Ensure that you use guest credentials with the wsk CLI.  
+**Note:** Ensure that you use guest credentials with the wsk CLI.
 
-To compile down to ECMA5 run the following command:  
-1 `$ npm run code-coverage-build`  
+To compile down to ECMA5 run the following command:
+1 `$ npm run code-coverage-build`
 
-To generate combined reports of both the unit and integration tests, run the following command:
 
-2 `$ npm run code-coverage-run <key> <host> <namespace> <token> <options>`
 
+To generate combined reports of both the unit and integration tests, run the following command:
+2 `$ npm run code-coverage-run <key> <host> <namespace> <token> <options>`
 
-The report is viewable under `/coverage`. Click **`/coverage/index.html`** to view the full
report.  
+The report is viewable under `/coverage`. Click **`/coverage/index.html`** to view the full
report.
diff --git a/lib/client.js b/lib/client.js
index 337fb22..900173c 100644
--- a/lib/client.js
+++ b/lib/client.js
@@ -73,7 +73,11 @@ class Client {
 
   parseOptions (options) {
     const apiKey = options.api_key || process.env['__OW_API_KEY']
-    const ignoreCerts = options.ignore_certs || false
+    const ignoreCerts = options.ignore_certs ||
+      (process.env['__OW_IGNORE_CERTS']
+        ? process.env['__OW_IGNORE_CERTS'].toLowerCase() === 'true'
+        : false)
+
     // if apihost is available, parse this into full API url
     const api = options.api ||
       this.urlFromApihost(options.apihost || process.env['__OW_API_HOST'])
diff --git a/test/unit/client.test.js b/test/unit/client.test.js
index 9db695f..dc97643 100644
--- a/test/unit/client.test.js
+++ b/test/unit/client.test.js
@@ -61,15 +61,18 @@ test('should use uuid from auth key as space guid if apigw_token present',
t =>
 test('should use environment parameters for options if not set explicitly.', t => {
   process.env['__OW_API_KEY'] = 'some_user:some_pass'
   process.env['__OW_API_HOST'] = 'mywhiskhost'
+  process.env['__OW_IGNORE_CERTS'] = 'true'
   process.env['__OW_APIGW_TOKEN'] = 'my-token'
   process.env['__OW_APIGW_SPACE_GUID'] = 'my-space'
   const client = new Client()
   t.is(client.options.apiKey, process.env['__OW_API_KEY'])
   t.is(client.options.api, 'https://mywhiskhost/api/v1/')
+  t.is(client.options.ignoreCerts, true)
   t.is(client.options.apigwToken, 'my-token')
   t.is(client.options.apigwSpaceGuid, 'my-space')
   delete process.env['__OW_API_KEY']
   delete process.env['__OW_API_HOST']
+  delete process.env['__OW_IGNORE_CERTS']
   delete process.env['__OW_APIGW_TOKEN']
   delete process.env['__OW_APIGW_SPACE_GUID']
 })

-- 
To stop receiving notification emails like this one, please contact
jamesthomas@apache.org.

Mime
View raw message