Add support for __OW_IGNORE_CERT env var (#110)
* Add support for __OW_IGNORE_CERT env var
diff --git a/README.md b/README.md
index 65671b3..cdaa050 100644
--- a/README.md
+++ b/README.md
@@ -81,11 +81,12 @@
### 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 @@
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 @@
## 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 @@
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 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']
})