@@ -75,6 +75,70 @@ async function deleteTemplate(templateName) {
7575 }
7676}
7777
78+ async function disableFloorSettings ( ) {
79+ try {
80+ // Disable project floor settings
81+ const [ projectFloorSettings ] = await client . getFloorSetting ( {
82+ name : `projects/${ projectId } /locations/global/floorSetting` ,
83+ } ) ;
84+
85+ if ( projectFloorSettings . enableFloorSettingEnforcement ) {
86+ const [ updatedProjectSettings ] = await client . updateFloorSetting ( {
87+ floorSetting : {
88+ name : `projects/${ projectId } /locations/global/floorSetting` ,
89+ enableFloorSettingEnforcement : false ,
90+ } ,
91+ updateMask : {
92+ paths : [ 'enable_floor_setting_enforcement' ] ,
93+ } ,
94+ } ) ;
95+ console . log ( 'Disabled project floor settings:' , updatedProjectSettings . name ) ;
96+ }
97+
98+ // Disable folder floor settings if folderId is available
99+ if ( folderId ) {
100+ const [ folderFloorSettings ] = await client . getFloorSetting ( {
101+ name : `folders/${ folderId } /locations/global/floorSetting` ,
102+ } ) ;
103+
104+ if ( folderFloorSettings . enableFloorSettingEnforcement ) {
105+ const [ updatedFolderSettings ] = await client . updateFloorSetting ( {
106+ floorSetting : {
107+ name : `folders/${ folderId } /locations/global/floorSetting` ,
108+ enableFloorSettingEnforcement : false ,
109+ } ,
110+ updateMask : {
111+ paths : [ 'enable_floor_setting_enforcement' ] ,
112+ } ,
113+ } ) ;
114+ console . log ( 'Disabled folder floor settings:' , updatedFolderSettings . name ) ;
115+ }
116+ }
117+
118+ // Disable organization floor settings if organizationId is available
119+ if ( organizationId ) {
120+ const [ orgFloorSettings ] = await client . getFloorSetting ( {
121+ name : `organizations/${ organizationId } /locations/global/floorSetting` ,
122+ } ) ;
123+
124+ if ( orgFloorSettings . enableFloorSettingEnforcement ) {
125+ const [ updatedOrgSettings ] = await client . updateFloorSetting ( {
126+ floorSetting : {
127+ name : `organizations/${ organizationId } /locations/global/floorSetting` ,
128+ enableFloorSettingEnforcement : false ,
129+ } ,
130+ updateMask : {
131+ paths : [ 'enable_floor_setting_enforcement' ] ,
132+ } ,
133+ } ) ;
134+ console . log ( 'Disabled organization floor settings:' , updatedOrgSettings . name ) ;
135+ }
136+ }
137+ } catch ( error ) {
138+ console . error ( 'Error disabling floor settings:' , error ) ;
139+ }
140+ }
141+
78142describe ( 'Model Armor tests' , ( ) => {
79143 const templatesToDelete = [ ] ;
80144
@@ -164,6 +228,9 @@ describe('Model Armor tests', () => {
164228 } ) ;
165229
166230 after ( async ( ) => {
231+ // Disable floor settings to restore original state
232+ await disableFloorSettings ( ) ;
233+
167234 // Clean up all templates
168235 const directTemplates = [ emptyTemplateId , basicTemplateId ] ;
169236 for ( const templateId of directTemplates ) {
@@ -249,4 +316,4 @@ describe('Model Armor tests', () => {
249316 // Check that the response contains enableFloorSettingEnforcement=true
250317 assert . match ( output , / e n a b l e F l o o r S e t t i n g E n f o r c e m e n t : \s * t r u e / ) ;
251318 } ) ;
252- } ) ;
319+ } ) ;
0 commit comments