Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis: fix failing tests + update dependencies #335

Merged
merged 16 commits into from
Apr 5, 2017
Merged
37 changes: 37 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2015-2016, Google, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

sudo: false
language: node_js
node_js:
- "6"

cache:
directories:
- node_modules/

env:
global:
- GOOGLE_APPLICATION_CREDENTIALS=$TRAVIS_BUILD_DIR/key.json
- TEST_BUCKET_NAME=nodejs-docs-samples
- GCLOUD_PROJECT=nodejs-docs-samples

before_install:
- openssl aes-256-cbc -K $encrypted_fda0b707c7d5_key -iv $encrypted_fda0b707c7d5_iv -in key.json.enc -out key.json -d
- npm install -g npm
- npm set progress=false

before_script:
- node scripts/install

script: npm test
4 changes: 2 additions & 2 deletions appengine/grunt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"grunt": "1.0.1",
"grunt-cli": "1.2.0",
"grunt-contrib-clean": "1.0.0",
"grunt-contrib-cssmin": "1.0.2",
"grunt-contrib-cssmin": "2.0.0",
"grunt-contrib-jshint": "1.1.0",
"grunt-contrib-watch": "1.0.0",
"morgan": "1.7.0",
"morgan": "1.8.0",
"pug": "2.0.0-beta6",
"serve-favicon": "2.3.2"
}
Expand Down
2 changes: 1 addition & 1 deletion appengine/loopback/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"helmet": "1.3.0",
"loopback-boot": "2.6.5",
"loopback-component-explorer": "2.4.0",
"serve-favicon": "2.0.1",
"serve-favicon": "2.3.2",
"strong-error-handler": "1.0.1",
"loopback-datasource-juggler": "2.39.0",
"loopback": "2.22.0"
Expand Down
2 changes: 1 addition & 1 deletion appengine/sails/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"grunt-contrib-coffee": "0.13.0",
"grunt-contrib-concat": "0.5.1",
"grunt-contrib-copy": "0.8.1",
"grunt-contrib-cssmin": "0.14.0",
"grunt-contrib-cssmin": "2.0.0",
"grunt-contrib-jst": "0.6.0",
"grunt-contrib-less": "1.0.1",
"grunt-contrib-uglify": "0.9.2",
Expand Down
4 changes: 2 additions & 2 deletions computeengine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"system-test": "cd ..; npm run t -- computeengine/system-test/*.test.js"
},
"dependencies": {
"@google-cloud/compute": "0.5.0",
"googleapis": "16.1.0",
"@google-cloud/compute": "0.6.0",
"googleapis": "18.0.0",
"nodemailer": "2.7.0",
"nodemailer-smtp-transport": "2.7.2",
"sendgrid": "4.7.1"
Expand Down
2 changes: 1 addition & 1 deletion datastore/concepts.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class Metadata extends TestHelper {
return runNamespaceQuery(startNamespace, endNamespace);
})
.then((namespaces) => {
t.deepEqual(namespaces, ['Animals']);
t.true(namespaces.includes('Animals'));
});
}

