Remove redundant key generation in tests

This commit is contained in:
René Pfeuffer
2018-11-30 11:26:23 +01:00
parent 205ca42e09
commit f7fc81b626
6 changed files with 19 additions and 34 deletions

View File

@@ -14,7 +14,6 @@ import java.time.Clock;
import java.time.Instant;
import java.util.Collections;
import java.util.Optional;
import java.util.Random;
import static java.time.Duration.ofMinutes;
import static java.time.temporal.ChronoUnit.SECONDS;
@@ -23,6 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static sonia.scm.security.SecureKeyTestUtil.createSecureKey;
@SubjectAware(
username = "user",
@@ -52,10 +52,7 @@ public class JwtAccessTokenRefresherTest {
@Before
public void initKeyResolver() {
byte[] bytes = new byte[256];
new Random().nextBytes(bytes);
SecureKey secureKey = new SecureKey(bytes, System.currentTimeMillis());
when(keyResolver.getSecureKey(any())).thenReturn(secureKey);
when(keyResolver.getSecureKey(any())).thenReturn(createSecureKey());
Clock creationClock = mock(Clock.class);
when(creationClock.instant()).thenReturn(TOKEN_CREATION);