This commit is contained in:
Claudio Maggioni (maggicl) 2020-05-27 11:42:55 +02:00
parent 9489fe9140
commit 2aa6718424
2 changed files with 4 additions and 3 deletions

View file

@ -6,7 +6,6 @@ import io.jsonwebtoken.SignatureAlgorithm;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.function.Function; import java.util.function.Function;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -19,7 +18,6 @@ public class JWTTokenUtils {
/** The secret key used to encrypt all JWTs */ /** The secret key used to encrypt all JWTs */
@Value("${jwt.secret}") @Value("${jwt.secret}")
@Setter
private String secret; private String secret;
/** /**

View file

@ -9,6 +9,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.test.util.ReflectionTestUtils;
@ExtendWith({MockitoExtension.class}) @ExtendWith({MockitoExtension.class})
public class JWTTokenUtilsTests { public class JWTTokenUtilsTests {
@ -18,7 +19,9 @@ public class JWTTokenUtilsTests {
@Test @Test
public void testGenerateToken() { public void testGenerateToken() {
utils.setSecret( ReflectionTestUtils.setField(
utils,
"secret",
"One, seven, three, four, six, seven\n" "One, seven, three, four, six, seven\n"
+ "Three, two, one, four, seven, six, charlie, three\n" + "Three, two, one, four, seven, six, charlie, three\n"
+ "Two, seven, eight, nine, seven, seven, seven\n" + "Two, seven, eight, nine, seven, seven, seven\n"