#449 Remove use of legacy settings in encryption methods

This commit is contained in:
ljacqu
2016-04-23 12:46:30 +02:00
parent ee745f153d
commit a78e0408c6
15 changed files with 203 additions and 118 deletions
@@ -1,24 +1,25 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.WrapperMock;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.properties.HooksSettings;
import org.junit.BeforeClass;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
/**
* Test for {@link BCRYPT}.
*/
public class BcryptTest extends AbstractEncryptionMethodTest {
@BeforeClass
public static void setUpSettings() {
WrapperMock.createInstance();
Settings.bCryptLog2Rounds = 8;
public static void initializeLogger() {
TestHelper.setupLogger();
}
public BcryptTest() {
super(new BCRYPT(),
super(new BCRYPT(mockSettings()),
"$2a$10$6iATmYgwJVc3YONhVcZFve3Cfb5GnwvKhJ20r.hMjmcNkIT9.Uh9K", // password
"$2a$10$LOhUxhEcS0vgDPv/jkXvCurNb7LjP9xUlEolJGk.Uhgikqc6FtIOi", // PassWord1
"$2a$10$j9da7SGiaakWhzIms9BtwemLUeIhSEphGUQ3XSlvYgpYsGnGCKRBa", // &^%te$t?Pw@_
@@ -26,4 +27,10 @@ public class BcryptTest extends AbstractEncryptionMethodTest {
);
}
private static NewSetting mockSettings() {
NewSetting settings = mock(NewSetting.class);
given(settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND)).willReturn(8);
return settings;
}
}
@@ -1,7 +1,6 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.util.WrapperMock;
import org.junit.BeforeClass;
/**
@@ -11,7 +10,6 @@ public class IPB4Test extends AbstractEncryptionMethodTest {
@BeforeClass
public static void setUpSettings() {
WrapperMock.createInstance();
TestHelper.setupLogger();
}
@@ -1,26 +1,28 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.WrapperMock;
import org.junit.Before;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.properties.SecuritySettings;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
/**
* Test for {@link SALTED2MD5}.
*/
public class SALTED2MD5Test extends AbstractEncryptionMethodTest {
@Before
public void setUpAlgorithm() {
WrapperMock.createInstance();
Settings.saltLength = 8;
}
public SALTED2MD5Test() {
super(new SALTED2MD5(),
super(new SALTED2MD5(mockSettings()),
new HashedPassword("9f3d13dc01a6fe61fd669954174399f3", "9b5f5749"), // password
new HashedPassword("b28c32f624a4eb161d6adc9acb5bfc5b", "f750ba32"), // PassWord1
new HashedPassword("38dcb83cc68424afe3cda012700c2bb1", "eb2c3394"), // &^%te$t?Pw@_
new HashedPassword("ad25606eae5b760c8a2469d65578ac39", "04eee598")); // âË_3(íù*)
}
private static NewSetting mockSettings() {
NewSetting settings = mock(NewSetting.class);
given(settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH)).willReturn(8);
return settings;
}
}
@@ -1,7 +1,6 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.util.WrapperMock;
import org.junit.BeforeClass;
/**
@@ -11,7 +10,6 @@ public class XFBCRYPTTest extends AbstractEncryptionMethodTest {
@BeforeClass
public static void setup() {
WrapperMock.createInstance();
TestHelper.setupLogger();
}