This commit is contained in:
@@ -79,7 +79,7 @@ public class ConfigurationClassLoaderTest implements IAuthenticator, IAuthorizat
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkValid(String username, String password) {
|
||||
public boolean checkValid(String username, byte[] password) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ public class ServerLowlevelMessagesIntegrationTests {
|
||||
connectMessage.setClientID("FAKECLNT");
|
||||
connectMessage.setKeepAlive(keepAlive);
|
||||
connectMessage.setWillFlag(true);
|
||||
connectMessage.setWillMessage(willTestamentMsg);
|
||||
connectMessage.setWillMessage(willTestamentMsg.getBytes());
|
||||
connectMessage.setWillTopic(willTestamentTopic);
|
||||
connectMessage.setWillQos((byte) QOSType.MOST_ONE.ordinal());
|
||||
|
||||
|
||||
@@ -25,13 +25,13 @@ import org.eclipse.moquette.spi.impl.security.IAuthenticator;
|
||||
*/
|
||||
class MockAuthenticator implements IAuthenticator {
|
||||
|
||||
private Map<String, String> m_userPwds;
|
||||
private Map<String, byte[]> m_userPwds;
|
||||
|
||||
MockAuthenticator(Map<String, String> userPwds) {
|
||||
MockAuthenticator(Map<String, byte[]> userPwds) {
|
||||
m_userPwds = userPwds;
|
||||
}
|
||||
|
||||
public boolean checkValid(String username, String password) {
|
||||
public boolean checkValid(String username, byte[] password) {
|
||||
if (!m_userPwds.containsKey(username)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ public class ProtocolProcessorTest {
|
||||
final static String BAD_FORMATTED_TOPIC = "#MQTTClient";
|
||||
|
||||
final static String TEST_USER = "fakeuser";
|
||||
final static String TEST_PWD = "fakepwd";
|
||||
final static byte[] TEST_PWD = "fakepwd".getBytes();
|
||||
final static String EVIL_TEST_USER = "eviluser";
|
||||
final static String EVIL_TEST_PWD = "unsecret";
|
||||
final static byte[] EVIL_TEST_PWD = "unsecret".getBytes();
|
||||
|
||||
final static List<InterceptHandler> EMPTY_OBSERVERS = Collections.emptyList();
|
||||
final static BrokerInterceptor NO_OBSERVERS_INTERCEPTOR = new BrokerInterceptor(EMPTY_OBSERVERS);
|
||||
@@ -164,7 +164,7 @@ public class ProtocolProcessorTest {
|
||||
m_sessionStore = memStorage;
|
||||
//m_storageService.initStore();
|
||||
|
||||
Map<String, String> users = new HashMap<>();
|
||||
Map<String, byte[]> users = new HashMap<>();
|
||||
users.put(TEST_USER, TEST_PWD);
|
||||
m_mockAuthenticator = new MockAuthenticator(users);
|
||||
|
||||
@@ -202,7 +202,7 @@ public class ProtocolProcessorTest {
|
||||
connMsg.setClientID("123");
|
||||
connMsg.setWillFlag(true);
|
||||
connMsg.setWillTopic("topic");
|
||||
connMsg.setWillMessage("Topic message");
|
||||
connMsg.setWillMessage("Topic message".getBytes());
|
||||
|
||||
|
||||
//Exercise
|
||||
|
||||
+3
-3
@@ -31,7 +31,7 @@ public class FileAuthenticatorTest {
|
||||
String file = getClass().getResource("/password_file.conf").getPath();
|
||||
IAuthenticator auth = new FileAuthenticator(null, file);
|
||||
|
||||
assertTrue(auth.checkValid("testuser", "passwd"));
|
||||
assertTrue(auth.checkValid("testuser", "passwd".getBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -39,14 +39,14 @@ public class FileAuthenticatorTest {
|
||||
String file = getClass().getResource("/password_file.conf").getPath();
|
||||
IAuthenticator auth = new FileAuthenticator(null, file);
|
||||
|
||||
assertFalse(auth.checkValid("testuser2", "passwd"));
|
||||
assertFalse(auth.checkValid("testuser2", "passwd".getBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadPasswordFile_verifyDirectoryRef() {
|
||||
IAuthenticator auth = new FileAuthenticator("", "");
|
||||
|
||||
assertFalse(auth.checkValid("testuser2", "passwd"));
|
||||
assertFalse(auth.checkValid("testuser2", "passwd".getBytes()));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user