@@ -77,8 +77,7 @@ describe('Model Armor tests', () => {
7777 const templatesToDelete = [ ] ;
7878
7979 before ( async ( ) => {
80- // projectId = await client.getProjectId();
81- projectId = 'ma-crest-data-test-2' ;
80+ projectId = await client . getProjectId ( ) ;
8281
8382 // Import necessary enums
8483 const { protos} = require ( '@google-cloud/modelarmor' ) ;
@@ -181,186 +180,26 @@ describe('Model Armor tests', () => {
181180 }
182181 } ) ;
183182
184- // =================== Template Creation Tests ===================
183+ // =================== Quickstart Tests ===================
185184
186- it ( 'should create a basic template' , async ( ) => {
187- const testTemplateId = `${ templateIdPrefix } -basic-create` ;
185+ it ( 'should create a template and sanitize content' , ( ) => {
186+ // Define the test template ID for quickstart
187+ const testQuickstartTemplateId = `${ templateIdPrefix } -quickstart` ;
188188
189189 const output = execSync (
190- `node snippets/createTemplate .js ${ projectId } ${ locationId } ${ testTemplateId } `
190+ `node snippets/quickstart .js ${ projectId } ${ locationId } ${ testQuickstartTemplateId } `
191191 ) ;
192192
193- const templateName = `projects/${ projectId } /locations/${ locationId } /templates/${ testTemplateId } ` ;
194- templatesToDelete . push ( templateName ) ;
195-
196- assert . match ( output , new RegExp ( `Created template: ${ templateName } ` ) ) ;
197- } ) ;
198-
199- it ( 'should create a template with basic SDP settings' , async ( ) => {
200- const testTemplateId = `${ templateIdPrefix } -basic-sdp-1` ;
201-
202- const output = execSync (
203- `node snippets/createTemplateWithBasicSdp.js ${ projectId } ${ locationId } ${ testTemplateId } `
204- ) ;
205-
206- const templateName = `projects/${ projectId } /locations/${ locationId } /templates/${ testTemplateId } ` ;
207- templatesToDelete . push ( templateName ) ;
208-
209- assert . match ( output , new RegExp ( `Created template: ${ templateName } ` ) ) ;
210- } ) ;
211-
212- it ( 'should create a template with advanced SDP settings' , async ( ) => {
213- const testTemplateId = `${ templateIdPrefix } -adv-sdp` ;
214- const inspectTemplate = basicSdpTemplateId ;
215- const deidentifyTemplate = basicSdpTemplateId ;
216-
217- const fullInspectTemplate = `projects/${ projectId } /locations/${ locationId } /inspectTemplates/${ inspectTemplate } ` ;
218- const fullDeidentifyTemplate = `projects/${ projectId } /locations/${ locationId } /deidentifyTemplates/${ deidentifyTemplate } ` ;
219-
220- const output = execSync (
221- `node snippets/createTemplateWithAdvancedSdp.js ${ projectId } ${ locationId } ${ testTemplateId } ${ fullInspectTemplate } ${ fullDeidentifyTemplate } `
222- ) ;
223-
224- const templateName = `projects/${ projectId } /locations/${ locationId } /templates/${ testTemplateId } ` ;
225- templatesToDelete . push ( templateName ) ;
226-
227- assert . match ( output , new RegExp ( `Created template: ${ templateName } ` ) ) ;
228- } ) ;
229-
230- it ( 'should create a template with metadata' , async ( ) => {
231- const testTemplateId = `${ templateIdPrefix } -metadata` ;
232-
233- const output = execSync (
234- `node snippets/createTemplateWithMetadata.js ${ projectId } ${ locationId } ${ testTemplateId } `
235- ) ;
236-
237- const templateName = `projects/${ projectId } /locations/${ locationId } /templates/${ testTemplateId } ` ;
238- templatesToDelete . push ( templateName ) ;
239-
240- assert . match (
241- output ,
242- new RegExp ( `Created Model Armor Template: ${ templateName } ` )
243- ) ;
244- } ) ;
245-
246- it ( 'should create a template with labels' , async ( ) => {
247- const testTemplateId = `${ templateIdPrefix } -labels` ;
248- const labelKey = 'environment' ;
249- const labelValue = 'test' ;
250-
251- const output = execSync (
252- `node snippets/createTemplateWithLabels.js ${ projectId } ${ locationId } ${ testTemplateId } ${ labelKey } ${ labelValue } `
253- ) ;
254-
255- const templateName = `projects/${ projectId } /locations/${ locationId } /templates/${ testTemplateId } ` ;
256- templatesToDelete . push ( templateName ) ;
257-
258- assert . match ( output , new RegExp ( `Created template: ${ templateName } ` ) ) ;
259- } ) ;
260-
261- // =================== Template Management Tests ===================
262-
263- it ( 'should get a template' , async ( ) => {
264- const templateToGet = `${ templateIdPrefix } -basic-sdp` ;
265- const templateName = `projects/${ projectId } /locations/${ locationId } /templates/${ templateToGet } ` ;
266- const output = execSync (
267- `node snippets/getTemplate.js ${ projectId } ${ locationId } ${ templateToGet } `
268- ) ;
269-
270- assert . match ( output , new RegExp ( `Template name: ${ templateName } ` ) ) ;
271- } ) ;
272-
273- it ( 'should delete a template' , async ( ) => {
274- const templateName = `projects/${ projectId } /locations/${ locationId } /templates/${ templateToDeleteId } ` ;
275-
276- const output = execSync (
277- `node snippets/deleteTemplate.js ${ projectId } ${ locationId } ${ templateToDeleteId } `
278- ) ;
279-
280- assert . match ( output , new RegExp ( `Deleted template ${ templateName } ` ) ) ;
281- } ) ;
282-
283- it ( 'should list templates' , async ( ) => {
284- const output = execSync (
285- `node snippets/listTemplates.js ${ projectId } ${ locationId } `
286- ) ;
287-
288- const templateNamePattern = `projects/${ projectId } /locations/${ locationId } /templates/${ templateIdPrefix } ` ;
289-
290- assert . match ( output , new RegExp ( templateNamePattern ) ) ;
291- } ) ;
292-
293- it ( 'should list templates with filter' , async ( ) => {
294- const templateToGet = `${ templateIdPrefix } -basic-sdp` ;
295- const output = execSync (
296- `node snippets/listTemplatesWithFilter.js ${ projectId } ${ locationId } ${ templateToGet } `
297- ) ;
298-
299- const templateName = `projects/${ projectId } /locations/${ locationId } /templates/${ templateToGet } ` ;
300-
301- assert . match ( output , new RegExp ( `Found template ${ templateName } ` ) ) ;
302- } ) ;
303-
304- // =================== Template Update Tests ===================
305-
306- it ( 'should update a template' , async ( ) => {
307- const templateToUpdate = `${ templateIdPrefix } -basic-create` ;
308- const output = execSync (
309- `node snippets/updateTemplate.js ${ projectId } ${ locationId } ${ templateToUpdate } `
310- ) ;
311-
312- assert . match ( output , / U p d a t e d t e m p l a t e f i l t e r c o n f i g u r a t i o n : / ) ;
313-
314- assert . match ( output , / p i A n d J a i l b r e a k F i l t e r S e t t i n g s / ) ;
315- assert . match ( output , / f i l t e r E n f o r c e m e n t : ' E N A B L E D ' / ) ;
316- assert . match ( output , / c o n f i d e n c e L e v e l : ' L O W _ A N D _ A B O V E ' / ) ;
317- assert . match ( output , / m a l i c i o u s U r i F i l t e r S e t t i n g s / ) ;
318- } ) ;
319-
320- it ( 'should update template labels' , async ( ) => {
321- const labelKey = 'environment' ;
322- const labelValue = 'testing' ;
323- const templateToUpdate = `${ templateIdPrefix } -basic-create` ;
324-
325- const output = execSync (
326- `node snippets/updateTemplateLabels.js ${ projectId } ${ locationId } ${ templateToUpdate } ${ labelKey } ${ labelValue } `
327- ) ;
328-
329- const templateName = `projects/${ projectId } /locations/${ locationId } /templates/${ templateToUpdate } ` ;
330-
331- assert . match (
332- output ,
333- new RegExp ( `Updated Model Armor Template: ${ templateName } ` )
334- ) ;
335- } ) ;
336-
337- it ( 'should update template metadata' , async ( ) => {
338- const templateToUpdateMetadata = `${ templateIdPrefix } -metadata` ;
339-
340- const output = execSync (
341- `node snippets/updateTemplateMetadata.js ${ projectId } ${ locationId } ${ templateToUpdateMetadata } `
342- ) ;
343-
344- const templateName = `projects/${ projectId } /locations/${ locationId } /templates/${ templateToUpdateMetadata } ` ;
345-
193+ // Verify the output contains the expected strings indicating success
346194 assert . match (
347195 output ,
348- new RegExp ( `Updated Model Armor Template: ${ templateName } ` )
196+ new RegExp (
197+ `Created template: projects/${ projectId } /locations/${ locationId } /templates/${ testQuickstartTemplateId } `
198+ )
349199 ) ;
350- } ) ;
351200
352- it ( 'should update template with mask configuration' , async ( ) => {
353- const templateToUpdateWithMask = `${ templateIdPrefix } -metadata` ;
354-
355- const output = execSync (
356- `node snippets/updateTemplateWithMaskConfiguration.js ${ projectId } ${ locationId } ${ templateToUpdateWithMask } `
357- ) ;
358-
359- const templateName = `projects/${ projectId } /locations/${ locationId } /templates/${ templateToUpdateWithMask } ` ;
360-
361- assert . match (
362- output ,
363- new RegExp ( `Updated Model Armor Template: ${ templateName } ` )
201+ templatesToDelete . push (
202+ `projects/${ projectId } /locations/${ locationId } /templates/${ testQuickstartTemplateId } `
364203 ) ;
365204 } ) ;
366205} ) ;
0 commit comments