diff --git a/polaris-core/src/test/java/org/apache/polaris/service/storage/azure/AzureCredentialStorageIntegrationTest.java b/polaris-core/src/test/java/org/apache/polaris/service/storage/azure/AzureCredentialStorageIntegrationTest.java index a7e9bdfdc..7ec4a9100 100644 --- a/polaris-core/src/test/java/org/apache/polaris/service/storage/azure/AzureCredentialStorageIntegrationTest.java +++ b/polaris-core/src/test/java/org/apache/polaris/service/storage/azure/AzureCredentialStorageIntegrationTest.java @@ -52,6 +52,7 @@ import org.apache.polaris.core.storage.azure.AzureCredentialsStorageIntegration; import org.apache.polaris.core.storage.azure.AzureStorageConfigurationInfo; import org.assertj.core.api.Assertions; +import org.assertj.core.api.Assumptions; import org.assertj.core.util.Strings; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtensionContext; @@ -59,24 +60,17 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.ArgumentsProvider; import org.junit.jupiter.params.provider.ArgumentsSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class AzureCredentialStorageIntegrationTest { - private static final Logger LOGGER = - LoggerFactory.getLogger(AzureCredentialStorageIntegrationTest.class); - private final String clientId = System.getenv("AZURE_CLIENT_ID"); private final String clientSecret = System.getenv("AZURE_CLIENT_SECRET"); private final String tenantId = "d479c7c9-2632-445a-b22d-7c19e68774f6"; - private boolean checkEnvNullVariables() { - if (Strings.isNullOrEmpty(clientId) || Strings.isNullOrEmpty(clientSecret)) { - LOGGER.debug("Null Azure testing environment variables! Skip {}", this.getClass().getName()); - return true; - } - return false; + private void assumeEnvVariablesNotNull() { + Assumptions.assumeThat(Strings.isNullOrEmpty(clientId) || Strings.isNullOrEmpty(clientSecret)) + .describedAs("Null Azure testing environment variables!") + .isFalse(); } @Test @@ -115,9 +109,8 @@ public void testNegativeCases() { @TestWithAzureArgs public void testGetSubscopedTokenList(boolean allowListAction, String service) { - if (checkEnvNullVariables()) { - return; - } + assumeEnvVariablesNotNull(); + boolean isBlobService = service.equals("blob"); List allowedLoc = Arrays.asList( @@ -184,10 +177,10 @@ public void testGetSubscopedTokenList(boolean allowListAction, String service) { } @TestWithAzureArgs - public void testGetSubscopedTokenRead(boolean allowListAction, String service) { - if (checkEnvNullVariables()) { - return; - } + public void testGetSubscopedTokenRead( + @SuppressWarnings("unused") boolean allowListAction, String service) { + assumeEnvVariablesNotNull(); + String allowedPrefix = "polaris-test"; String blockedPrefix = "blocked-prefix"; List allowedLoc = @@ -253,10 +246,10 @@ public void testGetSubscopedTokenRead(boolean allowListAction, String service) { } @TestWithAzureArgs - public void testGetSubscopedTokenWrite(boolean allowListAction, String service) { - if (checkEnvNullVariables()) { - return; - } + public void testGetSubscopedTokenWrite( + @SuppressWarnings("unused") boolean allowListAction, String service) { + assumeEnvVariablesNotNull(); + boolean isBlobService = service.equals("blob"); String allowedPrefix = "polaris-test/scopedcreds/"; String blockedPrefix = "blocked-prefix"; diff --git a/polaris-core/src/test/java/org/apache/polaris/service/storage/gcp/GcpCredentialsStorageIntegrationTest.java b/polaris-core/src/test/java/org/apache/polaris/service/storage/gcp/GcpCredentialsStorageIntegrationTest.java index 9a9c9be96..35d05c251 100644 --- a/polaris-core/src/test/java/org/apache/polaris/service/storage/gcp/GcpCredentialsStorageIntegrationTest.java +++ b/polaris-core/src/test/java/org/apache/polaris/service/storage/gcp/GcpCredentialsStorageIntegrationTest.java @@ -53,31 +53,25 @@ import org.apache.polaris.core.storage.gcp.GcpCredentialsStorageIntegration; import org.apache.polaris.core.storage.gcp.GcpStorageConfigurationInfo; import org.assertj.core.api.Assertions; +import org.assertj.core.api.Assumptions; import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration; -import org.assertj.core.util.Strings; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; class GcpCredentialsStorageIntegrationTest { private final String gcsServiceKeyJsonFileLocation = System.getenv("GOOGLE_APPLICATION_CREDENTIALS"); - private static final Logger LOGGER = - LoggerFactory.getLogger(GcpCredentialsStorageIntegrationTest.class); - @ParameterizedTest @ValueSource(booleans = {true, false}) - public void testSubscope(boolean allowedListAction) throws IOException { - if (Strings.isNullOrEmpty(gcsServiceKeyJsonFileLocation)) { - LOGGER.debug( - "Environment variable GOOGLE_APPLICATION_CREDENTIALS not exits, skip test {}", - getClass().getName()); - return; - } + public void testSubscope(boolean allowedListAction) throws Exception { + Assumptions.assumeThat(gcsServiceKeyJsonFileLocation) + .describedAs("Environment variable GOOGLE_APPLICATION_CREDENTIALS not exits") + .isNotNull() + .isNotEmpty(); + List allowedRead = Arrays.asList( "gs://sfc-dev1-regtest/polaris-test/subscoped-test/read1/",