Expand Down
2 changes: 1 addition & 1 deletion datastore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"test": "cd ..; npm run st -- --verbose datastore/system-test/*.test.js"
},
"dependencies": {
"@google-cloud/datastore": "0.7.0",
"@google-cloud/datastore": "0.8.0",
"yargs": "6.6.0"
},
"engines": {
Expand Down
4 changes: 3 additions & 1 deletion datastore/system-test/quickstart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const entity = { description: `Buy milk` };
const kind = `Task`;
const name = `sampletask1`;
const key = datastore.key([kind, name]);
const datastoreEntity = Object.assign({}, entity);
datastoreEntity[datastore.KEY] = key;

test.before(async () => {
try {
Expand Down Expand Up @@ -52,7 +54,7 @@ test.cb(`should get a task from Datastore`, (t) => {
setTimeout(() => {
datastore.get(key)
.then(([task]) => {
t.deepEqual(task, entity);
t.deepEqual(task, datastoreEntity);
t.true(console.log.calledWith(`Saved ${name}: ${entity.description}`));
t.end();
})
Expand Down
52 changes: 27 additions & 25 deletions dlp/system-test/inspect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,102 +16,104 @@
'use strict';

require(`../../system-test/_setup`);
const path = require('path');

const cmd = 'node inspect';
const cwd = path.join(__dirname, `..`);

// inspect_string
test(`should inspect a string`, async (t) => {
const output = await runAsync(`${cmd} string "I'm Gary and my email is [email protected]"`);
const output = await runAsync(`${cmd} string "I'm Gary and my email is [email protected]"`, cwd);
t.regex(output, /"name": "EMAIL_ADDRESS"/);
});

test(`should handle a string with no sensitive data`, async (t) => {
const output = await runAsync(`${cmd} string "foo"`);
const output = await runAsync(`${cmd} string "foo"`, cwd);
t.is(output, 'undefined');
});

test(`should report string inspection handling errors`, async (t) => {
const output = await runAsync(`${cmd} string "I'm Gary and my email is [email protected]" -a foo`);
const output = await runAsync(`${cmd} string "I'm Gary and my email is [email protected]" -a foo`, cwd);
t.regex(output, /Error in inspectString/);
});

// inspect_file
test(`should inspect a local text file`, async (t) => {
const output = await runAsync(`${cmd} file resources/test.txt`);
const output = await runAsync(`${cmd} file resources/test.txt`, cwd);
t.regex(output, /"name": "PHONE_NUMBER"/);
t.regex(output, /"name": "EMAIL_ADDRESS"/);
});

test(`should inspect a local image file`, async (t) => {
const output = await runAsync(`${cmd} file resources/test.png`);
const output = await runAsync(`${cmd} file resources/test.png`, cwd);
t.regex(output, /"name": "PHONE_NUMBER"/);
});

test(`should handle a local file with no sensitive data`, async (t) => {
const output = await runAsync(`${cmd} file resources/harmless.txt`);
const output = await runAsync(`${cmd} file resources/harmless.txt`, cwd);
t.is(output, 'undefined');
});

test(`should report local file handling errors`, async (t) => {
const output = await runAsync(`${cmd} file resources/harmless.txt -a foo`);
const output = await runAsync(`${cmd} file resources/harmless.txt -a foo`, cwd);
t.regex(output, /Error in inspectFile/);
});

// inspect_gcs_file
test.serial(`should inspect a GCS text file`, async (t) => {
const output = await runAsync(`${cmd} gcsFile nodejs-docs-samples-dlp test.txt`);
const output = await runAsync(`${cmd} gcsFile nodejs-docs-samples-dlp test.txt`, cwd);
t.regex(output, /"name": "PHONE_NUMBER"/);
t.regex(output, /"name": "EMAIL_ADDRESS"/);
});

test.serial(`should inspect multiple GCS text files`, async (t) => {
const output = await runAsync(`${cmd} gcsFile nodejs-docs-samples-dlp *.txt`);
const output = await runAsync(`${cmd} gcsFile nodejs-docs-samples-dlp *.txt`, cwd);
t.regex(output, /"name": "PHONE_NUMBER"/);
t.regex(output, /"name": "EMAIL_ADDRESS"/);
t.regex(output, /"name": "CREDIT_CARD_NUMBER"/);
});

test.serial(`should accept try limits for inspecting GCS files`, async (t) => {
const output = await runAsync(`${cmd} gcsFile nodejs-docs-samples-dlp test.txt --tries 0`);
const output = await runAsync(`${cmd} gcsFile nodejs-docs-samples-dlp test.txt --tries 0`, cwd);
t.regex(output, /polling timed out/);
});

test.serial(`should handle a GCS file with no sensitive data`, async (t) => {
const output = await runAsync(`${cmd} gcsFile nodejs-docs-samples-dlp harmless.txt`);
const output = await runAsync(`${cmd} gcsFile nodejs-docs-samples-dlp harmless.txt`, cwd);
t.is(output, 'undefined');
});

test.serial(`should report GCS file handling errors`, async (t) => {
const output = await runAsync(`${cmd} gcsFile nodejs-docs-samples-dlp harmless.txt -a foo`);
const output = await runAsync(`${cmd} gcsFile nodejs-docs-samples-dlp harmless.txt -a foo`, cwd);
t.regex(output, /Error in inspectGCSFile/);
});

// inspect_datastore
test.serial(`should inspect Datastore`, async (t) => {
const output = await runAsync(`${cmd} datastore Person --namespaceId DLP`);
const output = await runAsync(`${cmd} datastore Person --namespaceId DLP`, cwd);
t.regex(output, /"name": "PHONE_NUMBER"/);
t.regex(output, /"name": "EMAIL_ADDRESS"/);
});

test.serial(`should accept try limits for inspecting Datastore`, async (t) => {
const output = await runAsync(`${cmd} datastore Person --namespaceId DLP --tries 0`);
const output = await runAsync(`${cmd} datastore Person --namespaceId DLP --tries 0`, cwd);
t.regex(output, /polling timed out/);
});

test.serial(`should handle Datastore with no sensitive data`, async (t) => {
const output = await runAsync(`${cmd} datastore Harmless --namespaceId DLP`);
const output = await runAsync(`${cmd} datastore Harmless --namespaceId DLP`, cwd);
t.is(output, 'undefined');
});

test.serial(`should report Datastore file handling errors`, async (t) => {
const output = await runAsync(`${cmd} datastore Harmless --namespaceId DLP -a foo`);
const output = await runAsync(`${cmd} datastore Harmless --namespaceId DLP -a foo`, cwd);
t.regex(output, /Error in inspectDatastore/);
});

// CLI options
test(`should have a minLikelihood option`, async (t) => {
const promiseA = runAsync(`${cmd} string "My phone number is (123) 456-7890." -m POSSIBLE`);
const promiseB = runAsync(`${cmd} string "My phone number is (123) 456-7890." -m UNLIKELY`);
const promiseA = runAsync(`${cmd} string "My phone number is (123) 456-7890." -m POSSIBLE`, cwd);
const promiseB = runAsync(`${cmd} string "My phone number is (123) 456-7890." -m UNLIKELY`, cwd);

const outputA = await promiseA;
t.truthy(outputA);
Expand All @@ -122,8 +124,8 @@ test(`should have a minLikelihood option`, async (t) => {
});

test(`should have a maxFindings option`, async (t) => {
const promiseA = runAsync(`${cmd} string "My email is [email protected] and my phone number is (223) 456-7890." -f 1`);
const promiseB = runAsync(`${cmd} string "My email is [email protected] and my phone number is (223) 456-7890." -f 2`);
const promiseA = runAsync(`${cmd} string "My email is [email protected] and my phone number is (223) 456-7890." -f 1`, cwd);
const promiseB = runAsync(`${cmd} string "My email is [email protected] and my phone number is (223) 456-7890." -f 2`, cwd);

const outputA = await promiseA;
t.not(outputA.includes('PHONE_NUMBER'), outputA.includes('EMAIL_ADDRESS')); // Exactly one of these should be included
Expand All @@ -134,8 +136,8 @@ test(`should have a maxFindings option`, async (t) => {
});

test(`should have an option to include quotes`, async (t) => {
const promiseA = runAsync(`${cmd} string "My phone number is (223) 456-7890." -q false`);
const promiseB = runAsync(`${cmd} string "My phone number is (223) 456-7890."`);
const promiseA = runAsync(`${cmd} string "My phone number is (223) 456-7890." -q false`, cwd);
const promiseB = runAsync(`${cmd} string "My phone number is (223) 456-7890."`, cwd);

const outputA = await promiseA;
t.truthy(outputA);
Expand All @@ -146,8 +148,8 @@ test(`should have an option to include quotes`, async (t) => {
});

test(`should have an option to filter results by infoType`, async (t) => {
const promiseA = runAsync(`${cmd} string "My email is [email protected] and my phone number is (223) 456-7890."`);
const promiseB = runAsync(`${cmd} string "My email is [email protected] and my phone number is (223) 456-7890." -t PHONE_NUMBER`);
const promiseA = runAsync(`${cmd} string "My email is [email protected] and my phone number is (223) 456-7890."`, cwd);
const promiseB = runAsync(`${cmd} string "My email is [email protected] and my phone number is (223) 456-7890." -t PHONE_NUMBER`, cwd);

const outputA = await promiseA;
t.regex(outputA, /EMAIL_ADDRESS/);
Expand All @@ -159,7 +161,7 @@ test(`should have an option to filter results by infoType`, async (t) => {
});

test(`should have an option for custom auth tokens`, async (t) => {
const output = await runAsync(`${cmd} string "My name is Gary and my phone number is (223) 456-7890." -a foo`);
const output = await runAsync(`${cmd} string "My name is Gary and my phone number is (223) 456-7890." -a foo`, cwd);
t.regex(output, /Error in inspectString/);
t.regex(output, /invalid authentication/);
});
Expand Down
14 changes: 8 additions & 6 deletions dlp/system-test/metadata.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,34 @@
'use strict';

require(`../../system-test/_setup`);
const path = require('path');

const cmd = `node metadata`;
const cmd = 'node metadata';
const cwd = path.join(__dirname, `..`);

test(`should list info types for a given category`, async (t) => {
const output = await runAsync(`${cmd} infoTypes GOVERNMENT`);
const output = await runAsync(`${cmd} infoTypes GOVERNMENT`, cwd);
t.regex(output, /name: 'US_DRIVERS_LICENSE_NUMBER'/);
});

test(`should inspect categories`, async (t) => {
const output = await runAsync(`${cmd} categories`);
const output = await runAsync(`${cmd} categories`, cwd);
t.regex(output, /name: 'FINANCE'/);
});

test(`should have an option for custom auth tokens`, async (t) => {
const output = await runAsync(`${cmd} categories -a foo`);
const output = await runAsync(`${cmd} categories -a foo`, cwd);
t.regex(output, /Error in listCategories/);
t.regex(output, /invalid authentication/);
});

// Error handling
test(`should report info type listing handling errors`, async (t) => {
const output = await runAsync(`${cmd} infoTypes GOVERNMENT -a foo`);
const output = await runAsync(`${cmd} infoTypes GOVERNMENT -a foo`, cwd);
t.regex(output, /Error in listInfoTypes/);
});

test(`should report category listing handling errors`, async (t) => {
const output = await runAsync(`${cmd} categories -a foo`);
const output = await runAsync(`${cmd} categories -a foo`, cwd);
t.regex(output, /Error in listCategories/);
});
14 changes: 8 additions & 6 deletions dlp/system-test/redact.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,31 @@
'use strict';

require(`../../system-test/_setup`);
const path = require('path');

const cmd = 'node redact';
const cwd = path.join(__dirname, `..`);

// redact_string
test(`should redact sensitive data from a string`, async (t) => {
const output = await runAsync(`${cmd} string "I am Gary and my phone number is (123) 456-7890." REDACTED -t US_MALE_NAME PHONE_NUMBER`);
const output = await runAsync(`${cmd} string "I am Gary and my phone number is (123) 456-7890." REDACTED -t US_MALE_NAME PHONE_NUMBER`, cwd);
t.is(output, 'I am REDACTED and my phone number is REDACTED.');
});

test(`should ignore unspecified type names when redacting from a string`, async (t) => {
const output = await runAsync(`${cmd} string "I am Gary and my phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER`);
const output = await runAsync(`${cmd} string "I am Gary and my phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER`, cwd);
t.is(output, 'I am Gary and my phone number is REDACTED.');
});

test(`should report string redaction handling errors`, async (t) => {
const output = await runAsync(`${cmd} string "My name is Gary and my phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER -a foo`);
const output = await runAsync(`${cmd} string "My name is Gary and my phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER -a foo`, cwd);
t.regex(output, /Error in redactString/);
});

// CLI options
test(`should have a minLikelihood option`, async (t) => {
const promiseA = runAsync(`${cmd} string "My phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER -m VERY_LIKELY`);
const promiseB = runAsync(`${cmd} string "My phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER -m UNLIKELY`);
const promiseA = runAsync(`${cmd} string "My phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER -m VERY_LIKELY`, cwd);
const promiseB = runAsync(`${cmd} string "My phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER -m UNLIKELY`, cwd);

const outputA = await promiseA;
t.is(outputA, 'My phone number is (123) 456-7890.');
Expand All @@ -48,7 +50,7 @@ test(`should have a minLikelihood option`, async (t) => {
});

test(`should have an option for custom auth tokens`, async (t) => {
const output = await runAsync(`${cmd} string "My name is Gary and my phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER -a foo`);
const output = await runAsync(`${cmd} string "My name is Gary and my phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER -a foo`, cwd);
t.regex(output, /Error in redactString/);
t.regex(output, /invalid authentication/);
});
2 changes: 1 addition & 1 deletion functions/log/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},
"dependencies": {
"@google-cloud/logging": "0.7.0",
"@google-cloud/monitoring": "0.1.4"
"@google-cloud/monitoring": "0.2.0"
}
}
2 changes: 1 addition & 1 deletion functions/ocr/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"@google-cloud/pubsub": "0.8.0",
"@google-cloud/storage": "0.7.0",
"@google-cloud/translate": "0.7.0",
"@google-cloud/vision": "0.8.0"
"@google-cloud/vision": "0.11.0"
}
}
2 changes: 1 addition & 1 deletion functions/slack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"test": "cd ../..; npm run t -- functions/slack/test/*.test.js"
},
"dependencies": {
"googleapis": "16.1.0"
"googleapis": "18.0.0"
}
}
Loading