5757import org .openmetadata .schema .api .teams .CreateUser ;
5858import org .openmetadata .schema .api .tests .CreateTestCase ;
5959import org .openmetadata .schema .api .tests .CreateTestDefinition ;
60+ import org .openmetadata .schema .configuration .AssetCertificationSettings ;
6061import org .openmetadata .schema .entity .classification .Classification ;
6162import org .openmetadata .schema .entity .classification .Tag ;
6263import org .openmetadata .schema .entity .data .APICollection ;
8283import org .openmetadata .schema .services .connections .database .MysqlConnection ;
8384import org .openmetadata .schema .services .connections .database .PostgresConnection ;
8485import org .openmetadata .schema .services .connections .database .common .basicAuth ;
86+ import org .openmetadata .schema .settings .Settings ;
87+ import org .openmetadata .schema .settings .SettingsType ;
8588import org .openmetadata .schema .tests .TestCase ;
8689import org .openmetadata .schema .tests .TestPlatform ;
8790import org .openmetadata .schema .type .APIRequestMethod ;
@@ -5880,6 +5883,24 @@ private void setupCertificationTags_SDK() {
58805883 }
58815884 }
58825885
5886+ // Ensure Gold tag exists (bootstrapped at startup, but ensure defensively)
5887+ try {
5888+ Tag goldTag = SdkClients .adminClient ().tags ().getByName ("Certification.Gold" );
5889+ LOG .debug ("Gold tag already exists: {}" , goldTag .getFullyQualifiedName ());
5890+ } catch (ApiException e ) {
5891+ if (e .getStatusCode () == 404 ) {
5892+ CreateTag createGoldTag =
5893+ new CreateTag ()
5894+ .withName ("Gold" )
5895+ .withDescription ("Gold certified Data Asset." )
5896+ .withClassification ("Certification" );
5897+ Tag goldTag = SdkClients .adminClient ().tags ().create (createGoldTag );
5898+ LOG .debug ("Gold tag created: {}" , goldTag .getFullyQualifiedName ());
5899+ } else {
5900+ throw e ;
5901+ }
5902+ }
5903+
58835904 // Check if Brass tag already exists
58845905 try {
58855906 Tag brassTag = SdkClients .adminClient ().tags ().getByName ("Certification.Brass" );
@@ -5898,6 +5919,31 @@ private void setupCertificationTags_SDK() {
58985919 throw e ;
58995920 }
59005921 }
5922+
5923+ // Defensively ensure AssetCertificationSettings has correct allowedClassification.
5924+ // This guards against cross-test pollution (e.g., SystemResourceIT changing it).
5925+ try {
5926+ OpenMetadataClient client = SdkClients .adminClient ();
5927+ AssetCertificationSettings certSettings =
5928+ new AssetCertificationSettings ()
5929+ .withAllowedClassification ("Certification" )
5930+ .withValidityPeriod ("P30D" );
5931+ Settings settings =
5932+ new Settings ()
5933+ .withConfigType (SettingsType .ASSET_CERTIFICATION_SETTINGS )
5934+ .withConfigValue (certSettings );
5935+ String settingsJson = MAPPER .writeValueAsString (settings );
5936+ client
5937+ .getHttpClient ()
5938+ .executeForString (
5939+ HttpMethod .PUT ,
5940+ "/v1/system/settings" ,
5941+ settingsJson ,
5942+ RequestOptions .builder ().build ());
5943+ LOG .debug ("AssetCertificationSettings reset to allowedClassification=Certification" );
5944+ } catch (Exception e ) {
5945+ LOG .warn ("Failed to reset AssetCertificationSettings: {}" , e .getMessage ());
5946+ }
59015947 }
59025948
59035949 private void createTestEntities_SDK (TestNamespace ns , TestInfo test ) {
0 commit comments