#1119 email show permission and privacy improvements (#1312)

* #1119 new permission and email hider

* Updated commands.md

* Improved email hiding method

* Revert "Improved email hiding method"

This reverts commit cb60d7b

* New config option, updated tests, config.md and permission_nodes.md

* Moved to service import, fixed typo and updated config.md

* Removed unused imports O.o
This commit is contained in:
HexelDev
2017-08-12 16:20:06 +02:00
committed by Gabriele C
parent acfc35283d
commit 1dfb3575b5
9 changed files with 88 additions and 28 deletions
@@ -4,6 +4,7 @@ import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.bukkit.entity.Player;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,7 +31,7 @@ public class ShowEmailCommandTest {
private ShowEmailCommand command;
@Mock
private CommonService commandService;
private CommonService commonService;
@Mock
private PlayerCache playerCache;
@@ -41,12 +42,28 @@ public class ShowEmailCommandTest {
Player sender = mock(Player.class);
given(sender.getName()).willReturn(USERNAME);
given(playerCache.getAuth(USERNAME)).willReturn(newAuthWithEmail(CURRENT_EMAIL));
given(commonService.getProperty(SecuritySettings.USE_EMAIL_MASKING)).willReturn(false);
// when
command.executeCommand(sender, Collections.emptyList());
// then
verify(commandService).send(sender, MessageKey.EMAIL_SHOW, CURRENT_EMAIL);
verify(commonService).send(sender, MessageKey.EMAIL_SHOW, CURRENT_EMAIL);
}
@Test
public void shouldShowHiddenEmailMessage() {
// given
Player sender = mock(Player.class);
given(sender.getName()).willReturn(USERNAME);
given(playerCache.getAuth(USERNAME)).willReturn(newAuthWithEmail(CURRENT_EMAIL));
given(commonService.getProperty(SecuritySettings.USE_EMAIL_MASKING)).willReturn(true);
// when
command.executeCommand(sender, Collections.emptyList());
// then
verify(commonService).send(sender, MessageKey.EMAIL_SHOW, "my.***@***mple.com");
}
@Test
@@ -60,7 +77,7 @@ public class ShowEmailCommandTest {
command.executeCommand(sender, Collections.emptyList());
// then
verify(commandService).send(sender, MessageKey.SHOW_NO_EMAIL);
verify(commonService).send(sender, MessageKey.SHOW_NO_EMAIL);
}
private static PlayerAuth newAuthWithEmail(String email) {