broker/DBAuthenticatorTest: code formatter used

This commit is contained in:
Andreas Mager
2017-02-01 17:13:43 +01:00
parent f4120433d9
commit a946357ea3
@@ -1,15 +1,14 @@
package io.moquette.spi.impl.security;
import org.apache.commons.codec.binary.Hex;
import org.junit.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -25,7 +24,6 @@ public class DBAuthenticatorTest {
public static final String SHA_256 = "SHA-256";
private Connection connection;
@Before
public void setup() throws ClassNotFoundException, SQLException, NoSuchAlgorithmException {
Class.forName(ORG_H2_DRIVER);
@@ -51,28 +49,38 @@ public class DBAuthenticatorTest {
}
LOG.info("Table User created");
statement.close();
}
@Test
public void Db_verifyValid() {
final DBAuthenticator dbAuthenticator = new DBAuthenticator(ORG_H2_DRIVER, JDBC_H2_MEM_TEST, "SELECT PASSWORD FROM ACCOUNT WHERE LOGIN=?", SHA_256);
final DBAuthenticator dbAuthenticator = new DBAuthenticator(
ORG_H2_DRIVER,
JDBC_H2_MEM_TEST,
"SELECT PASSWORD FROM ACCOUNT WHERE LOGIN=?",
SHA_256);
assertTrue(dbAuthenticator.checkValid(null, "dbuser", "password".getBytes()));
}
@Test
public void Db_verifyInvalidLogin() {
final DBAuthenticator dbAuthenticator = new DBAuthenticator(ORG_H2_DRIVER, JDBC_H2_MEM_TEST, "SELECT PASSWORD FROM ACCOUNT WHERE LOGIN=?", SHA_256);
final DBAuthenticator dbAuthenticator = new DBAuthenticator(
ORG_H2_DRIVER,
JDBC_H2_MEM_TEST,
"SELECT PASSWORD FROM ACCOUNT WHERE LOGIN=?",
SHA_256);
assertFalse(dbAuthenticator.checkValid(null, "dbuser2", "password".getBytes()));
}
@Test
public void Db_verifyInvalidPassword() {
final DBAuthenticator dbAuthenticator = new DBAuthenticator(ORG_H2_DRIVER, JDBC_H2_MEM_TEST, "SELECT PASSWORD FROM ACCOUNT WHERE LOGIN=?", SHA_256);
final DBAuthenticator dbAuthenticator = new DBAuthenticator(
ORG_H2_DRIVER,
JDBC_H2_MEM_TEST,
"SELECT PASSWORD FROM ACCOUNT WHERE LOGIN=?",
SHA_256);
assertFalse(dbAuthenticator.checkValid(null, "dbuser", "wrongPassword".getBytes()));
}
@After
public void teardown() {
try {