From 9e46ba9f9182c4e7ab1ba4045fc835ad112b9ee4 Mon Sep 17 00:00:00 2001 From: Przemyslaw Motacki Date: Mon, 25 Nov 2024 12:55:13 +0100 Subject: [PATCH] SNOW-1689931 Adding flag to skip token file permission verification --- .../client/config/SFConnectionConfigParserTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/java/net/snowflake/client/config/SFConnectionConfigParserTest.java b/src/test/java/net/snowflake/client/config/SFConnectionConfigParserTest.java index 07658b9e8..46339e95c 100644 --- a/src/test/java/net/snowflake/client/config/SFConnectionConfigParserTest.java +++ b/src/test/java/net/snowflake/client/config/SFConnectionConfigParserTest.java @@ -18,10 +18,14 @@ import java.nio.file.attribute.FileAttribute; import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermissions; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; + import net.snowflake.client.RunningNotOnLinuxMac; import net.snowflake.client.core.Constants; import net.snowflake.client.jdbc.SnowflakeSQLException; @@ -33,12 +37,18 @@ public class SFConnectionConfigParserTest { + private static final List ENV_VARIABLES_KEYS = + new ArrayList<>(Arrays.asList(SNOWFLAKE_HOME_KEY, SNOWFLAKE_DEFAULT_CONNECTION_NAME_KEY, SKIP_TOKEN_FILE_PERMISSIONS_VERIFICATION)); private Path tempPath = null; private TomlMapper tomlMapper = new TomlMapper(); + private Map envVariables = new HashMap(); @Before public void setUp() throws IOException { tempPath = Files.createTempDirectory(".snowflake"); + ENV_VARIABLES_KEYS + .stream() + .forEach(key -> envVariables.put(key, SnowflakeUtil.systemGetEnv(key))); } @After @@ -48,6 +58,9 @@ public void close() throws IOException { SnowflakeUtil.systemUnsetEnv(SKIP_TOKEN_FILE_PERMISSIONS_VERIFICATION); Files.walk(tempPath).map(Path::toFile).forEach(File::delete); Files.delete(tempPath); + ENV_VARIABLES_KEYS + .stream() + .forEach(key -> SnowflakeUtil.systemSetEnv(key, envVariables.get(key))); } @Test