mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 20:19:06 +00:00
Use SecureRandom in RandomValuePropertySource
Closes gh-50172
This commit is contained in:
+2
-1
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.boot.env;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.HexFormat;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.OptionalLong;
|
||||
@@ -77,7 +78,7 @@ public class RandomValuePropertySource extends PropertySource<Random> {
|
||||
}
|
||||
|
||||
public RandomValuePropertySource(String name) {
|
||||
super(name, new Random());
|
||||
super(name, new SecureRandom());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ class RandomValuePropertySourceTests {
|
||||
|
||||
@Test
|
||||
void getPropertyWhenStringReturnsValue() {
|
||||
assertThat(this.source.getProperty("random.string")).isNotNull();
|
||||
assertThat(this.source.getProperty("random.string")).isNotNull().asString().containsPattern("^[0-9a-f]{32}$");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user