Skip to content

Conversation

mihirvala-crestdata
Copy link
Contributor

Added floor settings tests as issue b/424365799 is fixed.

Added tests for

  • Get Folder floor settings
  • Get Organization floor settings
  • Get Project Floor settings
  • Update Folder floor settings
  • Update Organization floor settings
  • Update Project floor settings

@mihirvala-crestdata mihirvala-crestdata requested review from a team as code owners July 7, 2025 11:21
@product-auto-label product-auto-label bot added api: modelarmor Issues related to the Model Armor API. samples Issues that are directly related to samples. labels Jul 7, 2025
@harshnasitcrest
Copy link
Contributor

harshnasitcrest commented Jul 7, 2025

NOTE: Please set following environment variables required for running tests:
MA_FOLDER_ID: 695279264361
MA_ORG_ID: 951890214235

Additionally, please grant the service account the following permissions in the above mentioned folder and org:

  • Model Armor Admin
  • Model Armor Floor Setting Admin

@utsav1810 utsav1810 added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jul 7, 2025
@kokoro-team kokoro-team removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jul 7, 2025
/**
* Reset project floor settings to default values
*/
protected static function resetProjectFloorSettings(): void

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code across all the methods of type reset...FloorSettings seems redundant. Can you please extract the common code in a separate method & use it for Project/Folder/Organization.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated logic for resetting floor settings to remove redundant logic.

Copy link
Contributor

@bshaffer bshaffer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: Please set following environment variables required for running tests: MA_FOLDER_ID: 695279264361 MA_ORG_ID: 951890214235

Which project are these credentials for? I used these for the standard test project (php-docs-samples-kokoro) and was unable to get them to work.

Comment on lines 104 to 105
self::$organizationId = getenv('MA_ORG_ID');
self::$folderId = getenv('MA_FOLDER_ID');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use requireEnv for these, that way people running the tests will know they're required:

Suggested change
self::$organizationId = getenv('MA_ORG_ID');
self::$folderId = getenv('MA_FOLDER_ID');
self::$organizationId = self::requireEnv('MA_ORG_ID');
self::$folderId = self::requireEnv('MA_FOLDER_ID');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, thanks.

@mihirvala-crestdata
Copy link
Contributor Author

NOTE: Please set following environment variables required for running tests: MA_FOLDER_ID: 695279264361 MA_ORG_ID: 951890214235

Which project are these credentials for? I used these for the standard test project (php-docs-samples-kokoro) and was unable to get them to work.

Did not get this.
We used the same Folder ID and Organization ID for testing model armor snippets across all languages.

cc: @bhardwaj-prerna @utsav1810

@harshnasitcrest
Copy link
Contributor

@bshaffer Could you provide the service account used for running these tests?

CC: @bhardwaj-prerna

@harshnasitcrest
Copy link
Contributor

@bshaffer Could you provide the service account used for running these tests?

CC: @bhardwaj-prerna

@iennae Can someone from your team help with this?

@bshaffer
Copy link
Contributor

bshaffer commented Sep 2, 2025

@harshnasitcrest @iennae These tests should be able to run with ANY valid credentials as long as you set the appropriate environment variables. However, if you message me directly via workchat, I can either provide you with the credentials or run them myself.

Edit: I ran these tests myself and I'm getting the following error:

Permission 'modelarmor.floorSettings.update' denied on resource '\/\/modelarmor.googleapis.com\/folders\/695279264361\/locations\/global\/floorSetting' (or it may not exist)

test(modelarmorTest): reset floor settings before tests
@harshnasitcrest
Copy link
Contributor

harshnasitcrest commented Sep 8, 2025

@bshaffer Sharing the screenshot for successful run of tests on my local machine on the latest commit:
Screenshot 2025-09-08 at 11 44 46 PM

I've requested to provision access to the folder and org with @bhardwaj-prerna . Once approved, you'll also be able run the tests.

@bshaffer bshaffer merged commit 5be36a7 into GoogleCloudPlatform:main Sep 8, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: modelarmor Issues related to the Model Armor API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants