openrewrite Junit Migration
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ package org.springframework.security.crypto.argon2;
|
||||
import java.util.Base64;
|
||||
|
||||
import org.bouncycastle.crypto.params.Argon2Parameters;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
+4
-4
@@ -19,11 +19,11 @@ package org.springframework.security.crypto.argon2;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.security.crypto.keygen.BytesKeyGenerator;
|
||||
|
||||
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
/**
|
||||
* @author Simeon Macke
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class Argon2PasswordEncoderTests {
|
||||
|
||||
@Mock
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package org.springframework.security.crypto.bcrypt;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
@@ -17,8 +17,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
@@ -58,7 +58,7 @@ public class BCryptTests {
|
||||
|
||||
private static List<TestObject<byte[]>> testObjectsByteArray;
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void setupTestObjects() {
|
||||
testObjectsString = new ArrayList<>();
|
||||
testObjectsString.add(new TestObject<>("", "$2a$06$DCq7YPn5Rq63x1Lad4cll.",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.crypto.codec;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.crypto.codec;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.security.crypto.codec;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
+3
-3
@@ -19,8 +19,8 @@ package org.springframework.security.crypto.encrypt;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.PBEKeySpec;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.security.crypto.codec.Hex;
|
||||
import org.springframework.security.crypto.encrypt.AesBytesEncryptor.CipherAlgorithm;
|
||||
@@ -44,7 +44,7 @@ public class AesBytesEncryptorTests {
|
||||
|
||||
private BytesKeyGenerator generator;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.generator = mock(BytesKeyGenerator.class);
|
||||
given(this.generator.generateKey()).willReturn(Hex.decode("4b0febebd439db7ca77153cb254520c3"));
|
||||
|
||||
+9
-9
@@ -20,9 +20,9 @@ import java.security.SecureRandom;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.security.crypto.codec.Hex;
|
||||
import org.springframework.security.crypto.encrypt.AesBytesEncryptor.CipherAlgorithm;
|
||||
@@ -39,7 +39,7 @@ public class BouncyCastleAesBytesEncryptorEquivalencyTests {
|
||||
|
||||
private SecureRandom secureRandom = new SecureRandom();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
// generate random password, salt, and test data
|
||||
this.password = UUID.randomUUID().toString();
|
||||
@@ -96,11 +96,11 @@ public class BouncyCastleAesBytesEncryptorEquivalencyTests {
|
||||
// and can decrypt back to the original input
|
||||
byte[] leftEncrypted = left.encrypt(this.testData);
|
||||
byte[] rightEncrypted = right.encrypt(this.testData);
|
||||
Assert.assertArrayEquals(leftEncrypted, rightEncrypted);
|
||||
Assertions.assertArrayEquals(leftEncrypted, rightEncrypted);
|
||||
byte[] leftDecrypted = left.decrypt(leftEncrypted);
|
||||
byte[] rightDecrypted = right.decrypt(rightEncrypted);
|
||||
Assert.assertArrayEquals(this.testData, leftDecrypted);
|
||||
Assert.assertArrayEquals(this.testData, rightDecrypted);
|
||||
Assertions.assertArrayEquals(this.testData, leftDecrypted);
|
||||
Assertions.assertArrayEquals(this.testData, rightDecrypted);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ public class BouncyCastleAesBytesEncryptorEquivalencyTests {
|
||||
byte[] rightEncrypted = right.encrypt(this.testData);
|
||||
byte[] leftDecrypted = left.decrypt(rightEncrypted);
|
||||
byte[] rightDecrypted = right.decrypt(leftEncrypted);
|
||||
Assert.assertArrayEquals(this.testData, leftDecrypted);
|
||||
Assert.assertArrayEquals(this.testData, rightDecrypted);
|
||||
Assertions.assertArrayEquals(this.testData, leftDecrypted);
|
||||
Assertions.assertArrayEquals(this.testData, rightDecrypted);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -20,9 +20,9 @@ import java.security.SecureRandom;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bouncycastle.util.Arrays;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.security.crypto.codec.Hex;
|
||||
import org.springframework.security.crypto.keygen.KeyGenerators;
|
||||
@@ -37,7 +37,7 @@ public class BouncyCastleAesBytesEncryptorTests {
|
||||
|
||||
private String salt;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
// generate random password, salt, and test data
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
@@ -64,11 +64,11 @@ public class BouncyCastleAesBytesEncryptorTests {
|
||||
private void generatesDifferentCipherTexts(BytesEncryptor bcEncryptor) {
|
||||
byte[] encrypted1 = bcEncryptor.encrypt(this.testData);
|
||||
byte[] encrypted2 = bcEncryptor.encrypt(this.testData);
|
||||
Assert.assertFalse(Arrays.areEqual(encrypted1, encrypted2));
|
||||
Assertions.assertFalse(Arrays.areEqual(encrypted1, encrypted2));
|
||||
byte[] decrypted1 = bcEncryptor.decrypt(encrypted1);
|
||||
byte[] decrypted2 = bcEncryptor.decrypt(encrypted2);
|
||||
Assert.assertArrayEquals(this.testData, decrypted1);
|
||||
Assert.assertArrayEquals(this.testData, decrypted2);
|
||||
Assertions.assertArrayEquals(this.testData, decrypted1);
|
||||
Assertions.assertArrayEquals(this.testData, decrypted2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+2
-2
@@ -21,8 +21,8 @@ import java.security.NoSuchAlgorithmException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
|
||||
import org.junit.Assume;
|
||||
import org.junit.AssumptionViolatedException;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
|
||||
import org.springframework.security.crypto.encrypt.AesBytesEncryptor.CipherAlgorithm;
|
||||
|
||||
@@ -51,7 +51,7 @@ public final class CryptoAssumptions {
|
||||
catch (NoSuchPaddingException ex) {
|
||||
throw new AssumptionViolatedException(cipherAlgorithm + " padding not available, skipping test", ex);
|
||||
}
|
||||
Assume.assumeTrue("AES key length of 256 not allowed, skipping test", aes256Available);
|
||||
Assumptions.assumeTrue(aes256Available, "AES key length of 256 not allowed, skipping test");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.crypto.encrypt;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.crypto.factory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package org.springframework.security.crypto.keygen;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package org.springframework.security.crypto.keygen;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.security.crypto.codec.Hex;
|
||||
|
||||
|
||||
+6
-6
@@ -20,11 +20,11 @@ import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
@@ -38,7 +38,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
* @author Michael Simons
|
||||
* @since 5.0
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class DelegatingPasswordEncoderTests {
|
||||
|
||||
@Mock
|
||||
@@ -64,7 +64,7 @@ public class DelegatingPasswordEncoderTests {
|
||||
|
||||
private DelegatingPasswordEncoder passwordEncoder;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.delegates = new HashMap<>();
|
||||
this.delegates.put(this.bcryptId, this.bcrypt);
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.crypto.password;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.security.crypto.codec.Hex;
|
||||
import org.springframework.security.crypto.codec.Utf8;
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.crypto.password;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.security.crypto.keygen.KeyGenerators;
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.crypto.password;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.crypto.password;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.crypto.password;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package org.springframework.security.crypto.password;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.security.crypto.codec.Hex;
|
||||
import org.springframework.security.crypto.keygen.KeyGenerators;
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.crypto.password;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.security.crypto.scrypt;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package org.springframework.security.crypto.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.security.crypto.codec.Hex;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user