Skip to content

Commit

Permalink
Test on Node 9. (#8)
Browse files Browse the repository at this point in the history
* Test on Node 9.

* Lint.
  • Loading branch information
stephenplusplus authored Nov 15, 2017
1 parent 06f4904 commit 9ee9326
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 17 deletions.
4 changes: 3 additions & 1 deletion dlp/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ function eventInspectGCSFile(
// Handle changes in job metadata (e.g. progress updates)
operation.on('progress', metadata => {
console.log(
`Processed ${metadata.processedBytes} of approximately ${metadata.totalEstimatedBytes} bytes.`
`Processed ${metadata.processedBytes} of approximately ${
metadata.totalEstimatedBytes
} bytes.`
);
});

Expand Down
14 changes: 9 additions & 5 deletions dlp/risk.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ function kAnonymityAnalysis(projectId, datasetId, tableId, quasiIds) {
completedJobResponse[0].kAnonymityResult
.equivalenceClassHistogramBuckets[0];
console.log(
`Bucket size range: [${results.equivalenceClassSizeLowerBound}, ${results.equivalenceClassSizeUpperBound}]`
`Bucket size range: [${results.equivalenceClassSizeLowerBound}, ${
results.equivalenceClassSizeUpperBound
}]`
);

results.bucketValues.forEach(bucket => {
Expand Down Expand Up @@ -295,17 +297,19 @@ function lDiversityAnalysis(
.sensitiveValueFrequencyHistogramBuckets[0];

console.log(
`Bucket size range: [${results.sensitiveValueFrequencyLowerBound}, ${results.sensitiveValueFrequencyUpperBound}]`
`Bucket size range: [${results.sensitiveValueFrequencyLowerBound}, ${
results.sensitiveValueFrequencyUpperBound
}]`
);
results.bucketValues.forEach(bucket => {
const quasiIdValues = bucket.quasiIdsValues.map(getValue).join(', ');
console.log(` Quasi-ID values: {${quasiIdValues}}`);
console.log(` Class size: ${bucket.equivalenceClassSize}`);
bucket.topSensitiveValues.forEach(valueObj => {
console.log(
` Sensitive value ${getValue(
valueObj.value
)} occurs ${valueObj.count} time(s).`
` Sensitive value ${getValue(valueObj.value)} occurs ${
valueObj.count
} time(s).`
);
});
});
Expand Down
16 changes: 12 additions & 4 deletions dlp/system-test/inspect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,15 @@ test(`should have a minLikelihood option`, async t => {

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

Expand Down Expand Up @@ -269,11 +273,15 @@ test(`should have an option to include quotes`, async t => {

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

Expand Down
24 changes: 18 additions & 6 deletions dlp/system-test/redact.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,29 @@ test.before(tools.checkCredentials);
// redact_string
test(`should redact multiple sensitive data types from a string`, async t => {
const output = await tools.runAsync(
`${cmd} string "I am Gary and my phone number is (123) 456-7890." REDACTED -t US_MALE_NAME PHONE_NUMBER`,
`${
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 redact a single sensitive data type from a string`, async t => {
const output = await tools.runAsync(
`${cmd} string "I am Gary and my phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER`,
`${
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 tools.runAsync(
`${cmd} string "My name is Gary and my phone number is (123) 456-7890." REDACTED -t BAD_TYPE`,
`${
cmd
} string "My name is Gary and my phone number is (123) 456-7890." REDACTED -t BAD_TYPE`,
cwd
);
t.regex(output, /Error in redactString/);
Expand All @@ -57,7 +63,9 @@ test(`should report string redaction handling errors`, async t => {
test(`should redact a single sensitive data type from an image`, async t => {
const testName = `redact-multiple-types`;
const output = await tools.runAsync(
`${cmd} image ${testImage} ${testName}.result.png -t PHONE_NUMBER EMAIL_ADDRESS`,
`${cmd} image ${testImage} ${
testName
}.result.png -t PHONE_NUMBER EMAIL_ADDRESS`,
cwd
);

Expand Down Expand Up @@ -105,11 +113,15 @@ test(`should report image redaction handling errors`, async t => {
// CLI options
test(`should have a minLikelihood option`, async t => {
const promiseA = tools.runAsync(
`${cmd} string "My phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER -m VERY_LIKELY`,
`${
cmd
} string "My phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER -m VERY_LIKELY`,
cwd
);
const promiseB = tools.runAsync(
`${cmd} string "My phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER -m UNLIKELY`,
`${
cmd
} string "My phone number is (123) 456-7890." REDACTED -t PHONE_NUMBER -m UNLIKELY`,
cwd
);

Expand Down
4 changes: 3 additions & 1 deletion dlp/system-test/risk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ test(`should perform l-diversity analysis on a single field`, async t => {

test(`should perform l-diversity analysis on multiple fields`, async t => {
const output = await tools.runAsync(
`${cmd} lDiversity ${dataset} harmful ${uniqueField} ${numericField} ${repeatedField}`,
`${cmd} lDiversity ${dataset} harmful ${uniqueField} ${numericField} ${
repeatedField
}`,
cwd
);
t.regex(output, /Quasi-ID values: \{\d{2}, \d{4} \d{4} \d{4} \d{4}\}/);
Expand Down

0 comments on commit 9ee9326

Please sign in to comment.