Skip to content

Commit

Permalink
SNOW-1689931 Adding flag to skip token file permission verification
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pmotacki committed Nov 25, 2024
1 parent 29f19fc commit 9e46ba9
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,12 +37,18 @@

public class SFConnectionConfigParserTest {

private static final List<String> 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<String, String> 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
Expand All @@ -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
Expand Down

0 comments on commit 9e46ba9

Please sign in to comment.