Skip to content

Commit 49bb2c1

Browse files
committed
test(toolkit): fix toLowerCase
1 parent 718c6e2 commit 49bb2c1

6 files changed

Lines changed: 18 additions & 12 deletions

File tree

framework/src/test/java/org/tron/keystore/WalletUtilsWriteTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.nio.file.Files;
1212
import java.nio.file.attribute.PosixFilePermission;
1313
import java.util.EnumSet;
14+
import java.util.Locale;
1415
import java.util.Set;
1516
import org.junit.Assume;
1617
import org.junit.Rule;
@@ -41,7 +42,7 @@ private static WalletFile lightWalletFile(String password) throws Exception {
4142
@Test
4243
public void testGenerateWalletFileCreatesOwnerOnlyFile() throws Exception {
4344
Assume.assumeTrue("POSIX permissions test",
44-
!System.getProperty("os.name").toLowerCase().contains("win"));
45+
!System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("win"));
4546

4647
File dir = tempFolder.newFolder("gen-perms");
4748
SignInterface keyPair = SignUtils.getGeneratedRandomSign(Utils.getRandom(), true);
@@ -84,7 +85,7 @@ public void testGenerateWalletFileLightScrypt() throws Exception {
8485
@Test
8586
public void testWriteWalletFileOwnerOnly() throws Exception {
8687
Assume.assumeTrue("POSIX permissions test",
87-
!System.getProperty("os.name").toLowerCase().contains("win"));
88+
!System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("win"));
8889

8990
File dir = tempFolder.newFolder("write-perms");
9091
WalletFile wf = lightWalletFile("password123");
@@ -172,7 +173,7 @@ public void testWriteWalletFileCleansUpTempOnFailure() throws Exception {
172173
@Test
173174
public void testLoadCredentialsFollowsSymlinkButWarns() throws Exception {
174175
Assume.assumeTrue("Symlinks only tested on POSIX",
175-
!System.getProperty("os.name").toLowerCase().contains("win"));
176+
!System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("win"));
176177

177178
File realDir = tempFolder.newFolder("load-symlink-target");
178179
SignInterface keyPair = SignUtils.getGeneratedRandomSign(Utils.getRandom(), true);

plugins/src/test/java/org/tron/plugins/KeystoreCliUtilsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.io.StringWriter;
1212
import java.nio.charset.StandardCharsets;
1313
import java.nio.file.Files;
14+
import java.util.Locale;
1415
import java.util.Map;
1516
import org.junit.Rule;
1617
import org.junit.Test;
@@ -307,7 +308,7 @@ public void testReadRegularFileTooLarge() throws Exception {
307308
@Test
308309
public void testReadRegularFileRefusesSymlink() throws Exception {
309310
org.junit.Assume.assumeTrue("Symlinks only tested on POSIX",
310-
!System.getProperty("os.name").toLowerCase().contains("win"));
311+
!System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("win"));
311312

312313
File target = tempFolder.newFile("real-target.txt");
313314
Files.write(target.toPath(), "secret content".getBytes(StandardCharsets.UTF_8));

plugins/src/test/java/org/tron/plugins/KeystoreImportTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.nio.charset.StandardCharsets;
1010
import java.nio.file.Files;
1111
import java.security.SecureRandom;
12+
import java.util.Locale;
1213
import org.junit.Rule;
1314
import org.junit.Test;
1415
import org.junit.rules.TemporaryFolder;
@@ -340,7 +341,7 @@ public void testImportWarnsOnCorruptedFile() throws Exception {
340341

341342
@Test
342343
public void testImportKeystoreFilePermissions() throws Exception {
343-
String os = System.getProperty("os.name").toLowerCase();
344+
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
344345
org.junit.Assume.assumeTrue("POSIX permissions test, skip on Windows",
345346
!os.contains("win"));
346347

@@ -377,7 +378,7 @@ public void testImportKeystoreFilePermissions() throws Exception {
377378
@Test
378379
public void testImportRefusesSymlinkKeyFile() throws Exception {
379380
org.junit.Assume.assumeTrue("Symlinks only tested on POSIX",
380-
!System.getProperty("os.name").toLowerCase().contains("win"));
381+
!System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("win"));
381382

382383
File dir = tempFolder.newFolder("keystore-symlink");
383384
// Create a real key file and a symlink pointing to it
@@ -409,7 +410,7 @@ public void testImportRefusesSymlinkKeyFile() throws Exception {
409410
@Test
410411
public void testImportRefusesSymlinkPasswordFile() throws Exception {
411412
org.junit.Assume.assumeTrue("Symlinks only tested on POSIX",
412-
!System.getProperty("os.name").toLowerCase().contains("win"));
413+
!System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("win"));
413414

414415
File dir = tempFolder.newFolder("keystore-pwsymlink");
415416
SignInterface keyPair = SignUtils.getGeneratedRandomSign(
@@ -468,7 +469,7 @@ public void testImportDuplicateCheckSkipsInvalidVersion() throws Exception {
468469
@Test
469470
public void testImportDuplicateScanSkipsSymlinkedEntry() throws Exception {
470471
org.junit.Assume.assumeTrue("Symlinks only tested on POSIX",
471-
!System.getProperty("os.name").toLowerCase().contains("win"));
472+
!System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("win"));
472473

473474
File dir = tempFolder.newFolder("keystore-dup-symlink");
474475

plugins/src/test/java/org/tron/plugins/KeystoreListTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.nio.charset.StandardCharsets;
1010
import java.nio.file.Files;
1111
import java.security.SecureRandom;
12+
import java.util.Locale;
1213
import org.junit.Rule;
1314
import org.junit.Test;
1415
import org.junit.rules.TemporaryFolder;
@@ -244,7 +245,7 @@ public void testListSkipsInvalidVersionKeystores() throws Exception {
244245
@Test
245246
public void testListSkipsSymlinkedKeystoreFile() throws Exception {
246247
org.junit.Assume.assumeTrue("Symlinks only tested on POSIX",
247-
!System.getProperty("os.name").toLowerCase().contains("win"));
248+
!System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("win"));
248249

249250
File dir = tempFolder.newFolder("keystore-symlink-scan");
250251
String password = "test123456";

plugins/src/test/java/org/tron/plugins/KeystoreNewTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.io.StringWriter;
1010
import java.nio.charset.StandardCharsets;
1111
import java.nio.file.Files;
12+
import java.util.Locale;
1213
import org.junit.Rule;
1314
import org.junit.Test;
1415
import org.junit.rules.TemporaryFolder;
@@ -251,7 +252,7 @@ public void testNewKeystorePasswordFileWithBom() throws Exception {
251252

252253
@Test
253254
public void testNewKeystoreFilePermissions() throws Exception {
254-
String os = System.getProperty("os.name").toLowerCase();
255+
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
255256
org.junit.Assume.assumeTrue("POSIX permissions test, skip on Windows",
256257
!os.contains("win"));
257258

plugins/src/test/java/org/tron/plugins/KeystoreUpdateTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.nio.charset.StandardCharsets;
1313
import java.nio.file.Files;
1414
import java.security.SecureRandom;
15+
import java.util.Locale;
1516
import org.junit.Rule;
1617
import org.junit.Test;
1718
import org.junit.rules.TemporaryFolder;
@@ -675,7 +676,7 @@ public void testUpdateNarrowsLoosePermissionsTo0600() throws Exception {
675676
// Adversarial test: pre-loosen the keystore to 0644, then verify that
676677
// update writes the file back with 0600. This exercises the temp-file
677678
// + atomic-rename path rather than merely preserving existing perms.
678-
String os = System.getProperty("os.name").toLowerCase();
679+
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
679680
org.junit.Assume.assumeTrue("POSIX permissions test, skip on Windows",
680681
!os.contains("win"));
681682

@@ -786,7 +787,7 @@ public void testUpdateLegacyTipSuppressedWhenPasswordHasNoWhitespace() throws Ex
786787
@Test
787788
public void testUpdateScanSkipsSymlinkedEntry() throws Exception {
788789
org.junit.Assume.assumeTrue("Symlinks only tested on POSIX",
789-
!System.getProperty("os.name").toLowerCase().contains("win"));
790+
!System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("win"));
790791

791792
File dir = tempFolder.newFolder("keystore-update-symlink");
792793
String oldPassword = "oldpass123";

0 commit comments

Comments
 (0)