1
0
mirror of synced 2026-05-22 13:23:17 +00:00

openrewrite Junit Migration

This commit is contained in:
Rob Winch
2021-07-08 14:52:28 -05:00
parent 8652f01269
commit 3e93b024d6
999 changed files with 3088 additions and 3092 deletions
@@ -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;
@@ -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
@@ -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;
@@ -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"));
@@ -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);
}
}
@@ -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
@@ -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");
}
}
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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);
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;