Removed a test for antibot service.

This commit is contained in:
DNx5 2016-10-18 03:46:15 +07:00
parent b3fd6170fe
commit cbd9add1b7
3 changed files with 4 additions and 25 deletions

View File

@ -161,7 +161,7 @@ public class AntiBotService implements SettingsDependent {
if (lastFlaggedJoin == null) { if (lastFlaggedJoin == null) {
lastFlaggedJoin = Instant.now(); lastFlaggedJoin = Instant.now();
} }
if (ChronoUnit.SECONDS.between(Instant.now(), lastFlaggedJoin) <= 5) { if (ChronoUnit.SECONDS.between(lastFlaggedJoin, Instant.now()) <= 5) {
flagged++; flagged++;
} else { } else {
// reset to 1 because this player is also count as not registered // reset to 1 because this player is also count as not registered

View File

@ -565,7 +565,6 @@ public class PlayerListenerTest {
verify(onJoinVerifier).checkKickNonRegistered(true); verify(onJoinVerifier).checkKickNonRegistered(true);
verify(onJoinVerifier).checkNameCasing(player, auth); verify(onJoinVerifier).checkNameCasing(player, auth);
verify(onJoinVerifier).checkPlayerCountry(true, ip); verify(onJoinVerifier).checkPlayerCountry(true, ip);
verify(antiBotService).handlePlayerJoin();
verify(teleportationService).teleportOnJoin(player); verify(teleportationService).teleportOnJoin(player);
verifyNoModifyingCalls(event); verifyNoModifyingCalls(event);
} }

View File

@ -3,7 +3,6 @@ package fr.xephi.authme.service;
import ch.jalu.injector.testing.BeforeInjecting; import ch.jalu.injector.testing.BeforeInjecting;
import ch.jalu.injector.testing.DelayedInjectionRunner; import ch.jalu.injector.testing.DelayedInjectionRunner;
import ch.jalu.injector.testing.InjectDelayed; import ch.jalu.injector.testing.InjectDelayed;
import fr.xephi.authme.ReflectionTestUtils;
import fr.xephi.authme.message.MessageKey; import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages; import fr.xephi.authme.message.Messages;
import fr.xephi.authme.permission.AdminPermission; import fr.xephi.authme.permission.AdminPermission;
@ -152,22 +151,6 @@ public class AntiBotServiceTest {
assertThat(kickWithAuth, equalTo(false)); assertThat(kickWithAuth, equalTo(false));
} }
@Test
public void shouldIncreaseCountAndDecreaseAfterDelay() {
// given - listening antibot
runSyncDelayedTaskWithDelay(bukkitService);
reset(bukkitService);
assertThat(getAntiBotCount(antiBotService), equalTo(0));
// when
antiBotService.handlePlayerJoin();
// then
assertThat(getAntiBotCount(antiBotService), equalTo(1));
runSyncDelayedTaskWithDelay(bukkitService);
assertThat(getAntiBotCount(antiBotService), equalTo(0));
}
@Test @Test
public void shouldActivateAntibotAfterThreshold() { public void shouldActivateAntibotAfterThreshold() {
// given // given
@ -178,12 +161,12 @@ public class AntiBotServiceTest {
runSyncDelayedTaskWithDelay(bukkitService); runSyncDelayedTaskWithDelay(bukkitService);
for (int i = 0; i < sensitivity; ++i) { for (int i = 0; i < sensitivity; ++i) {
antiBotService.handlePlayerJoin(); antiBotService.shouldKick(false);
} }
assertThat(antiBotService.getAntiBotStatus(), equalTo(AntiBotService.AntiBotStatus.LISTENING)); assertThat(antiBotService.getAntiBotStatus(), equalTo(AntiBotService.AntiBotStatus.LISTENING));
// when // when
antiBotService.handlePlayerJoin(); antiBotService.shouldKick(false);
// then // then
assertThat(antiBotService.getAntiBotStatus(), equalTo(AntiBotService.AntiBotStatus.ACTIVE)); assertThat(antiBotService.getAntiBotStatus(), equalTo(AntiBotService.AntiBotStatus.ACTIVE));
@ -222,7 +205,4 @@ public class AntiBotServiceTest {
assertThat(antiBotService.getAntiBotStatus(), equalTo(AntiBotService.AntiBotStatus.LISTENING)); assertThat(antiBotService.getAntiBotStatus(), equalTo(AntiBotService.AntiBotStatus.LISTENING));
} }
private static int getAntiBotCount(AntiBotService antiBotService) {
return ReflectionTestUtils.getFieldValue(AntiBotService.class, antiBotService, "antibotPlayers");
}
} }