mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-03 01:00:18 +01:00
#364 Add tests for more encryption algorithms
This commit is contained in:
parent
acfc4dba3e
commit
51d1705b1f
@ -66,17 +66,28 @@ public abstract class AbstractEncryptionMethodTest {
|
||||
}
|
||||
}
|
||||
|
||||
static void generateHashes(EncryptionMethod method) {
|
||||
System.out.println("AbstractEncryptionMethodTest.testGivenPasswords(method,");
|
||||
// @org.junit.Test public void a() { AbstractEncryptionMethodTest.generateTest(); }
|
||||
// TODO #364: Remove this method
|
||||
static void generateTest(EncryptionMethod method) {
|
||||
String className = method.getClass().getSimpleName();
|
||||
System.out.println("public class " + className + "Test extends AbstractEncryptionMethodTest {");
|
||||
System.out.println("\tpublic " + className + "Test() {");
|
||||
System.out.println("\t\tsuper(new " + className + "(),");
|
||||
|
||||
String delim = ", ";
|
||||
for (String password : GIVEN_PASSWORDS) {
|
||||
if (password.equals(GIVEN_PASSWORDS[GIVEN_PASSWORDS.length - 1])) {
|
||||
delim = "); ";
|
||||
}
|
||||
try {
|
||||
System.out.println("\t\"" + method.getHash(password, getSalt(method), "USERNAME")
|
||||
+ "\", // " + password);
|
||||
System.out.println("\t\t\"" + method.getHash(password, getSalt(method), "USERNAME")
|
||||
+ "\"" + delim + "// " + password);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException("Could not generate hash", e);
|
||||
}
|
||||
}
|
||||
System.out.println(");");
|
||||
System.out.println("\t}");
|
||||
System.out.println("}");
|
||||
}
|
||||
|
||||
// TODO #358: Remove this method and use the new salt method on the interface
|
||||
@ -84,12 +95,16 @@ public abstract class AbstractEncryptionMethodTest {
|
||||
try {
|
||||
if (method instanceof BCRYPT) {
|
||||
return BCRYPT.gensalt();
|
||||
} else if (method instanceof MD5) {
|
||||
} else if (method instanceof MD5 || method instanceof WORDPRESS) {
|
||||
return "";
|
||||
} else if (method instanceof JOOMLA) {
|
||||
return PasswordSecurity.createSalt(32);
|
||||
} else if (method instanceof SHA256) {
|
||||
} else if (method instanceof SHA256 || method instanceof PHPBB) {
|
||||
return PasswordSecurity.createSalt(16);
|
||||
} else if (method instanceof WBB3) {
|
||||
return PasswordSecurity.createSalt(40);
|
||||
} else if (method instanceof XAUTH) {
|
||||
return PasswordSecurity.createSalt(12);
|
||||
}
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
16
src/test/java/fr/xephi/authme/security/crypts/PHPBBTest.java
Normal file
16
src/test/java/fr/xephi/authme/security/crypts/PHPBBTest.java
Normal file
@ -0,0 +1,16 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
/**
|
||||
* Test for {@link PHPBB}.
|
||||
*/
|
||||
public class PHPBBTest extends AbstractEncryptionMethodTest {
|
||||
|
||||
public PHPBBTest() {
|
||||
super(new PHPBB(),
|
||||
"$H$7MaSGQb0xe3Fp/a.Q.Ewpw.UKfCv.t0", // password
|
||||
"$H$7ESfAVjzqajC7fJFcZKZIhyds41MuW.", // PassWord1
|
||||
"$H$7G65SXRPbR69jLg.qZTjtqsw36Ciw7.", // &^%te$t?Pw@_
|
||||
"$H$7Brcg8zO9amr2SHVgz.pFxprDu40v4/"); // âË_3(íù*
|
||||
}
|
||||
|
||||
}
|
20
src/test/java/fr/xephi/authme/security/crypts/WBB3Test.java
Normal file
20
src/test/java/fr/xephi/authme/security/crypts/WBB3Test.java
Normal file
@ -0,0 +1,20 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
* Test for {@link WBB3}.
|
||||
*/
|
||||
@Ignore
|
||||
// TODO #364 ljacqu 20151220: Unignore test after fixing closely coupled DB dependency
|
||||
public class WBB3Test extends AbstractEncryptionMethodTest {
|
||||
|
||||
public WBB3Test() {
|
||||
super(new WBB3(),
|
||||
"ca426c4d20a82cd24c7bb07d94d69f3757e3d07d", // password
|
||||
"72d59d27674a3cace2600ff152ba8b46274e27e9", // PassWord1
|
||||
"23daf26602e52591156968a14c2a6592b5be4743", // &^%te$t?Pw@_
|
||||
"d3908efe4a15314066391dd8572883c70b16fd8a"); // âË_3(íù*
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
/**
|
||||
* Test for {@link WORDPRESS}.
|
||||
*/
|
||||
public class WORDPRESSTest extends AbstractEncryptionMethodTest {
|
||||
|
||||
public WORDPRESSTest() {
|
||||
super(new WORDPRESS(),
|
||||
"$P$B9wyjxuU4yrfjnnHNGSzH9ti9CC0Os1", // password
|
||||
"$P$BjzPjjzPjjkRzvGGRTyYu0sNqcz6Ci0", // PassWord1
|
||||
"$P$BjzPjjzPjrAOyB1V0WFdpisgCTFx.N/", // &^%te$t?Pw@_
|
||||
"$P$BjzPjxxyjp2QdKcab/oTW8l/W0AgE21"); // âË_3(íù*
|
||||
}
|
||||
}
|
16
src/test/java/fr/xephi/authme/security/crypts/XAUTHTest.java
Normal file
16
src/test/java/fr/xephi/authme/security/crypts/XAUTHTest.java
Normal file
@ -0,0 +1,16 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
/**
|
||||
* Test for {@link XAUTH}.
|
||||
*/
|
||||
public class XAUTHTest extends AbstractEncryptionMethodTest {
|
||||
|
||||
public XAUTHTest() {
|
||||
super(new XAUTH(),
|
||||
"e54d4916577410d26d2f6e9362445463dab9ffdff9a67ed3b74d3f2312bc8fab84f653fcb88ad8338793ef8a6d0a1162105e46ec24f0dcb52355c634e3e6439f45444b09c715", // password
|
||||
"d54489a4fd4732ee03d56810ab92944096e3d49335266adeecfbc12567abb3ff744761b33a1fcc4d04739e377775c788e4baace3caf35c7b9176b82b1fe3472e4cbdc5a43214", // PassWord1
|
||||
"ce6404c1092fb5abf0a72f9c4327bfe8f4cdc4b8dc90ee6ca35c42b8ae9481b89c2559bb60b99ff2b57a102cfced40b8e2f5ef481400c9e6f79445017fc763b1cc27f4c2df36", // &^%te$t?Pw@_
|
||||
"73074fe3f5503677ab9c5a1885b46a8b6fb249453317da08d86312c20e7b326e84f615e1b594c71129d2d1020400a89838e44653dc02d1799886e522a2789fbe1df6e70b7ffb"); // âË_3(íù*
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user