From 040ade439d58d8029914015c49946b363546231d Mon Sep 17 00:00:00 2001 From: Mihir Vala Date: Thu, 12 Jun 2025 17:44:17 +0530 Subject: [PATCH 1/6] chore(modelarmor): added floor settings tests and marked as skip for now --- model-armor/test/modelarmor.test.js | 153 ++++++++++++++++++++++++++-- 1 file changed, 147 insertions(+), 6 deletions(-) diff --git a/model-armor/test/modelarmor.test.js b/model-armor/test/modelarmor.test.js index 2f813b1f4f..9f68665d26 100644 --- a/model-armor/test/modelarmor.test.js +++ b/model-armor/test/modelarmor.test.js @@ -14,19 +14,23 @@ 'use strict'; -const {assert} = require('chai'); -const {v4: uuidv4} = require('uuid'); -const {ModelArmorClient} = require('@google-cloud/modelarmor').v1; -const {DlpServiceClient} = require('@google-cloud/dlp'); +const { assert } = require('chai'); +const cp = require('child_process'); +const { v4: uuidv4 } = require('uuid'); +const { ModelArmorClient } = require('@google-cloud/modelarmor').v1; +const { DlpServiceClient } = require('@google-cloud/dlp'); let projectId; const locationId = process.env.GCLOUD_LOCATION || 'us-central1'; +const folderId = process.env.MA_FOLDER_ID; +const organizationId = process.env.MA_ORG_ID; const options = { apiEndpoint: `modelarmor.${locationId}.rep.googleapis.com`, }; const client = new ModelArmorClient(options); const templateIdPrefix = `test-template-${uuidv4().substring(0, 8)}`; +const execSync = cmd => cp.execSync(cmd, { encoding: 'utf-8' }); let emptyTemplateId; let basicTemplateId; @@ -75,6 +79,79 @@ async function deleteTemplate(templateName) { } } +async function disableFloorSettings() { + try { + // Disable project floor settings + const [projectFloorSettings] = await client.getFloorSetting({ + name: `projects/${projectId}/locations/global/floorSetting`, + }); + + if (projectFloorSettings.enableFloorSettingEnforcement) { + const [updatedProjectSettings] = await client.updateFloorSetting({ + floorSetting: { + name: `projects/${projectId}/locations/global/floorSetting`, + enableFloorSettingEnforcement: false, + }, + updateMask: { + paths: ['enable_floor_setting_enforcement'], + }, + }); + console.log( + 'Disabled project floor settings:', + updatedProjectSettings.name + ); + } + + // Disable folder floor settings if folderId is available + if (folderId) { + const [folderFloorSettings] = await client.getFloorSetting({ + name: `folders/${folderId}/locations/global/floorSetting`, + }); + + if (folderFloorSettings.enableFloorSettingEnforcement) { + const [updatedFolderSettings] = await client.updateFloorSetting({ + floorSetting: { + name: `folders/${folderId}/locations/global/floorSetting`, + enableFloorSettingEnforcement: false, + }, + updateMask: { + paths: ['enable_floor_setting_enforcement'], + }, + }); + console.log( + 'Disabled folder floor settings:', + updatedFolderSettings.name + ); + } + } + + // Disable organization floor settings if organizationId is available + if (organizationId) { + const [orgFloorSettings] = await client.getFloorSetting({ + name: `organizations/${organizationId}/locations/global/floorSetting`, + }); + + if (orgFloorSettings.enableFloorSettingEnforcement) { + const [updatedOrgSettings] = await client.updateFloorSetting({ + floorSetting: { + name: `organizations/${organizationId}/locations/global/floorSetting`, + enableFloorSettingEnforcement: false, + }, + updateMask: { + paths: ['enable_floor_setting_enforcement'], + }, + }); + console.log( + 'Disabled organization floor settings:', + updatedOrgSettings.name + ); + } + } + } catch (error) { + console.error('Error disabling floor settings:', error); + } +} + // Helper function to create DLP template. async function createDlpTemplates() { try { @@ -292,6 +369,12 @@ describe('Model Armor tests', () => { after(async () => { for (const templateName of templatesToDelete) { + + // TODO: Enable clean up once tests are enabled. + // Disable floor settings to restore original state + // await disableFloorSettings(); + + await deleteTemplate(templateName); } @@ -300,7 +383,65 @@ describe('Model Armor tests', () => { // =================== Floor Settings Tests =================== - // TODO: Add tests for floor settings once the floor setting API issues are resolved. + // TODO: Enable these tests once floor settings API issue is resolved. + + it.skip('should get organization floor settings', () => { + const output = execSync( + `node snippets/getOrganizationFloorSettings.js ${organizationId}` + ).toString(); + const expectedName = `organizations/${organizationId}/locations/global/floorSetting`; + assert.match(output, new RegExp(expectedName.replace(/\//g, '\\/'))); + }); + + it.skip('should get folder floor settings', () => { + const output = execSync( + `node snippets/getFolderFloorSettings.js ${folderId}` + ).toString(); + + // Check for expected name format in output + const expectedName = `folders/${folderId}/locations/global/floorSetting`; + assert.match(output, new RegExp(expectedName.replace(/\//g, '\\/'))); + }); + + it.skip('should get project floor settings', () => { + const output = execSync( + `node snippets/getProjectFloorSettings.js ${projectId}` + ).toString(); + + // Check for expected name format in output + const expectedName = `projects/${projectId}/locations/global/floorSetting`; + assert.match(output, new RegExp(expectedName.replace(/\//g, '\\/'))); + }); + + it.skip('should update organization floor settings', () => { + const output = execSync( + `node snippets/updateOrganizationFloorSettings.js ${organizationId}` + ).toString(); + // Check that the update was performed + assert.match(output, /Updated organization floor settings/); + // Check that the response contains enableFloorSettingEnforcement=true + assert.match(output, /enableFloorSettingEnforcement:\s*true/); + }); + + it.skip('should update folder floor settings', () => { + const output = execSync( + `node snippets/updateFolderFloorSettings.js ${folderId}` + ).toString(); + // Check that the update was performed + assert.match(output, /Updated folder floor settings/); + // Check that the response contains enableFloorSettingEnforcement=true + assert.match(output, /enableFloorSettingEnforcement:\s*true/); + }); + + it.skip('should update project floor settings', () => { + const output = execSync( + `node snippets/updateProjectFloorSettings.js ${projectId}` + ).toString(); + // Check that the update was performed + assert.match(output, /Updated project floor settings/); + // Check that the response contains enableFloorSettingEnforcement=true + assert.match(output, /enableFloorSettingEnforcement:\s*true/); + }); // =================== Template Creation Tests =================== @@ -858,4 +999,4 @@ describe('Model Armor tests', () => { 'NO_MATCH_FOUND' ); }); -}); +}); \ No newline at end of file From 29e6cdf073a74b1bcc6cca341728a2c6bed9a566 Mon Sep 17 00:00:00 2001 From: Mihir Vala Date: Fri, 13 Jun 2025 16:33:21 +0530 Subject: [PATCH 2/6] chore(modelarmor): fixed floorsetting clean up and refactoring of tests --- .../snippets/getFolderFloorSettings.js | 12 ++++ .../snippets/getOrganizationFloorSettings.js | 12 ++++ .../snippets/getProjectFloorSettings.js | 12 ++++ .../snippets/updateFolderFloorSettings.js | 12 ++++ .../updateOrganizationFloorSettings.js | 12 ++++ .../snippets/updateProjectFloorSettings.js | 12 ++++ model-armor/test/modelarmor.test.js | 68 +++++++++---------- 7 files changed, 105 insertions(+), 35 deletions(-) diff --git a/model-armor/snippets/getFolderFloorSettings.js b/model-armor/snippets/getFolderFloorSettings.js index bacb9570de..3646559557 100644 --- a/model-armor/snippets/getFolderFloorSettings.js +++ b/model-armor/snippets/getFolderFloorSettings.js @@ -45,3 +45,15 @@ async function getFolderFloorSettings(folderId) { } module.exports = getFolderFloorSettings; + +/* c8 ignore next 10 */ +if (require.main === module) { + main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); + process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; + }); +} diff --git a/model-armor/snippets/getOrganizationFloorSettings.js b/model-armor/snippets/getOrganizationFloorSettings.js index 10a0186777..3f25ed4be0 100644 --- a/model-armor/snippets/getOrganizationFloorSettings.js +++ b/model-armor/snippets/getOrganizationFloorSettings.js @@ -47,3 +47,15 @@ async function getOrganizationFloorSettings(organizationId) { } module.exports = getOrganizationFloorSettings; + +/* c8 ignore next 10 */ +if (require.main === module) { + main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); + process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; + }); +} \ No newline at end of file diff --git a/model-armor/snippets/getProjectFloorSettings.js b/model-armor/snippets/getProjectFloorSettings.js index 9a37d96a6c..0b40cdb667 100644 --- a/model-armor/snippets/getProjectFloorSettings.js +++ b/model-armor/snippets/getProjectFloorSettings.js @@ -47,3 +47,15 @@ async function getProjectFloorSettings(projectId) { } module.exports = getProjectFloorSettings; + +/* c8 ignore next 10 */ +if (require.main === module) { + main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); + process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; + }); +} \ No newline at end of file diff --git a/model-armor/snippets/updateFolderFloorSettings.js b/model-armor/snippets/updateFolderFloorSettings.js index 1b59c6562f..4c48682b8c 100644 --- a/model-armor/snippets/updateFolderFloorSettings.js +++ b/model-armor/snippets/updateFolderFloorSettings.js @@ -73,3 +73,15 @@ async function updateFolderFloorSettings(folderId) { } module.exports = updateFolderFloorSettings; + +/* c8 ignore next 10 */ +if (require.main === module) { + main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); + process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; + }); +} diff --git a/model-armor/snippets/updateOrganizationFloorSettings.js b/model-armor/snippets/updateOrganizationFloorSettings.js index f4ce121394..099b1c5c2e 100644 --- a/model-armor/snippets/updateOrganizationFloorSettings.js +++ b/model-armor/snippets/updateOrganizationFloorSettings.js @@ -71,3 +71,15 @@ async function updateOrganizationFloorSettings(organizationId) { } module.exports = updateOrganizationFloorSettings; + +/* c8 ignore next 10 */ +if (require.main === module) { + main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); + process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; + }); +} \ No newline at end of file diff --git a/model-armor/snippets/updateProjectFloorSettings.js b/model-armor/snippets/updateProjectFloorSettings.js index c740836553..5de0294dff 100644 --- a/model-armor/snippets/updateProjectFloorSettings.js +++ b/model-armor/snippets/updateProjectFloorSettings.js @@ -71,3 +71,15 @@ async function updateProjectFloorSettings(projectId) { } module.exports = updateProjectFloorSettings; + +/* c8 ignore next 10 */ +if (require.main === module) { + main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); + process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; + }); +} \ No newline at end of file diff --git a/model-armor/test/modelarmor.test.js b/model-armor/test/modelarmor.test.js index 9f68665d26..de49eb5f6c 100644 --- a/model-armor/test/modelarmor.test.js +++ b/model-armor/test/modelarmor.test.js @@ -14,11 +14,10 @@ 'use strict'; -const { assert } = require('chai'); -const cp = require('child_process'); -const { v4: uuidv4 } = require('uuid'); -const { ModelArmorClient } = require('@google-cloud/modelarmor').v1; -const { DlpServiceClient } = require('@google-cloud/dlp'); +const {assert} = require('chai'); +const {v4: uuidv4} = require('uuid'); +const {ModelArmorClient} = require('@google-cloud/modelarmor').v1; +const {DlpServiceClient} = require('@google-cloud/dlp'); let projectId; const locationId = process.env.GCLOUD_LOCATION || 'us-central1'; @@ -30,7 +29,6 @@ const options = { const client = new ModelArmorClient(options); const templateIdPrefix = `test-template-${uuidv4().substring(0, 8)}`; -const execSync = cmd => cp.execSync(cmd, { encoding: 'utf-8' }); let emptyTemplateId; let basicTemplateId; @@ -79,15 +77,19 @@ async function deleteTemplate(templateName) { } } +// eslint-disable-next-line no-unused-vars async function disableFloorSettings() { try { + // Create global client + const global_client = new ModelArmorClient(); + // Disable project floor settings - const [projectFloorSettings] = await client.getFloorSetting({ + const [projectFloorSettings] = await global_client.getFloorSetting({ name: `projects/${projectId}/locations/global/floorSetting`, }); if (projectFloorSettings.enableFloorSettingEnforcement) { - const [updatedProjectSettings] = await client.updateFloorSetting({ + const [updatedProjectSettings] = await global_client.updateFloorSetting({ floorSetting: { name: `projects/${projectId}/locations/global/floorSetting`, enableFloorSettingEnforcement: false, @@ -104,12 +106,12 @@ async function disableFloorSettings() { // Disable folder floor settings if folderId is available if (folderId) { - const [folderFloorSettings] = await client.getFloorSetting({ + const [folderFloorSettings] = await global_client.getFloorSetting({ name: `folders/${folderId}/locations/global/floorSetting`, }); if (folderFloorSettings.enableFloorSettingEnforcement) { - const [updatedFolderSettings] = await client.updateFloorSetting({ + const [updatedFolderSettings] = await global_client.updateFloorSetting({ floorSetting: { name: `folders/${folderId}/locations/global/floorSetting`, enableFloorSettingEnforcement: false, @@ -127,12 +129,12 @@ async function disableFloorSettings() { // Disable organization floor settings if organizationId is available if (organizationId) { - const [orgFloorSettings] = await client.getFloorSetting({ + const [orgFloorSettings] = await global_client.getFloorSetting({ name: `organizations/${organizationId}/locations/global/floorSetting`, }); if (orgFloorSettings.enableFloorSettingEnforcement) { - const [updatedOrgSettings] = await client.updateFloorSetting({ + const [updatedOrgSettings] = await global_client.updateFloorSetting({ floorSetting: { name: `organizations/${organizationId}/locations/global/floorSetting`, enableFloorSettingEnforcement: false, @@ -369,12 +371,10 @@ describe('Model Armor tests', () => { after(async () => { for (const templateName of templatesToDelete) { - - // TODO: Enable clean up once tests are enabled. + // TODO(b/424365799): Uncomment below code once the mentioned issue is resolved // Disable floor settings to restore original state // await disableFloorSettings(); - await deleteTemplate(templateName); } @@ -383,20 +383,21 @@ describe('Model Armor tests', () => { // =================== Floor Settings Tests =================== - // TODO: Enable these tests once floor settings API issue is resolved. + // TODO(b/424365799): Enable below tests once the mentioned issue is resolved it.skip('should get organization floor settings', () => { - const output = execSync( - `node snippets/getOrganizationFloorSettings.js ${organizationId}` - ).toString(); + const getOrganizationFloorSettings = require('../snippets/getOrganizationFloorSettings'); + + const output = getOrganizationFloorSettings(organizationId).toString(); + const expectedName = `organizations/${organizationId}/locations/global/floorSetting`; assert.match(output, new RegExp(expectedName.replace(/\//g, '\\/'))); }); it.skip('should get folder floor settings', () => { - const output = execSync( - `node snippets/getFolderFloorSettings.js ${folderId}` - ).toString(); + const getFolderFloorSettings = require('../snippets/getFolderFloorSettings'); + + const output = getFolderFloorSettings(folderId).toString(); // Check for expected name format in output const expectedName = `folders/${folderId}/locations/global/floorSetting`; @@ -404,9 +405,9 @@ describe('Model Armor tests', () => { }); it.skip('should get project floor settings', () => { - const output = execSync( - `node snippets/getProjectFloorSettings.js ${projectId}` - ).toString(); + const getProjectFloorSettings = require('../snippets/getProjectFloorSettings'); + + const output = getProjectFloorSettings(projectId).toString(); // Check for expected name format in output const expectedName = `projects/${projectId}/locations/global/floorSetting`; @@ -414,9 +415,8 @@ describe('Model Armor tests', () => { }); it.skip('should update organization floor settings', () => { - const output = execSync( - `node snippets/updateOrganizationFloorSettings.js ${organizationId}` - ).toString(); + const updateOrganizationFloorSettings = require('../snippets/updateOrganizationFloorSettings'); + const output = updateOrganizationFloorSettings(organizationId).toString(); // Check that the update was performed assert.match(output, /Updated organization floor settings/); // Check that the response contains enableFloorSettingEnforcement=true @@ -424,9 +424,8 @@ describe('Model Armor tests', () => { }); it.skip('should update folder floor settings', () => { - const output = execSync( - `node snippets/updateFolderFloorSettings.js ${folderId}` - ).toString(); + const updateFolderFloorSettings = require('../snippets/updateFolderFloorSettings'); + const output = updateFolderFloorSettings(folderId).toString(); // Check that the update was performed assert.match(output, /Updated folder floor settings/); // Check that the response contains enableFloorSettingEnforcement=true @@ -434,9 +433,8 @@ describe('Model Armor tests', () => { }); it.skip('should update project floor settings', () => { - const output = execSync( - `node snippets/updateProjectFloorSettings.js ${projectId}` - ).toString(); + const updateProjectFloorSettings = require('../snippets/updateProjectFloorSettings'); + const output = updateProjectFloorSettings(projectId).toString(); // Check that the update was performed assert.match(output, /Updated project floor settings/); // Check that the response contains enableFloorSettingEnforcement=true @@ -999,4 +997,4 @@ describe('Model Armor tests', () => { 'NO_MATCH_FOUND' ); }); -}); \ No newline at end of file +}); From 664fd3e8972a9f4574468cadf5a3f19305d41ac0 Mon Sep 17 00:00:00 2001 From: Mihir Vala Date: Fri, 13 Jun 2025 17:17:45 +0530 Subject: [PATCH 3/6] chore(modelarmor): refactored floor settings snippets --- .../snippets/getFolderFloorSettings.js | 23 +++--- .../snippets/getOrganizationFloorSettings.js | 26 ++++--- .../snippets/getProjectFloorSettings.js | 24 +++--- .../snippets/updateFolderFloorSettings.js | 76 ++++++++++--------- .../updateOrganizationFloorSettings.js | 76 ++++++++++--------- .../snippets/updateProjectFloorSettings.js | 76 ++++++++++--------- 6 files changed, 166 insertions(+), 135 deletions(-) diff --git a/model-armor/snippets/getFolderFloorSettings.js b/model-armor/snippets/getFolderFloorSettings.js index 3646559557..8fe790a68d 100644 --- a/model-armor/snippets/getFolderFloorSettings.js +++ b/model-armor/snippets/getFolderFloorSettings.js @@ -19,7 +19,7 @@ * * @param {string} folderId - The ID of the Google Cloud folder for which to retrieve floor settings. */ -async function getFolderFloorSettings(folderId) { +async function main(folderId) { // [START modelarmor_get_folder_floor_settings] /** * TODO(developer): Uncomment these variables before running the sample. @@ -29,22 +29,27 @@ async function getFolderFloorSettings(folderId) { const name = `folders/${folderId}/locations/global/floorSetting`; // Imports the Modelarmor library - const {ModelArmorClient} = require('@google-cloud/modelarmor').v1; + const { ModelArmorClient } = require('@google-cloud/modelarmor').v1; // Instantiates a client const modelarmorClient = new ModelArmorClient(); - // Construct request - const request = { - name, - }; + async function getFolderFloorSettings() { + // Construct request + const request = { + name, + }; - const [response] = await modelarmorClient.getFloorSetting(request); - return response; + const [response] = await modelarmorClient.getFloorSetting(request); + return response; + + } + + return await getFolderFloorSettings(); // [END modelarmor_get_folder_floor_settings] } -module.exports = getFolderFloorSettings; +module.exports.main = main; /* c8 ignore next 10 */ if (require.main === module) { diff --git a/model-armor/snippets/getOrganizationFloorSettings.js b/model-armor/snippets/getOrganizationFloorSettings.js index 3f25ed4be0..6b31f30510 100644 --- a/model-armor/snippets/getOrganizationFloorSettings.js +++ b/model-armor/snippets/getOrganizationFloorSettings.js @@ -20,33 +20,37 @@ * @param {string} organizationId - The ID of the Google Cloud organization for which to retrieve * floor settings. */ -async function getOrganizationFloorSettings(organizationId) { +async function main(organizationId) { // [START modelarmor_get_organization_floor_settings] /** * TODO(developer): Uncomment these variables before running the sample. */ // const organizationId = 'your-organization-id'; - const name = `organizations/${organizationId}/locations/global/floorSetting`; // Imports the Modelarmor library - const {ModelArmorClient} = require('@google-cloud/modelarmor').v1; + const { ModelArmorClient } = require('@google-cloud/modelarmor').v1; // Instantiates a client const modelarmorClient = new ModelArmorClient(); - // Construct request - const request = { - name, - }; + async function getOrganizationFloorSettings() { + // Construct request + const request = { + name, + }; + + // Run request + const [response] = await modelarmorClient.getFloorSetting(request); + return response; + + } - // Run request - const [response] = await modelarmorClient.getFloorSetting(request); - return response; + return await getOrganizationFloorSettings(); // [END modelarmor_get_organization_floor_settings] } -module.exports = getOrganizationFloorSettings; +module.exports.main = main; /* c8 ignore next 10 */ if (require.main === module) { diff --git a/model-armor/snippets/getProjectFloorSettings.js b/model-armor/snippets/getProjectFloorSettings.js index 0b40cdb667..638df78dfa 100644 --- a/model-armor/snippets/getProjectFloorSettings.js +++ b/model-armor/snippets/getProjectFloorSettings.js @@ -20,7 +20,7 @@ * @param {string} projectId - The ID of the Google Cloud project for which to retrieve * floor settings. */ -async function getProjectFloorSettings(projectId) { +async function main(projectId) { // [START modelarmor_get_project_floor_settings] /** * TODO(developer): Uncomment these variables before running the sample. @@ -30,23 +30,27 @@ async function getProjectFloorSettings(projectId) { const name = `projects/${projectId}/locations/global/floorSetting`; // Imports the Modelarmor library - const {ModelArmorClient} = require('@google-cloud/modelarmor').v1; + const { ModelArmorClient } = require('@google-cloud/modelarmor').v1; // Instantiates a client const modelarmorClient = new ModelArmorClient(); - // Construct request - const request = { - name, - }; + async function getProjectFloorSettings() { + // Construct request + const request = { + name, + }; - // Run request - const [response] = await modelarmorClient.getFloorSetting(request); - return response; + // Run request + const [response] = await modelarmorClient.getFloorSetting(request); + return response; + } + + return await getProjectFloorSettings(); // [END modelarmor_get_project_floor_settings] } -module.exports = getProjectFloorSettings; +module.exports.main = main; /* c8 ignore next 10 */ if (require.main === module) { diff --git a/model-armor/snippets/updateFolderFloorSettings.js b/model-armor/snippets/updateFolderFloorSettings.js index 4c48682b8c..f66f7d6803 100644 --- a/model-armor/snippets/updateFolderFloorSettings.js +++ b/model-armor/snippets/updateFolderFloorSettings.js @@ -19,7 +19,7 @@ * * @param {string} folderId - Google Cloud folder ID for which floor settings need to be updated. */ -async function updateFolderFloorSettings(folderId) { +async function main(folderId) { // [START modelarmor_update_folder_floor_settings] /** * TODO(developer): Uncomment these variables before running the sample. @@ -28,51 +28,57 @@ async function updateFolderFloorSettings(folderId) { // Imports the Model Armor library const modelarmor = require('@google-cloud/modelarmor'); - const {ModelArmorClient} = modelarmor.v1; - const {protos} = modelarmor; + const { ModelArmorClient } = modelarmor.v1; + const { protos } = modelarmor; // Instantiates a client const client = new ModelArmorClient(); - const floorSettingsName = `folders/${folderId}/locations/global/floorSetting`; + async function updateFolderFloorSettings() { - // Build the floor settings with your preferred filters - // For more details on filters, please refer to the following doc: - // https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters - const floorSetting = { - name: floorSettingsName, - filterConfig: { - raiSettings: { - raiFilters: [ - { - filterType: - protos.google.cloud.modelarmor.v1.RaiFilterType.HARASSMENT, - confidenceLevel: - protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel - .LOW_AND_ABOVE, - }, - { - filterType: - protos.google.cloud.modelarmor.v1.RaiFilterType.SEXUALLY_EXPLICIT, - confidenceLevel: - protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel.HIGH, - }, - ], + const floorSettingsName = `folders/${folderId}/locations/global/floorSetting`; + + // Build the floor settings with your preferred filters + // For more details on filters, please refer to the following doc: + // https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters + const floorSetting = { + name: floorSettingsName, + filterConfig: { + raiSettings: { + raiFilters: [ + { + filterType: + protos.google.cloud.modelarmor.v1.RaiFilterType.HARASSMENT, + confidenceLevel: + protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel + .LOW_AND_ABOVE, + }, + { + filterType: + protos.google.cloud.modelarmor.v1.RaiFilterType.SEXUALLY_EXPLICIT, + confidenceLevel: + protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel.HIGH, + }, + ], + }, }, - }, - enableFloorSettingEnforcement: true, - }; + enableFloorSettingEnforcement: true, + }; + + const request = { + floorSetting: floorSetting, + }; + + const [response] = await client.updateFloorSetting(request); + return response; - const request = { - floorSetting: floorSetting, - }; + } - const [response] = await client.updateFloorSetting(request); - return response; + return await updateFolderFloorSettings(); // [END modelarmor_update_folder_floor_settings] } -module.exports = updateFolderFloorSettings; +module.exports.main = main; /* c8 ignore next 10 */ if (require.main === module) { diff --git a/model-armor/snippets/updateOrganizationFloorSettings.js b/model-armor/snippets/updateOrganizationFloorSettings.js index 099b1c5c2e..e4c803afb1 100644 --- a/model-armor/snippets/updateOrganizationFloorSettings.js +++ b/model-armor/snippets/updateOrganizationFloorSettings.js @@ -19,7 +19,8 @@ * * @param {string} organizationId - Google Cloud organization ID for which floor settings need to be updated. */ -async function updateOrganizationFloorSettings(organizationId) { +async function main(organizationId) { + // [START modelarmor_update_organization_floor_settings] /** * TODO(developer): Uncomment these variables before running the sample. @@ -27,50 +28,55 @@ async function updateOrganizationFloorSettings(organizationId) { // const organizationId = 'your-organization-id'; const modelarmor = require('@google-cloud/modelarmor'); - const {ModelArmorClient} = modelarmor.v1; - const {protos} = modelarmor; + const { ModelArmorClient } = modelarmor.v1; + const { protos } = modelarmor; const client = new ModelArmorClient(); - const floorSettingsName = `organizations/${organizationId}/locations/global/floorSetting`; + async function updateOrganizationFloorSettings() { + + const floorSettingsName = `organizations/${organizationId}/locations/global/floorSetting`; - // Build the floor settings with your preferred filters - // For more details on filters, please refer to the following doc: - // https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters - const floorSetting = { - name: floorSettingsName, - filterConfig: { - raiSettings: { - raiFilters: [ - { - filterType: - protos.google.cloud.modelarmor.v1.RaiFilterType.HARASSMENT, - confidenceLevel: - protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel - .LOW_AND_ABOVE, - }, - { - filterType: - protos.google.cloud.modelarmor.v1.RaiFilterType.SEXUALLY_EXPLICIT, - confidenceLevel: - protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel.HIGH, - }, - ], + // Build the floor settings with your preferred filters + // For more details on filters, please refer to the following doc: + // https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters + const floorSetting = { + name: floorSettingsName, + filterConfig: { + raiSettings: { + raiFilters: [ + { + filterType: + protos.google.cloud.modelarmor.v1.RaiFilterType.HARASSMENT, + confidenceLevel: + protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel + .LOW_AND_ABOVE, + }, + { + filterType: + protos.google.cloud.modelarmor.v1.RaiFilterType.SEXUALLY_EXPLICIT, + confidenceLevel: + protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel.HIGH, + }, + ], + }, }, - }, - enableFloorSettingEnforcement: true, - }; + enableFloorSettingEnforcement: true, + }; + + const request = { + floorSetting: floorSetting, + }; - const request = { - floorSetting: floorSetting, - }; + const [response] = await client.updateFloorSetting(request); + return response; + } - const [response] = await client.updateFloorSetting(request); - return response; + return await updateOrganizationFloorSettings(); // [END modelarmor_update_organization_floor_settings] } -module.exports = updateOrganizationFloorSettings; +module.exports.main = main; /* c8 ignore next 10 */ if (require.main === module) { diff --git a/model-armor/snippets/updateProjectFloorSettings.js b/model-armor/snippets/updateProjectFloorSettings.js index 5de0294dff..71ab7b1900 100644 --- a/model-armor/snippets/updateProjectFloorSettings.js +++ b/model-armor/snippets/updateProjectFloorSettings.js @@ -19,7 +19,7 @@ * * @param {string} projectId - Google Cloud project ID for which floor settings need to be updated. */ -async function updateProjectFloorSettings(projectId) { +async function main(projectId) { // [START modelarmor_update_project_floor_settings] /** * TODO(developer): Uncomment these variables before running the sample. @@ -27,50 +27,56 @@ async function updateProjectFloorSettings(projectId) { // const projectId = 'your-project-id'; const modelarmor = require('@google-cloud/modelarmor'); - const {ModelArmorClient} = modelarmor.v1; - const {protos} = modelarmor; + const { ModelArmorClient } = modelarmor.v1; + const { protos } = modelarmor; + // Initiate client const client = new ModelArmorClient(); - const floorSettingsName = `projects/${projectId}/locations/global/floorSetting`; + async function updateProjectFloorSettings() { - // Build the floor settings with your preferred filters - // For more details on filters, please refer to the following doc: - // https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters - const floorSetting = { - name: floorSettingsName, - filterConfig: { - raiSettings: { - raiFilters: [ - { - filterType: - protos.google.cloud.modelarmor.v1.RaiFilterType.HARASSMENT, - confidenceLevel: - protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel - .LOW_AND_ABOVE, - }, - { - filterType: + const floorSettingsName = `projects/${projectId}/locations/global/floorSetting`; + + // Build the floor settings with your preferred filters + // For more details on filters, please refer to the following doc: + // https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters + const floorSetting = { + name: floorSettingsName, + filterConfig: { + raiSettings: { + raiFilters: [ + { + filterType: + protos.google.cloud.modelarmor.v1.RaiFilterType.HARASSMENT, + confidenceLevel: + protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel + .LOW_AND_ABOVE, + }, + { + filterType: protos.google.cloud.modelarmor.v1.RaiFilterType.SEXUALLY_EXPLICIT, - confidenceLevel: - protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel.HIGH, - }, - ], + confidenceLevel: + protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel.HIGH, + }, + ], + }, }, - }, - enableFloorSettingEnforcement: true, - }; + enableFloorSettingEnforcement: true, + }; + + const request = { + floorSetting: floorSetting, + }; - const request = { - floorSetting: floorSetting, - }; + const [response] = await client.updateFloorSetting(request); + return response; + } - const [response] = await client.updateFloorSetting(request); - return response; + return await updateProjectFloorSettings(); // [END modelarmor_update_project_floor_settings] } -module.exports = updateProjectFloorSettings; +module.exports.main = main; /* c8 ignore next 10 */ if (require.main === module) { @@ -82,4 +88,4 @@ if (require.main === module) { console.error(err.message); process.exitCode = 1; }); -} \ No newline at end of file +} \ No newline at end of file From 5b8709095878fcba74908a9dc4619234d7bd7be4 Mon Sep 17 00:00:00 2001 From: Mihir Vala Date: Fri, 13 Jun 2025 17:18:59 +0530 Subject: [PATCH 4/6] chore(modelarmor): fixed linting for floorsettings snippets --- model-armor/snippets/getFolderFloorSettings.js | 5 ++--- model-armor/snippets/getOrganizationFloorSettings.js | 5 ++--- model-armor/snippets/getProjectFloorSettings.js | 4 ++-- model-armor/snippets/updateFolderFloorSettings.js | 11 +++++------ .../snippets/updateOrganizationFloorSettings.js | 11 +++++------ model-armor/snippets/updateProjectFloorSettings.js | 10 +++++----- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/model-armor/snippets/getFolderFloorSettings.js b/model-armor/snippets/getFolderFloorSettings.js index 8fe790a68d..6e66376d2c 100644 --- a/model-armor/snippets/getFolderFloorSettings.js +++ b/model-armor/snippets/getFolderFloorSettings.js @@ -29,7 +29,7 @@ async function main(folderId) { const name = `folders/${folderId}/locations/global/floorSetting`; // Imports the Modelarmor library - const { ModelArmorClient } = require('@google-cloud/modelarmor').v1; + const {ModelArmorClient} = require('@google-cloud/modelarmor').v1; // Instantiates a client const modelarmorClient = new ModelArmorClient(); @@ -42,7 +42,6 @@ async function main(folderId) { const [response] = await modelarmorClient.getFloorSetting(request); return response; - } return await getFolderFloorSettings(); @@ -61,4 +60,4 @@ if (require.main === module) { console.error(err.message); process.exitCode = 1; }); -} +} diff --git a/model-armor/snippets/getOrganizationFloorSettings.js b/model-armor/snippets/getOrganizationFloorSettings.js index 6b31f30510..016f82e03a 100644 --- a/model-armor/snippets/getOrganizationFloorSettings.js +++ b/model-armor/snippets/getOrganizationFloorSettings.js @@ -29,7 +29,7 @@ async function main(organizationId) { const name = `organizations/${organizationId}/locations/global/floorSetting`; // Imports the Modelarmor library - const { ModelArmorClient } = require('@google-cloud/modelarmor').v1; + const {ModelArmorClient} = require('@google-cloud/modelarmor').v1; // Instantiates a client const modelarmorClient = new ModelArmorClient(); @@ -43,7 +43,6 @@ async function main(organizationId) { // Run request const [response] = await modelarmorClient.getFloorSetting(request); return response; - } return await getOrganizationFloorSettings(); @@ -62,4 +61,4 @@ if (require.main === module) { console.error(err.message); process.exitCode = 1; }); -} \ No newline at end of file +} diff --git a/model-armor/snippets/getProjectFloorSettings.js b/model-armor/snippets/getProjectFloorSettings.js index 638df78dfa..2b6b0bf23f 100644 --- a/model-armor/snippets/getProjectFloorSettings.js +++ b/model-armor/snippets/getProjectFloorSettings.js @@ -30,7 +30,7 @@ async function main(projectId) { const name = `projects/${projectId}/locations/global/floorSetting`; // Imports the Modelarmor library - const { ModelArmorClient } = require('@google-cloud/modelarmor').v1; + const {ModelArmorClient} = require('@google-cloud/modelarmor').v1; // Instantiates a client const modelarmorClient = new ModelArmorClient(); @@ -62,4 +62,4 @@ if (require.main === module) { console.error(err.message); process.exitCode = 1; }); -} \ No newline at end of file +} diff --git a/model-armor/snippets/updateFolderFloorSettings.js b/model-armor/snippets/updateFolderFloorSettings.js index f66f7d6803..d34415b67d 100644 --- a/model-armor/snippets/updateFolderFloorSettings.js +++ b/model-armor/snippets/updateFolderFloorSettings.js @@ -28,14 +28,13 @@ async function main(folderId) { // Imports the Model Armor library const modelarmor = require('@google-cloud/modelarmor'); - const { ModelArmorClient } = modelarmor.v1; - const { protos } = modelarmor; + const {ModelArmorClient} = modelarmor.v1; + const {protos} = modelarmor; // Instantiates a client const client = new ModelArmorClient(); async function updateFolderFloorSettings() { - const floorSettingsName = `folders/${folderId}/locations/global/floorSetting`; // Build the floor settings with your preferred filters @@ -55,7 +54,8 @@ async function main(folderId) { }, { filterType: - protos.google.cloud.modelarmor.v1.RaiFilterType.SEXUALLY_EXPLICIT, + protos.google.cloud.modelarmor.v1.RaiFilterType + .SEXUALLY_EXPLICIT, confidenceLevel: protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel.HIGH, }, @@ -71,7 +71,6 @@ async function main(folderId) { const [response] = await client.updateFloorSetting(request); return response; - } return await updateFolderFloorSettings(); @@ -90,4 +89,4 @@ if (require.main === module) { console.error(err.message); process.exitCode = 1; }); -} +} diff --git a/model-armor/snippets/updateOrganizationFloorSettings.js b/model-armor/snippets/updateOrganizationFloorSettings.js index e4c803afb1..d78ef47d0c 100644 --- a/model-armor/snippets/updateOrganizationFloorSettings.js +++ b/model-armor/snippets/updateOrganizationFloorSettings.js @@ -20,7 +20,6 @@ * @param {string} organizationId - Google Cloud organization ID for which floor settings need to be updated. */ async function main(organizationId) { - // [START modelarmor_update_organization_floor_settings] /** * TODO(developer): Uncomment these variables before running the sample. @@ -28,13 +27,12 @@ async function main(organizationId) { // const organizationId = 'your-organization-id'; const modelarmor = require('@google-cloud/modelarmor'); - const { ModelArmorClient } = modelarmor.v1; - const { protos } = modelarmor; + const {ModelArmorClient} = modelarmor.v1; + const {protos} = modelarmor; const client = new ModelArmorClient(); async function updateOrganizationFloorSettings() { - const floorSettingsName = `organizations/${organizationId}/locations/global/floorSetting`; // Build the floor settings with your preferred filters @@ -54,7 +52,8 @@ async function main(organizationId) { }, { filterType: - protos.google.cloud.modelarmor.v1.RaiFilterType.SEXUALLY_EXPLICIT, + protos.google.cloud.modelarmor.v1.RaiFilterType + .SEXUALLY_EXPLICIT, confidenceLevel: protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel.HIGH, }, @@ -88,4 +87,4 @@ if (require.main === module) { console.error(err.message); process.exitCode = 1; }); -} \ No newline at end of file +} diff --git a/model-armor/snippets/updateProjectFloorSettings.js b/model-armor/snippets/updateProjectFloorSettings.js index 71ab7b1900..73307187bb 100644 --- a/model-armor/snippets/updateProjectFloorSettings.js +++ b/model-armor/snippets/updateProjectFloorSettings.js @@ -27,14 +27,13 @@ async function main(projectId) { // const projectId = 'your-project-id'; const modelarmor = require('@google-cloud/modelarmor'); - const { ModelArmorClient } = modelarmor.v1; - const { protos } = modelarmor; + const {ModelArmorClient} = modelarmor.v1; + const {protos} = modelarmor; // Initiate client const client = new ModelArmorClient(); async function updateProjectFloorSettings() { - const floorSettingsName = `projects/${projectId}/locations/global/floorSetting`; // Build the floor settings with your preferred filters @@ -54,7 +53,8 @@ async function main(projectId) { }, { filterType: - protos.google.cloud.modelarmor.v1.RaiFilterType.SEXUALLY_EXPLICIT, + protos.google.cloud.modelarmor.v1.RaiFilterType + .SEXUALLY_EXPLICIT, confidenceLevel: protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel.HIGH, }, @@ -88,4 +88,4 @@ if (require.main === module) { console.error(err.message); process.exitCode = 1; }); -} \ No newline at end of file +} From ff148e0717a729578386e949b46effca03ebadf7 Mon Sep 17 00:00:00 2001 From: Mihir Vala Date: Fri, 13 Jun 2025 18:13:54 +0530 Subject: [PATCH 5/6] chore(modelarmor): Refactored tests assertion for floor settings tests --- model-armor/test/modelarmor.test.js | 135 +++++++++++++--------------- 1 file changed, 64 insertions(+), 71 deletions(-) diff --git a/model-armor/test/modelarmor.test.js b/model-armor/test/modelarmor.test.js index de49eb5f6c..1e694744fb 100644 --- a/model-armor/test/modelarmor.test.js +++ b/model-armor/test/modelarmor.test.js @@ -14,10 +14,10 @@ 'use strict'; -const {assert} = require('chai'); -const {v4: uuidv4} = require('uuid'); -const {ModelArmorClient} = require('@google-cloud/modelarmor').v1; -const {DlpServiceClient} = require('@google-cloud/dlp'); +const { assert } = require('chai'); +const { v4: uuidv4 } = require('uuid'); +const { ModelArmorClient } = require('@google-cloud/modelarmor').v1; +const { DlpServiceClient } = require('@google-cloud/dlp'); let projectId; const locationId = process.env.GCLOUD_LOCATION || 'us-central1'; @@ -173,9 +173,9 @@ async function createDlpTemplates() { inspectTemplate: { inspectConfig: { infoTypes: [ - {name: 'EMAIL_ADDRESS'}, - {name: 'PHONE_NUMBER'}, - {name: 'US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER'}, + { name: 'EMAIL_ADDRESS' }, + { name: 'PHONE_NUMBER' }, + { name: 'US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER' }, ], }, }, @@ -260,7 +260,7 @@ describe('Model Armor tests', () => { before(async () => { projectId = await client.getProjectId(); - const {protos} = require('@google-cloud/modelarmor'); + const { protos } = require('@google-cloud/modelarmor'); // Import necessary enums const DetectionConfidenceLevel = protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel; @@ -298,9 +298,9 @@ describe('Model Armor tests', () => { basicConfig: { filterEnforcement: SdpBasicConfigEnforcement.ENABLED, infoTypes: [ - {name: 'EMAIL_ADDRESS'}, - {name: 'PHONE_NUMBER'}, - {name: 'US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER'}, + { name: 'EMAIL_ADDRESS' }, + { name: 'PHONE_NUMBER' }, + { name: 'US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER' }, ], }, }, @@ -381,66 +381,6 @@ describe('Model Armor tests', () => { await deleteDlpTemplates(); }); - // =================== Floor Settings Tests =================== - - // TODO(b/424365799): Enable below tests once the mentioned issue is resolved - - it.skip('should get organization floor settings', () => { - const getOrganizationFloorSettings = require('../snippets/getOrganizationFloorSettings'); - - const output = getOrganizationFloorSettings(organizationId).toString(); - - const expectedName = `organizations/${organizationId}/locations/global/floorSetting`; - assert.match(output, new RegExp(expectedName.replace(/\//g, '\\/'))); - }); - - it.skip('should get folder floor settings', () => { - const getFolderFloorSettings = require('../snippets/getFolderFloorSettings'); - - const output = getFolderFloorSettings(folderId).toString(); - - // Check for expected name format in output - const expectedName = `folders/${folderId}/locations/global/floorSetting`; - assert.match(output, new RegExp(expectedName.replace(/\//g, '\\/'))); - }); - - it.skip('should get project floor settings', () => { - const getProjectFloorSettings = require('../snippets/getProjectFloorSettings'); - - const output = getProjectFloorSettings(projectId).toString(); - - // Check for expected name format in output - const expectedName = `projects/${projectId}/locations/global/floorSetting`; - assert.match(output, new RegExp(expectedName.replace(/\//g, '\\/'))); - }); - - it.skip('should update organization floor settings', () => { - const updateOrganizationFloorSettings = require('../snippets/updateOrganizationFloorSettings'); - const output = updateOrganizationFloorSettings(organizationId).toString(); - // Check that the update was performed - assert.match(output, /Updated organization floor settings/); - // Check that the response contains enableFloorSettingEnforcement=true - assert.match(output, /enableFloorSettingEnforcement:\s*true/); - }); - - it.skip('should update folder floor settings', () => { - const updateFolderFloorSettings = require('../snippets/updateFolderFloorSettings'); - const output = updateFolderFloorSettings(folderId).toString(); - // Check that the update was performed - assert.match(output, /Updated folder floor settings/); - // Check that the response contains enableFloorSettingEnforcement=true - assert.match(output, /enableFloorSettingEnforcement:\s*true/); - }); - - it.skip('should update project floor settings', () => { - const updateProjectFloorSettings = require('../snippets/updateProjectFloorSettings'); - const output = updateProjectFloorSettings(projectId).toString(); - // Check that the update was performed - assert.match(output, /Updated project floor settings/); - // Check that the response contains enableFloorSettingEnforcement=true - assert.match(output, /enableFloorSettingEnforcement:\s*true/); - }); - // =================== Template Creation Tests =================== it('should create a basic template', async () => { @@ -997,4 +937,57 @@ describe('Model Armor tests', () => { 'NO_MATCH_FOUND' ); }); + + // =================== Floor Settings Tests =================== + + // TODO(b/424365799): Enable below tests once the mentioned issue is resolved + + it.skip('should get organization floor settings', async () => { + const getOrganizationFloorSettings = require('../snippets/getOrganizationFloorSettings'); + + const output = await getOrganizationFloorSettings.main(organizationId); + + const expectedName = `organizations/${organizationId}/locations/global/floorSetting`; + assert.equal(output.name, expectedName); + }); + + it.skip('should get folder floor settings', async () => { + const getFolderFloorSettings = require('../snippets/getFolderFloorSettings'); + + const output = await getFolderFloorSettings.main(folderId); + + // Check for expected name format in output + const expectedName = `folders/${folderId}/locations/global/floorSetting`; + assert.equal(output.name, expectedName); + }); + + it.skip('should get project floor settings', async () => { + const getProjectFloorSettings = require('../snippets/getProjectFloorSettings'); + + const output = await getProjectFloorSettings.main(projectId) + // Check for expected name format in output + const expectedName = `projects/${projectId}/locations/global/floorSetting`; + assert.equal(output.name, expectedName); + }); + + it.skip('should update organization floor settings', async () => { + const updateOrganizationFloorSettings = require('../snippets/updateOrganizationFloorSettings'); + const output = await updateOrganizationFloorSettings.main(organizationId); + // Check that the enableFloorSettingEnforcement=true + assert.equal(output.enableFloorSettingEnforcement, true); + }); + + it.skip('should update folder floor settings', async () => { + const updateFolderFloorSettings = require('../snippets/updateFolderFloorSettings'); + const output = await updateFolderFloorSettings.main(folderId); + // Check that the enableFloorSettingEnforcement=true + assert.equal(output.enableFloorSettingEnforcement, true); + }); + + it.skip('should update project floor settings', async () => { + const updateProjectFloorSettings = require('../snippets/updateProjectFloorSettings'); + const output = await updateProjectFloorSettings.main(projectId); + // Check that the enableFloorSettingEnforcement=true + assert.equal(output.enableFloorSettingEnforcement, true); + }); }); From 567a1da2a822c3faf16cf25d77e26df1bc4b2862 Mon Sep 17 00:00:00 2001 From: Mihir Vala Date: Fri, 13 Jun 2025 18:14:59 +0530 Subject: [PATCH 6/6] chore(modelarmor): fixed linting --- model-armor/test/modelarmor.test.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/model-armor/test/modelarmor.test.js b/model-armor/test/modelarmor.test.js index 1e694744fb..1a176dab4f 100644 --- a/model-armor/test/modelarmor.test.js +++ b/model-armor/test/modelarmor.test.js @@ -14,10 +14,10 @@ 'use strict'; -const { assert } = require('chai'); -const { v4: uuidv4 } = require('uuid'); -const { ModelArmorClient } = require('@google-cloud/modelarmor').v1; -const { DlpServiceClient } = require('@google-cloud/dlp'); +const {assert} = require('chai'); +const {v4: uuidv4} = require('uuid'); +const {ModelArmorClient} = require('@google-cloud/modelarmor').v1; +const {DlpServiceClient} = require('@google-cloud/dlp'); let projectId; const locationId = process.env.GCLOUD_LOCATION || 'us-central1'; @@ -173,9 +173,9 @@ async function createDlpTemplates() { inspectTemplate: { inspectConfig: { infoTypes: [ - { name: 'EMAIL_ADDRESS' }, - { name: 'PHONE_NUMBER' }, - { name: 'US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER' }, + {name: 'EMAIL_ADDRESS'}, + {name: 'PHONE_NUMBER'}, + {name: 'US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER'}, ], }, }, @@ -260,7 +260,7 @@ describe('Model Armor tests', () => { before(async () => { projectId = await client.getProjectId(); - const { protos } = require('@google-cloud/modelarmor'); + const {protos} = require('@google-cloud/modelarmor'); // Import necessary enums const DetectionConfidenceLevel = protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel; @@ -298,9 +298,9 @@ describe('Model Armor tests', () => { basicConfig: { filterEnforcement: SdpBasicConfigEnforcement.ENABLED, infoTypes: [ - { name: 'EMAIL_ADDRESS' }, - { name: 'PHONE_NUMBER' }, - { name: 'US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER' }, + {name: 'EMAIL_ADDRESS'}, + {name: 'PHONE_NUMBER'}, + {name: 'US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER'}, ], }, }, @@ -964,7 +964,7 @@ describe('Model Armor tests', () => { it.skip('should get project floor settings', async () => { const getProjectFloorSettings = require('../snippets/getProjectFloorSettings'); - const output = await getProjectFloorSettings.main(projectId) + const output = await getProjectFloorSettings.main(projectId); // Check for expected name format in output const expectedName = `projects/${projectId}/locations/global/floorSetting`; assert.equal(output.name, expectedName);