diff --git a/pom.xml b/pom.xml index edad3fc7f..a221186cc 100644 --- a/pom.xml +++ b/pom.xml @@ -56,6 +56,7 @@ AuthMe CUSTOM + false ${project.version}-b${project.buildNumber} ${project.outputName}-${project.version} @@ -81,6 +82,17 @@ ${env.BUILD_NUMBER} + + skipLongHashTests + + + skipLongHashTests + + + + true + + @@ -124,6 +136,9 @@ 2.19.1 -Dfile.encoding=${project.build.sourceEncoding} @{argLine} + + ${project.skipExtendedHashTests} + diff --git a/src/test/java/fr/xephi/authme/security/crypts/AbstractEncryptionMethodTest.java b/src/test/java/fr/xephi/authme/security/crypts/AbstractEncryptionMethodTest.java index 454897106..1ee728404 100644 --- a/src/test/java/fr/xephi/authme/security/crypts/AbstractEncryptionMethodTest.java +++ b/src/test/java/fr/xephi/authme/security/crypts/AbstractEncryptionMethodTest.java @@ -12,6 +12,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeThat; /** * Test for implementations of {@link EncryptionMethod}. @@ -36,6 +37,14 @@ public abstract class AbstractEncryptionMethodTest { "asdfg:hjkl", "::test", "~#$#~~~#$#~", "d41d8cd98f00b204e9800998ecf427e", "$2y$7a$da641e404b982ed" }; + /** + * Certain hash algorithms are slow by design, which has a considerable effect on these unit tests. + * Setting the property below to "true" will reduce the checks in these unit tests as to offer fast, + * partial tests during development. + */ + private static final boolean SKIP_LONG_TESTS = + "true".equals(System.getProperty("project.skipExtendedHashTests")); + /** The encryption method to test. */ private EncryptionMethod method; /** Map with the hashes against which the entries in GIVEN_PASSWORDS are tested. */ @@ -79,8 +88,10 @@ public abstract class AbstractEncryptionMethodTest { @Test public void testGivenPasswords() { - // Test all entries in GIVEN_PASSWORDS except the last one - for (int i = 0; i < GIVEN_PASSWORDS.length - 1; ++i) { + // Start with the 2nd to last password if we skip long tests + int start = SKIP_LONG_TESTS ? GIVEN_PASSWORDS.length - 2 : 0; + // Test entries in GIVEN_PASSWORDS except the last one + for (int i = start; i < GIVEN_PASSWORDS.length - 1; ++i) { String password = GIVEN_PASSWORDS[i]; assertTrue("Hash for password '" + password + "' should match", doesGivenHashMatch(password, method)); @@ -124,12 +135,14 @@ public abstract class AbstractEncryptionMethodTest { assertFalse("Upper-case of '" + password + "' should not match generated hash '" + hash + "'", method.comparePassword(password.toUpperCase(), hashedPassword, USERNAME)); } + assumeThat(SKIP_LONG_TESTS, equalTo(false)); } } /** Tests various strings to ensure that encryption methods don't rely on the hash's format too much. */ @Test public void testMalformedHashes() { + assumeThat(SKIP_LONG_TESTS, equalTo(false)); String salt = method.hasSeparateSalt() ? "testSalt" : null; for (String bogusHash : BOGUS_HASHES) { HashedPassword hashedPwd = new HashedPassword(bogusHash, salt);