mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-26 18:47:37 +01:00
Removed a test for antibot service.
This commit is contained in:
parent
b3fd6170fe
commit
cbd9add1b7
@ -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
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user