Add test for the warning if the BungeeCord is enabled

This commit is contained in:
games647 2022-07-06 15:27:49 +02:00
parent 32d92e13c5
commit 0b6c92949c
No known key found for this signature in database
GPG Key ID: BFC68C8708713A88
1 changed files with 21 additions and 3 deletions

View File

@ -36,9 +36,6 @@ public class SettingsWarnerTest {
@Mock
private Settings settings;
@Mock
private AuthMe authMe;
@Mock
private BukkitService bukkitService;
@ -62,6 +59,26 @@ public class SettingsWarnerTest {
verify(logger, times(4)).warning(anyString());
}
@Test
public void shouldWarnBungeeWithoutSpigot() {
Logger logger = TestHelper.setupLogger();
// this cannot be covered above, because it's conflicting with the other settings
given(settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)).willReturn(true);
given(settings.getProperty(EmailSettings.SMTP_PORT)).willReturn(25);
given(settings.getProperty(EmailSettings.PORT25_USE_TLS)).willReturn(false);
given(settings.getProperty(PluginSettings.SESSIONS_ENABLED)).willReturn(false);
given(settings.getProperty(SecuritySettings.PASSWORD_HASH)).willReturn(HashAlgorithm.MD5);
given(settings.getProperty(HooksSettings.BUNGEECORD)).willReturn(true);
given(bukkitService.isBungeeCordConfiguredForSpigot()).willReturn(Optional.of(false));
// when
settingsWarner.logWarningsForMisconfigurations();
// then
verify(logger, times(1)).warning(anyString());
}
@Test
public void shouldNotLogAnyWarning() {
Logger logger = TestHelper.setupLogger();
@ -70,6 +87,7 @@ public class SettingsWarnerTest {
given(settings.getProperty(EmailSettings.PORT25_USE_TLS)).willReturn(false);
given(settings.getProperty(PluginSettings.SESSIONS_ENABLED)).willReturn(false);
given(settings.getProperty(SecuritySettings.PASSWORD_HASH)).willReturn(HashAlgorithm.MD5);
given(settings.getProperty(HooksSettings.BUNGEECORD)).willReturn(false);
given(bukkitService.isBungeeCordConfiguredForSpigot()).willReturn(Optional.empty());
// when