11/**
2- * Copyright 2018, Google, Inc.
2+ * Copyright 2018 Google LLC
33 * Licensed under the Apache License, Version 2.0 (the "License");
44 * you may not use this file except in compliance with the License.
55 * You may obtain a copy of the License at
@@ -30,12 +30,19 @@ const execSync = cmd => {
3030const cmd = 'node risk.js' ;
3131const dataset = 'integration_tests_dlp' ;
3232const uniqueField = 'Name' ;
33- const repeatedField = 'Mystery' ;
3433const numericField = 'Age' ;
35- const stringBooleanField = 'Gender' ;
3634const testProjectId = process . env . GCLOUD_PROJECT ;
3735const pubsub = new PubSub ( ) ;
3836
37+ /*
38+ * The tests in this file rely on a table in BigQuery entitled
39+ * "integration_tests_dlp.harmful" with the following fields:
40+ *
41+ * Age NUMERIC NULLABLE
42+ * Name STRING NULLABLE
43+ *
44+ * Insert into this table a few rows of Age/Name pairs.
45+ */
3946describe ( 'risk' , ( ) => {
4047 // Create new custom topic/subscription
4148 let topic , subscription ;
@@ -57,8 +64,9 @@ describe('risk', () => {
5764 const output = execSync (
5865 `${ cmd } numerical ${ dataset } harmful ${ numericField } ${ topicName } ${ subscriptionName } -p ${ testProjectId } `
5966 ) ;
60- assert . match ( output , / V a l u e a t 0 % q u a n t i l e : \d { 2 } / ) ;
61- assert . match ( output , / V a l u e a t \d { 2 } % q u a n t i l e : \d { 2 } / ) ;
67+ console . info ( output ) ;
68+ assert . match ( output , / V a l u e a t 0 % q u a n t i l e : / ) ;
69+ assert . match ( output , / V a l u e a t \d + % q u a n t i l e : / ) ;
6270 } ) ;
6371
6472 it ( 'should handle numerical risk analysis errors' , ( ) => {
@@ -95,15 +103,7 @@ describe('risk', () => {
95103 const output = execSync (
96104 `${ cmd } kAnonymity ${ dataset } harmful ${ topicName } ${ subscriptionName } ${ numericField } -p ${ testProjectId } `
97105 ) ;
98- assert . match ( output , / Q u a s i - I D v a l u e s : \{ \d { 2 } \} / ) ;
99- assert . match ( output , / C l a s s s i z e : \d / ) ;
100- } ) ;
101-
102- it ( 'should perform k-anonymity analysis on multiple fields' , ( ) => {
103- const output = execSync (
104- `${ cmd } kAnonymity ${ dataset } harmful ${ topicName } ${ subscriptionName } ${ numericField } ${ repeatedField } -p ${ testProjectId } `
105- ) ;
106- assert . match ( output , / Q u a s i - I D v a l u e s : \{ \d { 2 } , \d { 4 } \d { 4 } \d { 4 } \d { 4 } \} / ) ;
106+ assert . match ( output , / Q u a s i - I D v a l u e s : / ) ;
107107 assert . match ( output , / C l a s s s i z e : \d / ) ;
108108 } ) ;
109109
@@ -124,15 +124,6 @@ describe('risk', () => {
124124 assert . match ( output , / V a l u e s : \d { 2 } / ) ;
125125 } ) ;
126126
127- it ( 'should perform k-map analysis on multiple fields' , ( ) => {
128- const output = execSync (
129- `${ cmd } kMap ${ dataset } harmful ${ topicName } ${ subscriptionName } ${ numericField } ${ stringBooleanField } -t AGE GENDER -p ${ testProjectId } `
130- ) ;
131- assert . match ( output , / A n o n y m i t y r a n g e : \[ \d + , \d + \] / ) ;
132- assert . match ( output , / S i z e : \d / ) ;
133- assert . match ( output , / V a l u e s : \d { 2 } F e m a l e / ) ;
134- } ) ;
135-
136127 it ( 'should handle k-map analysis errors' , ( ) => {
137128 const output = execSync (
138129 `${ cmd } kMap ${ dataset } nonexistent ${ topicName } ${ subscriptionName } ${ numericField } -t AGE -p ${ testProjectId } `
@@ -153,18 +144,9 @@ describe('risk', () => {
153144 const output = execSync (
154145 `${ cmd } lDiversity ${ dataset } harmful ${ uniqueField } ${ topicName } ${ subscriptionName } ${ numericField } -p ${ testProjectId } `
155146 ) ;
156- assert . match ( output , / Q u a s i - I D v a l u e s : \{ \d { 2 } \} / ) ;
157- assert . match ( output , / C l a s s s i z e : \d / ) ;
158- assert . match ( output , / S e n s i t i v e v a l u e J a m e s o c c u r s \d t i m e \( s \) / ) ;
159- } ) ;
160-
161- it ( 'should perform l-diversity analysis on multiple fields' , ( ) => {
162- const output = execSync (
163- `${ cmd } lDiversity ${ dataset } harmful ${ uniqueField } ${ topicName } ${ subscriptionName } ${ numericField } ${ repeatedField } -p ${ testProjectId } `
164- ) ;
165- assert . match ( output , / Q u a s i - I D v a l u e s : \{ \d { 2 } , \d { 4 } \d { 4 } \d { 4 } \d { 4 } \} / ) ;
147+ assert . match ( output , / Q u a s i - I D v a l u e s : / ) ;
166148 assert . match ( output , / C l a s s s i z e : \d / ) ;
167- assert . match ( output , / S e n s i t i v e v a l u e J a m e s o c c u r s \d t i m e \( s \) / ) ;
149+ assert . match ( output , / S e n s i t i v e v a l u e / ) ;
168150 } ) ;
169151
170152 it ( 'should handle l-diversity analysis errors' , ( ) => {
0 commit comments