Skip to content

Commit ff148e0

Browse files
committed
chore(modelarmor): Refactored tests assertion for floor settings tests
1 parent 5b87090 commit ff148e0

File tree

1 file changed

+64
-71
lines changed

1 file changed

+64
-71
lines changed

model-armor/test/modelarmor.test.js

Lines changed: 64 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
'use strict';
1616

17-
const {assert} = require('chai');
18-
const {v4: uuidv4} = require('uuid');
19-
const {ModelArmorClient} = require('@google-cloud/modelarmor').v1;
20-
const {DlpServiceClient} = require('@google-cloud/dlp');
17+
const { assert } = require('chai');
18+
const { v4: uuidv4 } = require('uuid');
19+
const { ModelArmorClient } = require('@google-cloud/modelarmor').v1;
20+
const { DlpServiceClient } = require('@google-cloud/dlp');
2121

2222
let projectId;
2323
const locationId = process.env.GCLOUD_LOCATION || 'us-central1';
@@ -173,9 +173,9 @@ async function createDlpTemplates() {
173173
inspectTemplate: {
174174
inspectConfig: {
175175
infoTypes: [
176-
{name: 'EMAIL_ADDRESS'},
177-
{name: 'PHONE_NUMBER'},
178-
{name: 'US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER'},
176+
{ name: 'EMAIL_ADDRESS' },
177+
{ name: 'PHONE_NUMBER' },
178+
{ name: 'US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER' },
179179
],
180180
},
181181
},
@@ -260,7 +260,7 @@ describe('Model Armor tests', () => {
260260

261261
before(async () => {
262262
projectId = await client.getProjectId();
263-
const {protos} = require('@google-cloud/modelarmor');
263+
const { protos } = require('@google-cloud/modelarmor');
264264
// Import necessary enums
265265
const DetectionConfidenceLevel =
266266
protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel;
@@ -298,9 +298,9 @@ describe('Model Armor tests', () => {
298298
basicConfig: {
299299
filterEnforcement: SdpBasicConfigEnforcement.ENABLED,
300300
infoTypes: [
301-
{name: 'EMAIL_ADDRESS'},
302-
{name: 'PHONE_NUMBER'},
303-
{name: 'US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER'},
301+
{ name: 'EMAIL_ADDRESS' },
302+
{ name: 'PHONE_NUMBER' },
303+
{ name: 'US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER' },
304304
],
305305
},
306306
},
@@ -381,66 +381,6 @@ describe('Model Armor tests', () => {
381381
await deleteDlpTemplates();
382382
});
383383

384-
// =================== Floor Settings Tests ===================
385-
386-
// TODO(b/424365799): Enable below tests once the mentioned issue is resolved
387-
388-
it.skip('should get organization floor settings', () => {
389-
const getOrganizationFloorSettings = require('../snippets/getOrganizationFloorSettings');
390-
391-
const output = getOrganizationFloorSettings(organizationId).toString();
392-
393-
const expectedName = `organizations/${organizationId}/locations/global/floorSetting`;
394-
assert.match(output, new RegExp(expectedName.replace(/\//g, '\\/')));
395-
});
396-
397-
it.skip('should get folder floor settings', () => {
398-
const getFolderFloorSettings = require('../snippets/getFolderFloorSettings');
399-
400-
const output = getFolderFloorSettings(folderId).toString();
401-
402-
// Check for expected name format in output
403-
const expectedName = `folders/${folderId}/locations/global/floorSetting`;
404-
assert.match(output, new RegExp(expectedName.replace(/\//g, '\\/')));
405-
});
406-
407-
it.skip('should get project floor settings', () => {
408-
const getProjectFloorSettings = require('../snippets/getProjectFloorSettings');
409-
410-
const output = getProjectFloorSettings(projectId).toString();
411-
412-
// Check for expected name format in output
413-
const expectedName = `projects/${projectId}/locations/global/floorSetting`;
414-
assert.match(output, new RegExp(expectedName.replace(/\//g, '\\/')));
415-
});
416-
417-
it.skip('should update organization floor settings', () => {
418-
const updateOrganizationFloorSettings = require('../snippets/updateOrganizationFloorSettings');
419-
const output = updateOrganizationFloorSettings(organizationId).toString();
420-
// Check that the update was performed
421-
assert.match(output, /Updated organization floor settings/);
422-
// Check that the response contains enableFloorSettingEnforcement=true
423-
assert.match(output, /enableFloorSettingEnforcement:\s*true/);
424-
});
425-
426-
it.skip('should update folder floor settings', () => {
427-
const updateFolderFloorSettings = require('../snippets/updateFolderFloorSettings');
428-
const output = updateFolderFloorSettings(folderId).toString();
429-
// Check that the update was performed
430-
assert.match(output, /Updated folder floor settings/);
431-
// Check that the response contains enableFloorSettingEnforcement=true
432-
assert.match(output, /enableFloorSettingEnforcement:\s*true/);
433-
});
434-
435-
it.skip('should update project floor settings', () => {
436-
const updateProjectFloorSettings = require('../snippets/updateProjectFloorSettings');
437-
const output = updateProjectFloorSettings(projectId).toString();
438-
// Check that the update was performed
439-
assert.match(output, /Updated project floor settings/);
440-
// Check that the response contains enableFloorSettingEnforcement=true
441-
assert.match(output, /enableFloorSettingEnforcement:\s*true/);
442-
});
443-
444384
// =================== Template Creation Tests ===================
445385

446386
it('should create a basic template', async () => {
@@ -997,4 +937,57 @@ describe('Model Armor tests', () => {
997937
'NO_MATCH_FOUND'
998938
);
999939
});
940+
941+
// =================== Floor Settings Tests ===================
942+
943+
// TODO(b/424365799): Enable below tests once the mentioned issue is resolved
944+
945+
it.skip('should get organization floor settings', async () => {
946+
const getOrganizationFloorSettings = require('../snippets/getOrganizationFloorSettings');
947+
948+
const output = await getOrganizationFloorSettings.main(organizationId);
949+
950+
const expectedName = `organizations/${organizationId}/locations/global/floorSetting`;
951+
assert.equal(output.name, expectedName);
952+
});
953+
954+
it.skip('should get folder floor settings', async () => {
955+
const getFolderFloorSettings = require('../snippets/getFolderFloorSettings');
956+
957+
const output = await getFolderFloorSettings.main(folderId);
958+
959+
// Check for expected name format in output
960+
const expectedName = `folders/${folderId}/locations/global/floorSetting`;
961+
assert.equal(output.name, expectedName);
962+
});
963+
964+
it.skip('should get project floor settings', async () => {
965+
const getProjectFloorSettings = require('../snippets/getProjectFloorSettings');
966+
967+
const output = await getProjectFloorSettings.main(projectId)
968+
// Check for expected name format in output
969+
const expectedName = `projects/${projectId}/locations/global/floorSetting`;
970+
assert.equal(output.name, expectedName);
971+
});
972+
973+
it.skip('should update organization floor settings', async () => {
974+
const updateOrganizationFloorSettings = require('../snippets/updateOrganizationFloorSettings');
975+
const output = await updateOrganizationFloorSettings.main(organizationId);
976+
// Check that the enableFloorSettingEnforcement=true
977+
assert.equal(output.enableFloorSettingEnforcement, true);
978+
});
979+
980+
it.skip('should update folder floor settings', async () => {
981+
const updateFolderFloorSettings = require('../snippets/updateFolderFloorSettings');
982+
const output = await updateFolderFloorSettings.main(folderId);
983+
// Check that the enableFloorSettingEnforcement=true
984+
assert.equal(output.enableFloorSettingEnforcement, true);
985+
});
986+
987+
it.skip('should update project floor settings', async () => {
988+
const updateProjectFloorSettings = require('../snippets/updateProjectFloorSettings');
989+
const output = await updateProjectFloorSettings.main(projectId);
990+
// Check that the enableFloorSettingEnforcement=true
991+
assert.equal(output.enableFloorSettingEnforcement, true);
992+
});
1000993
});

0 commit comments

Comments
 (0)