Search in sources :

Example 1 with BadWordController

use of games.strategy.engine.lobby.server.db.BadWordController in project triplea by triplea-game.

the class LobbyLoginValidatorIntegrationTest method testAnonymousLoginBadName.

@Test
public void testAnonymousLoginBadName() {
    final String name = "bitCh" + Util.createUniqueTimeStamp();
    try {
        new BadWordController().addBadWord("bitCh");
    } catch (final Exception ignore) {
    // this is probably a duplicate insertion error, we can ignore that as it only means we already added the bad
    // word previously
    }
    assertEquals(LobbyLoginValidator.ErrorMessages.THATS_NOT_A_NICE_NAME, generateChallenge(name, new HashedPassword(md5Crypt("foo"))).apply(challenge -> new HashMap<>(Collections.singletonMap(LobbyLoginValidator.ANONYMOUS_LOGIN, Boolean.TRUE.toString()))));
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) SocketAddress(java.net.SocketAddress) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Integration(games.strategy.test.Integration) HashMap(java.util.HashMap) Function(java.util.function.Function) LobbyServer(games.strategy.engine.lobby.server.LobbyServer) MacFinder(games.strategy.net.MacFinder) HashedPassword(games.strategy.engine.lobby.server.db.HashedPassword) Matchers.containsStringIgnoringCase(org.hamcrest.Matchers.containsStringIgnoringCase) Map(java.util.Map) RsaAuthenticator.hashPasswordWithSalt(games.strategy.engine.lobby.server.login.RsaAuthenticator.hashPasswordWithSalt) DBUser(games.strategy.engine.lobby.server.userDB.DBUser) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) BCrypt(org.mindrot.jbcrypt.BCrypt) Nullable(javax.annotation.Nullable) UserController(games.strategy.engine.lobby.server.db.UserController) ILoginValidator(games.strategy.net.ILoginValidator) InetSocketAddress(java.net.InetSocketAddress) Util(games.strategy.util.Util) Test(org.junit.jupiter.api.Test) Md5Crypt(games.strategy.util.Md5Crypt) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) BadWordController(games.strategy.engine.lobby.server.db.BadWordController) Collections(java.util.Collections) HashMap(java.util.HashMap) BadWordController(games.strategy.engine.lobby.server.db.BadWordController) HashedPassword(games.strategy.engine.lobby.server.db.HashedPassword) Test(org.junit.jupiter.api.Test)

Aggregations

LobbyServer (games.strategy.engine.lobby.server.LobbyServer)1 BadWordController (games.strategy.engine.lobby.server.db.BadWordController)1 HashedPassword (games.strategy.engine.lobby.server.db.HashedPassword)1 UserController (games.strategy.engine.lobby.server.db.UserController)1 RsaAuthenticator.hashPasswordWithSalt (games.strategy.engine.lobby.server.login.RsaAuthenticator.hashPasswordWithSalt)1 DBUser (games.strategy.engine.lobby.server.userDB.DBUser)1 ILoginValidator (games.strategy.net.ILoginValidator)1 MacFinder (games.strategy.net.MacFinder)1 Integration (games.strategy.test.Integration)1 Md5Crypt (games.strategy.util.Md5Crypt)1 Util (games.strategy.util.Util)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Nullable (javax.annotation.Nullable)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1