mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-25 03:35:16 +01:00
Merge branch 'master' into task-sync-hotfix
This commit is contained in:
commit
69cd899e2e
4
.github/workflows/maven.yml
vendored
4
.github/workflows/maven.yml
vendored
@ -14,6 +14,4 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
java-version: 1.8
|
java-version: 1.8
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: mvn clean package --file pom.xml
|
run: mvn -B clean package --file pom.xml
|
||||||
- name: Tests with Maven
|
|
||||||
run: mvn test --file pom.xml
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
|
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
|
||||||
<!-- File auto-generated on Tue Apr 23 17:17:02 CEST 2019. See docs/config/config.tpl.md -->
|
<!-- File auto-generated on Thu Oct 17 08:29:25 CEST 2019. See docs/config/config.tpl.md -->
|
||||||
|
|
||||||
## AuthMe Configuration
|
## AuthMe Configuration
|
||||||
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
|
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
|
||||||
with which you can configure various settings. This following is the initial contents of
|
with which you can configure various settings. The following is the initial contents of
|
||||||
the generated config.yml file.
|
the generated config.yml file.
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
@ -70,6 +70,8 @@ DataSource:
|
|||||||
mySQLlastlocYaw: yaw
|
mySQLlastlocYaw: yaw
|
||||||
# Column for storing player LastLocation - Pitch
|
# Column for storing player LastLocation - Pitch
|
||||||
mySQLlastlocPitch: pitch
|
mySQLlastlocPitch: pitch
|
||||||
|
# Column for storing players uuids (optional)
|
||||||
|
mySQLPlayerUUID: ''
|
||||||
# Overrides the size of the DB Connection Pool, default = 10
|
# Overrides the size of the DB Connection Pool, default = 10
|
||||||
poolSize: 10
|
poolSize: 10
|
||||||
# The maximum lifetime of a connection in the pool, default = 1800 seconds
|
# The maximum lifetime of a connection in the pool, default = 1800 seconds
|
||||||
@ -124,10 +126,6 @@ settings:
|
|||||||
# By default we schedule async tasks when talking to the database. If you want
|
# By default we schedule async tasks when talking to the database. If you want
|
||||||
# typical communication with the database to happen synchronously, set this to false
|
# typical communication with the database to happen synchronously, set this to false
|
||||||
useAsyncTasks: true
|
useAsyncTasks: true
|
||||||
# By default we handle the AsyncPlayerPreLoginEvent which makes the plugin faster
|
|
||||||
# but it is incompatible with any permission plugin not included in our compatibility list.
|
|
||||||
# If you have issues with permission checks on player join please disable this option.
|
|
||||||
useAsyncPreLoginEvent: true
|
|
||||||
# The name of the server, used in some placeholders.
|
# The name of the server, used in some placeholders.
|
||||||
serverName: Your Minecraft Server
|
serverName: Your Minecraft Server
|
||||||
restrictions:
|
restrictions:
|
||||||
@ -327,7 +325,7 @@ settings:
|
|||||||
removeJoinMessage: false
|
removeJoinMessage: false
|
||||||
# Should we remove leave messages altogether?
|
# Should we remove leave messages altogether?
|
||||||
removeLeaveMessage: false
|
removeLeaveMessage: false
|
||||||
# Do we need to add potion effect Blinding before login/reigster?
|
# Do we need to add potion effect Blinding before login/register?
|
||||||
applyBlindEffect: false
|
applyBlindEffect: false
|
||||||
# Do we need to prevent people to login with another case?
|
# Do we need to prevent people to login with another case?
|
||||||
# If Xephi is registered, then Xephi can login, but not XEPHI/xephi/XePhI
|
# If Xephi is registered, then Xephi can login, but not XEPHI/xephi/XePhI
|
||||||
@ -578,4 +576,4 @@ To change settings on a running server, save your changes to config.yml and use
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Tue Apr 23 17:17:02 CEST 2019
|
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Thu Oct 17 08:29:25 CEST 2019
|
||||||
|
16
pom.xml
16
pom.xml
@ -205,7 +205,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
<version>0.8.4</version>
|
<version>0.8.5</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>pre-unit-test</id>
|
<id>pre-unit-test</id>
|
||||||
@ -241,7 +241,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>3.1.2</version>
|
<version>3.2.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Generate a jar containing the source javadoc -->
|
<!-- Generate a jar containing the source javadoc -->
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -265,7 +265,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.2.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<finalName>${project.finalNameBase}</finalName>
|
<finalName>${project.finalNameBase}</finalName>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -583,7 +583,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-simple</artifactId>
|
<artifactId>slf4j-simple</artifactId>
|
||||||
<version>1.7.28</version>
|
<version>1.7.29</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -607,7 +607,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.warrenstrange</groupId>
|
<groupId>com.warrenstrange</groupId>
|
||||||
<artifactId>googleauth</artifactId>
|
<artifactId>googleauth</artifactId>
|
||||||
<version>1.2.0</version>
|
<version>1.4.0</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -856,7 +856,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>at.favre.lib</groupId>
|
<groupId>at.favre.lib</groupId>
|
||||||
<artifactId>bcrypt</artifactId>
|
<artifactId>bcrypt</artifactId>
|
||||||
<version>0.8.0</version>
|
<version>0.9.0</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -914,7 +914,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.checkerframework</groupId>
|
<groupId>org.checkerframework</groupId>
|
||||||
<artifactId>checker-qual</artifactId>
|
<artifactId>checker-qual</artifactId>
|
||||||
<version>2.11.1</version>
|
<version>3.0.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -928,7 +928,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>1.4.199</version>
|
<version>1.4.200</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -316,12 +316,12 @@ settings:
|
|||||||
|
|
||||||
# When this setting is enabled, online players can't be kicked out
|
# When this setting is enabled, online players can't be kicked out
|
||||||
# due to "Logged in from another Location"
|
# due to "Logged in from another Location"
|
||||||
# This setting will prevent potetial security exploits.
|
# This setting will prevent potential security exploits.
|
||||||
ForceSingleSession: true
|
ForceSingleSession: true
|
||||||
|
|
||||||
# To activate the restricted user feature you need
|
# To activate the restricted user feature you need
|
||||||
# to enable this option and configure the
|
# to enable this option and configure the
|
||||||
# AllowedRestrctedUser field.
|
# AllowedRestrictedUser field.
|
||||||
AllowRestrictedUser: false
|
AllowRestrictedUser: false
|
||||||
# The restricted user feature will kick players listed below
|
# The restricted user feature will kick players listed below
|
||||||
# if they dont match of the defined ip address.
|
# if they dont match of the defined ip address.
|
||||||
|
@ -13,6 +13,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
/**
|
/**
|
||||||
* AuthMe player data.
|
* AuthMe player data.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:FinalClass") // Justification: class is mocked in multiple tests
|
||||||
public class PlayerAuth {
|
public class PlayerAuth {
|
||||||
|
|
||||||
/** Default email used in the database if the email column is defined to be NOT NULL. */
|
/** Default email used in the database if the email column is defined to be NOT NULL. */
|
||||||
|
@ -170,6 +170,7 @@ public class MySQL extends AbstractSqlDataSource {
|
|||||||
/**
|
/**
|
||||||
* Creates the table or any of its required columns if they don't exist.
|
* Creates the table or any of its required columns if they don't exist.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({"checkstyle:CyclomaticComplexity", "checkstyle:JavaNCSS"})
|
||||||
private void checkTablesAndColumns() throws SQLException {
|
private void checkTablesAndColumns() throws SQLException {
|
||||||
try (Connection con = getConnection(); Statement st = con.createStatement()) {
|
try (Connection con = getConnection(); Statement st = con.createStatement()) {
|
||||||
// Create table with ID column if it doesn't exist
|
// Create table with ID column if it doesn't exist
|
||||||
|
@ -98,6 +98,7 @@ public class SQLite extends AbstractSqlDataSource {
|
|||||||
* @throws SQLException when an SQL error occurs while initializing the database
|
* @throws SQLException when an SQL error occurs while initializing the database
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@SuppressWarnings("checkstyle:CyclomaticComplexity")
|
||||||
protected void setup() throws SQLException {
|
protected void setup() throws SQLException {
|
||||||
try (Statement st = con.createStatement()) {
|
try (Statement st = con.createStatement()) {
|
||||||
// Note: cannot add unique fields later on in SQLite, so we add it on initialization
|
// Note: cannot add unique fields later on in SQLite, so we add it on initialization
|
||||||
|
@ -30,73 +30,55 @@ class WordpressExtension extends MySqlExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the required data to Wordpress tables.
|
||||||
|
*
|
||||||
|
* @param auth the player data
|
||||||
|
* @param id the player id
|
||||||
|
* @param con the sql connection
|
||||||
|
* @throws SQLException .
|
||||||
|
*/
|
||||||
private void saveSpecifics(PlayerAuth auth, int id, Connection con) throws SQLException {
|
private void saveSpecifics(PlayerAuth auth, int id, Connection con) throws SQLException {
|
||||||
String sql = "INSERT INTO " + wordpressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?)";
|
String sql = "INSERT INTO " + wordpressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?)";
|
||||||
try (PreparedStatement pst = con.prepareStatement(sql)) {
|
try (PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
// First Name
|
|
||||||
pst.setInt(1, id);
|
new UserMetaBatchAdder(pst, id)
|
||||||
pst.setString(2, "first_name");
|
.addMetaRow("first_name", "")
|
||||||
pst.setString(3, "");
|
.addMetaRow("last_name", "")
|
||||||
pst.addBatch();
|
.addMetaRow("nickname", auth.getNickname())
|
||||||
// Last Name
|
.addMetaRow("description", "")
|
||||||
pst.setInt(1, id);
|
.addMetaRow("rich_editing", "true")
|
||||||
pst.setString(2, "last_name");
|
.addMetaRow("comment_shortcuts", "false")
|
||||||
pst.setString(3, "");
|
.addMetaRow("admin_color", "fresh")
|
||||||
pst.addBatch();
|
.addMetaRow("use_ssl", "0")
|
||||||
// Nick Name
|
.addMetaRow("show_admin_bar_front", "true")
|
||||||
pst.setInt(1, id);
|
.addMetaRow(wordpressPrefix + "capabilities", "a:1:{s:10:\"subscriber\";b:1;}")
|
||||||
pst.setString(2, "nickname");
|
.addMetaRow(wordpressPrefix + "user_level", "0")
|
||||||
pst.setString(3, auth.getNickname());
|
.addMetaRow("default_password_nag", "");
|
||||||
pst.addBatch();
|
|
||||||
// Description
|
|
||||||
pst.setInt(1, id);
|
|
||||||
pst.setString(2, "description");
|
|
||||||
pst.setString(3, "");
|
|
||||||
pst.addBatch();
|
|
||||||
// Rich_Editing
|
|
||||||
pst.setInt(1, id);
|
|
||||||
pst.setString(2, "rich_editing");
|
|
||||||
pst.setString(3, "true");
|
|
||||||
pst.addBatch();
|
|
||||||
// Comments_Shortcuts
|
|
||||||
pst.setInt(1, id);
|
|
||||||
pst.setString(2, "comment_shortcuts");
|
|
||||||
pst.setString(3, "false");
|
|
||||||
pst.addBatch();
|
|
||||||
// admin_color
|
|
||||||
pst.setInt(1, id);
|
|
||||||
pst.setString(2, "admin_color");
|
|
||||||
pst.setString(3, "fresh");
|
|
||||||
pst.addBatch();
|
|
||||||
// use_ssl
|
|
||||||
pst.setInt(1, id);
|
|
||||||
pst.setString(2, "use_ssl");
|
|
||||||
pst.setString(3, "0");
|
|
||||||
pst.addBatch();
|
|
||||||
// show_admin_bar_front
|
|
||||||
pst.setInt(1, id);
|
|
||||||
pst.setString(2, "show_admin_bar_front");
|
|
||||||
pst.setString(3, "true");
|
|
||||||
pst.addBatch();
|
|
||||||
// wp_capabilities
|
|
||||||
pst.setInt(1, id);
|
|
||||||
pst.setString(2, wordpressPrefix + "capabilities");
|
|
||||||
pst.setString(3, "a:1:{s:10:\"subscriber\";b:1;}");
|
|
||||||
pst.addBatch();
|
|
||||||
// wp_user_level
|
|
||||||
pst.setInt(1, id);
|
|
||||||
pst.setString(2, wordpressPrefix + "user_level");
|
|
||||||
pst.setString(3, "0");
|
|
||||||
pst.addBatch();
|
|
||||||
// default_password_nag
|
|
||||||
pst.setInt(1, id);
|
|
||||||
pst.setString(2, "default_password_nag");
|
|
||||||
pst.setString(3, "");
|
|
||||||
pst.addBatch();
|
|
||||||
|
|
||||||
// Execute queries
|
// Execute queries
|
||||||
pst.executeBatch();
|
pst.executeBatch();
|
||||||
pst.clearBatch();
|
pst.clearBatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Helper to add batch entries to the wrapped prepared statement. */
|
||||||
|
private static final class UserMetaBatchAdder {
|
||||||
|
|
||||||
|
private final PreparedStatement pst;
|
||||||
|
private final int userId;
|
||||||
|
|
||||||
|
UserMetaBatchAdder(PreparedStatement pst, int userId) {
|
||||||
|
this.pst = pst;
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserMetaBatchAdder addMetaRow(String metaKey, String metaValue) throws SQLException {
|
||||||
|
pst.setInt(1, userId);
|
||||||
|
pst.setString(2, metaKey);
|
||||||
|
pst.setString(3, metaValue);
|
||||||
|
pst.addBatch();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,11 @@ class InventoryPacketAdapter extends PacketAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers itself to ProtocolLib and blanks out the inventory packet to any applicable players.
|
||||||
|
*
|
||||||
|
* @param bukkitService the bukkit service (for retrieval of online players)
|
||||||
|
*/
|
||||||
public void register(BukkitService bukkitService) {
|
public void register(BukkitService bukkitService) {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(this);
|
ProtocolLibrary.getProtocolManager().addPacketListener(this);
|
||||||
|
|
||||||
@ -85,6 +90,11 @@ class InventoryPacketAdapter extends PacketAdapter {
|
|||||||
ProtocolLibrary.getProtocolManager().removePacketListener(this);
|
ProtocolLibrary.getProtocolManager().removePacketListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a blanked out packet to the given player in order to hide the inventory.
|
||||||
|
*
|
||||||
|
* @param player the player to send the blank inventory packet to
|
||||||
|
*/
|
||||||
public void sendBlankInventoryPacket(Player player) {
|
public void sendBlankInventoryPacket(Player player) {
|
||||||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
PacketContainer inventoryPacket = protocolManager.createPacket(PacketType.Play.Server.WINDOW_ITEMS);
|
PacketContainer inventoryPacket = protocolManager.createPacket(PacketType.Play.Server.WINDOW_ITEMS);
|
||||||
|
@ -30,8 +30,8 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent
|
|||||||
private boolean isEnabled;
|
private boolean isEnabled;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
BungeeReceiver(final AuthMe plugin, final BukkitService bukkitService, final Management management,
|
BungeeReceiver(AuthMe plugin, BukkitService bukkitService, Management management,
|
||||||
final DataSource dataSource, final Settings settings) {
|
DataSource dataSource, Settings settings) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.bukkitService = bukkitService;
|
this.bukkitService = bukkitService;
|
||||||
this.management = management;
|
this.management = management;
|
||||||
@ -51,6 +51,11 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes the given data input and attempts to translate it to a message for the "AuthMe.v2.Broadcast" channel.
|
||||||
|
*
|
||||||
|
* @param in the input to handle
|
||||||
|
*/
|
||||||
private void handleBroadcast(final ByteArrayDataInput in) {
|
private void handleBroadcast(final ByteArrayDataInput in) {
|
||||||
// Read data byte array
|
// Read data byte array
|
||||||
final short dataLength = in.readShort();
|
final short dataLength = in.readShort();
|
||||||
@ -91,7 +96,12 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handle(final ByteArrayDataInput in) {
|
/**
|
||||||
|
* Processes the given data input and attempts to translate it to a message for the "AuthMe.v2" channel.
|
||||||
|
*
|
||||||
|
* @param in the input to handle
|
||||||
|
*/
|
||||||
|
private void handle(ByteArrayDataInput in) {
|
||||||
// Parse type
|
// Parse type
|
||||||
final String typeId = in.readUTF();
|
final String typeId = in.readUTF();
|
||||||
final Optional<MessageType> type = MessageType.fromId(typeId);
|
final Optional<MessageType> type = MessageType.fromId(typeId);
|
||||||
|
@ -97,7 +97,7 @@ public final class RegistrationSettings implements SettingsHolder {
|
|||||||
public static final Property<Boolean> REMOVE_LEAVE_MESSAGE =
|
public static final Property<Boolean> REMOVE_LEAVE_MESSAGE =
|
||||||
newProperty("settings.removeLeaveMessage", false);
|
newProperty("settings.removeLeaveMessage", false);
|
||||||
|
|
||||||
@Comment("Do we need to add potion effect Blinding before login/reigster?")
|
@Comment("Do we need to add potion effect Blinding before login/register?")
|
||||||
public static final Property<Boolean> APPLY_BLIND_EFFECT =
|
public static final Property<Boolean> APPLY_BLIND_EFFECT =
|
||||||
newProperty("settings.applyBlindEffect", false);
|
newProperty("settings.applyBlindEffect", false);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ section:
|
|||||||
# -------------------------------------------------------
|
# -------------------------------------------------------
|
||||||
# Vous pouvez traduire tous les textes d'aide en utilisant la syntaxe ci-dessous.
|
# Vous pouvez traduire tous les textes d'aide en utilisant la syntaxe ci-dessous.
|
||||||
# Par exemple, pour traduire l'aide du "/authme reload" créez une section nommée "authme.reload", ou "login" pour "/login".
|
# Par exemple, pour traduire l'aide du "/authme reload" créez une section nommée "authme.reload", ou "login" pour "/login".
|
||||||
# Si la commande a des arguments, vour pouvez utiliser "arg1" pour traduire le premier argument, "arg2" pour le 2ème, ainsi de suite.
|
# Si la commande a des arguments, vous pouvez utiliser "arg1" pour traduire le premier argument, "arg2" pour le 2ème, ainsi de suite.
|
||||||
# Les sections non traduites auront leur texte par défaut (en anglais), il n'est donc pas obligatoire de tout traduire.
|
# Les sections non traduites auront leur texte par défaut (en anglais), il n'est donc pas obligatoire de tout traduire.
|
||||||
# Important: Il faut mettre la commande principale (authme) avant sa sous-commande (ex. "authme.register" pour "/authme register")
|
# Important: Il faut mettre la commande principale (authme) avant sa sous-commande (ex. "authme.register" pour "/authme register")
|
||||||
commands:
|
commands:
|
||||||
|
@ -82,7 +82,7 @@ on_join_validation:
|
|||||||
country_banned: 'Votre pays est banni de ce serveur.'
|
country_banned: 'Votre pays est banni de ce serveur.'
|
||||||
not_owner_error: 'Vous n''êtes pas le propriétaire de ce compte. Veuillez utiliser un autre pseudo !'
|
not_owner_error: 'Vous n''êtes pas le propriétaire de ce compte. Veuillez utiliser un autre pseudo !'
|
||||||
invalid_name_case: 'Veuillez vous connecter avec "%valid" et non pas avec "%invalid".'
|
invalid_name_case: 'Veuillez vous connecter avec "%valid" et non pas avec "%invalid".'
|
||||||
quick_command: '&cUtilisation trop rapide de commande! Veuillez vous reconnecter et attendre un peu avant d''executer une commande.'
|
quick_command: '&cUtilisation trop rapide de commande! Veuillez vous reconnecter et attendre un peu avant d''exécuter une commande.'
|
||||||
|
|
||||||
# Email
|
# Email
|
||||||
email:
|
email:
|
||||||
@ -122,7 +122,7 @@ captcha:
|
|||||||
usage_captcha: '&cTrop de tentatives de connexion ont échoué, faites: /captcha %captcha_code'
|
usage_captcha: '&cTrop de tentatives de connexion ont échoué, faites: /captcha %captcha_code'
|
||||||
wrong_captcha: '&cCaptcha incorrect, écrivez de nouveau: /captcha %captcha_code'
|
wrong_captcha: '&cCaptcha incorrect, écrivez de nouveau: /captcha %captcha_code'
|
||||||
valid_captcha: '&aCaptcha validé! Vous pouvez maintenant réessayer de vous connecter.'
|
valid_captcha: '&aCaptcha validé! Vous pouvez maintenant réessayer de vous connecter.'
|
||||||
captcha_for_registration: 'Avant de vous inscrire veuillez rentrer un captcha en faisant "/captcha %captcha_code"'
|
captcha_for_registration: 'Avant de vous inscrire, veuillez rentrer un captcha en faisant "/captcha %captcha_code"'
|
||||||
register_captcha_valid: '&aCaptcha validé! Vous pouvez maintenant vous inscrire.'
|
register_captcha_valid: '&aCaptcha validé! Vous pouvez maintenant vous inscrire.'
|
||||||
|
|
||||||
# Verification code
|
# Verification code
|
||||||
|
@ -6,9 +6,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -95,33 +92,6 @@ public final class TestHelper {
|
|||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check that a class only has a hidden, zero-argument constructor, preventing the
|
|
||||||
* instantiation of such classes (utility classes). Invokes the hidden constructor
|
|
||||||
* as to register the code coverage.
|
|
||||||
*
|
|
||||||
* @param clazz The class to validate
|
|
||||||
*/
|
|
||||||
public static void validateHasOnlyPrivateEmptyConstructor(Class<?> clazz) {
|
|
||||||
Constructor<?>[] constructors = clazz.getDeclaredConstructors();
|
|
||||||
if (constructors.length > 1) {
|
|
||||||
throw new IllegalStateException("Class " + clazz.getSimpleName() + " has more than one constructor");
|
|
||||||
} else if (constructors[0].getParameterTypes().length != 0) {
|
|
||||||
throw new IllegalStateException("Constructor of " + clazz + " does not have empty parameter list");
|
|
||||||
} else if (!Modifier.isPrivate(constructors[0].getModifiers())) {
|
|
||||||
throw new IllegalStateException("Constructor of " + clazz + " is not private");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ugly hack to get coverage on the private constructors
|
|
||||||
// http://stackoverflow.com/questions/14077842/how-to-test-a-private-constructor-in-java-application
|
|
||||||
try {
|
|
||||||
constructors[0].setAccessible(true);
|
|
||||||
constructors[0].newInstance();
|
|
||||||
} catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
|
||||||
throw new UnsupportedOperationException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the player mock to return the given IP address.
|
* Configures the player mock to return the given IP address.
|
||||||
*
|
*
|
||||||
|
@ -24,11 +24,11 @@ import org.mockito.InjectMocks;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
import static fr.xephi.authme.IsEqualByReflectionMatcher.hasEqualValuesOnAllFields;
|
import static fr.xephi.authme.IsEqualByReflectionMatcher.hasEqualValuesOnAllFields;
|
||||||
import static org.hamcrest.Matchers.contains;
|
import static org.hamcrest.Matchers.contains;
|
||||||
@ -43,7 +43,7 @@ import static org.mockito.BDDMockito.given;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.only;
|
import static org.mockito.Mockito.only;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -478,7 +478,7 @@ public class AuthMeApiTest {
|
|||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verify(dataSource, only()).isAuthAvailable(name);
|
verify(dataSource, only()).isAuthAvailable(name);
|
||||||
verifyZeroInteractions(management, passwordSecurity);
|
verifyNoInteractions(management, passwordSecurity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package fr.xephi.authme.command;
|
package fr.xephi.authme.command;
|
||||||
|
|
||||||
import fr.xephi.authme.TestHelper;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -83,12 +82,6 @@ public class CommandUtilsTest {
|
|||||||
checkArgumentCount(command, 1, 3);
|
checkArgumentCount(command, 1, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenConstructor() {
|
|
||||||
// given / when / then
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(CommandUtils.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldFormatSimpleArgument() {
|
public void shouldFormatSimpleArgument() {
|
||||||
// given
|
// given
|
||||||
|
@ -33,7 +33,7 @@ import static org.mockito.BDDMockito.given;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +64,7 @@ public class HelpCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(sender).sendMessage(argThat(containsString("Could not get base command")));
|
verify(sender).sendMessage(argThat(containsString("Could not get base command")));
|
||||||
verifyZeroInteractions(helpProvider);
|
verifyNoInteractions(helpProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -102,7 +102,7 @@ public class HelpCommandTest {
|
|||||||
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
|
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
|
||||||
verify(sender).sendMessage(captor.capture());
|
verify(sender).sendMessage(captor.capture());
|
||||||
assertThat(removeColors(captor.getValue()), containsString("Unknown command"));
|
assertThat(removeColors(captor.getValue()), containsString("Unknown command"));
|
||||||
verifyZeroInteractions(helpProvider);
|
verifyNoInteractions(helpProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -17,7 +17,7 @@ import java.util.Arrays;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link ChangePasswordAdminCommand}.
|
* Test for {@link ChangePasswordAdminCommand}.
|
||||||
@ -68,6 +68,6 @@ public class ChangePasswordAdminCommandTest {
|
|||||||
// then
|
// then
|
||||||
verify(validationService).validatePassword(pass, name);
|
verify(validationService).validatePassword(pass, name);
|
||||||
verify(commonService).send(sender, MessageKey.INVALID_PASSWORD_LENGTH, "7");
|
verify(commonService).send(sender, MessageKey.INVALID_PASSWORD_LENGTH, "7");
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ import static org.mockito.BDDMockito.given;
|
|||||||
import static org.mockito.Mockito.doThrow;
|
import static org.mockito.Mockito.doThrow;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,7 +67,7 @@ public class ConverterCommandTest {
|
|||||||
// then
|
// then
|
||||||
String converters = String.join(", ", ConverterCommand.CONVERTERS.keySet());
|
String converters = String.join(", ", ConverterCommand.CONVERTERS.keySet());
|
||||||
verify(sender).sendMessage(argThat(containsString(converters)));
|
verify(sender).sendMessage(argThat(containsString(converters)));
|
||||||
verifyZeroInteractions(commonService, converterFactory, bukkitService);
|
verifyNoInteractions(commonService, converterFactory, bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -81,7 +81,7 @@ public class ConverterCommandTest {
|
|||||||
// then
|
// then
|
||||||
String converters = String.join(", ", ConverterCommand.CONVERTERS.keySet());
|
String converters = String.join(", ", ConverterCommand.CONVERTERS.keySet());
|
||||||
verify(sender).sendMessage(argThat(containsString(converters)));
|
verify(sender).sendMessage(argThat(containsString(converters)));
|
||||||
verifyZeroInteractions(commonService, converterFactory, bukkitService);
|
verifyNoInteractions(commonService, converterFactory, bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -18,7 +18,7 @@ import static org.hamcrest.Matchers.containsString;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,7 +53,7 @@ public class ForceLoginCommandTest {
|
|||||||
// then
|
// then
|
||||||
verify(bukkitService).getPlayerExact(playerName);
|
verify(bukkitService).getPlayerExact(playerName);
|
||||||
verify(sender).sendMessage("Player needs to be online!");
|
verify(sender).sendMessage("Player needs to be online!");
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -69,7 +69,7 @@ public class ForceLoginCommandTest {
|
|||||||
// then
|
// then
|
||||||
verify(bukkitService).getPlayerExact(playerName);
|
verify(bukkitService).getPlayerExact(playerName);
|
||||||
verify(sender).sendMessage("Player needs to be online!");
|
verify(sender).sendMessage("Player needs to be online!");
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -87,7 +87,7 @@ public class ForceLoginCommandTest {
|
|||||||
// then
|
// then
|
||||||
verify(bukkitService).getPlayerExact(playerName);
|
verify(bukkitService).getPlayerExact(playerName);
|
||||||
verify(sender).sendMessage(argThat(containsString("You cannot force login the player")));
|
verify(sender).sendMessage(argThat(containsString("You cannot force login the player")));
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -19,7 +19,7 @@ import static org.junit.Assert.assertThat;
|
|||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +45,7 @@ public class PurgeCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(sender).sendMessage(argThat(containsString("The value you've entered is invalid")));
|
verify(sender).sendMessage(argThat(containsString("The value you've entered is invalid")));
|
||||||
verifyZeroInteractions(purgeService);
|
verifyNoInteractions(purgeService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -59,7 +59,7 @@ public class PurgeCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(sender).sendMessage(argThat(containsString("You can only purge data older than 30 days")));
|
verify(sender).sendMessage(argThat(containsString("You can only purge data older than 30 days")));
|
||||||
verifyZeroInteractions(purgeService);
|
verifyNoInteractions(purgeService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -18,7 +18,7 @@ import static org.hamcrest.Matchers.containsString;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,7 +52,7 @@ public class PurgePlayerCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(sender).sendMessage(argThat(containsString("This player is still registered")));
|
verify(sender).sendMessage(argThat(containsString("This player is still registered")));
|
||||||
verifyZeroInteractions(purgeExecutor);
|
verifyNoInteractions(purgeExecutor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -22,8 +22,8 @@ import static org.mockito.BDDMockito.given;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link SetEmailCommand}.
|
* Test for {@link SetEmailCommand}.
|
||||||
@ -63,7 +63,7 @@ public class SetEmailCommandTest {
|
|||||||
// then
|
// then
|
||||||
verify(validationService).validateEmail(email);
|
verify(validationService).validateEmail(email);
|
||||||
verify(commandService).send(sender, MessageKey.INVALID_EMAIL);
|
verify(commandService).send(sender, MessageKey.INVALID_EMAIL);
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -107,7 +107,7 @@ public class SetEmailCommandTest {
|
|||||||
verify(validationService).isEmailFreeForRegistration(email, sender);
|
verify(validationService).isEmailFreeForRegistration(email, sender);
|
||||||
verify(commandService).send(sender, MessageKey.EMAIL_ALREADY_USED_ERROR);
|
verify(commandService).send(sender, MessageKey.EMAIL_ALREADY_USED_ERROR);
|
||||||
verifyNoMoreInteractions(dataSource);
|
verifyNoMoreInteractions(dataSource);
|
||||||
verifyZeroInteractions(auth);
|
verifyNoInteractions(auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -18,7 +18,7 @@ import java.util.Collections;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link UpdateHelpMessagesCommand}.
|
* Test for {@link UpdateHelpMessagesCommand}.
|
||||||
@ -65,6 +65,6 @@ public class UpdateHelpMessagesCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(sender).sendMessage("Could not update help file: Couldn't do the thing");
|
verify(sender).sendMessage("Could not update help file: Couldn't do the thing");
|
||||||
verifyZeroInteractions(helpMessagesService);
|
verifyNoInteractions(helpMessagesService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,6 @@ public class DebugSectionUtilsTest {
|
|||||||
assertThat(DebugSectionUtils.formatLocation(null), equalTo("null"));
|
assertThat(DebugSectionUtils.formatLocation(null), equalTo("null"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenConstructor() {
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(DebugSectionUtils.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldFetchMapInLimboService() {
|
public void shouldFetchMapInLimboService() {
|
||||||
// given
|
// given
|
||||||
|
@ -19,7 +19,7 @@ import static org.hamcrest.Matchers.equalTo;
|
|||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link AddEmailCommand}.
|
* Test for {@link AddEmailCommand}.
|
||||||
@ -45,7 +45,7 @@ public class AddEmailCommandTest {
|
|||||||
command.executeCommand(sender, Collections.emptyList());
|
command.executeCommand(sender, Collections.emptyList());
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -71,7 +71,7 @@ public class AddEmailCommandTest {
|
|||||||
command.executeCommand(sender, Arrays.asList(email, "wrongConf"));
|
command.executeCommand(sender, Arrays.asList(email, "wrongConf"));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
verify(commandService).send(sender, MessageKey.CONFIRM_EMAIL_MESSAGE);
|
verify(commandService).send(sender, MessageKey.CONFIRM_EMAIL_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import static org.junit.Assert.assertThat;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,7 +52,7 @@ public class ChangeEmailCommandTest {
|
|||||||
command.executeCommand(sender, Collections.emptyList());
|
command.executeCommand(sender, Collections.emptyList());
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -68,7 +68,7 @@ public class ChangeEmailCommandTest {
|
|||||||
// then
|
// then
|
||||||
verify(codeManager).codeExistOrGenerateNew(name);
|
verify(codeManager).codeExistOrGenerateNew(name);
|
||||||
verify(commonService).send(player, MessageKey.VERIFICATION_CODE_REQUIRED);
|
verify(commonService).send(player, MessageKey.VERIFICATION_CODE_REQUIRED);
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -21,7 +21,7 @@ import java.util.Collections;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link EmailSetPasswordCommand}.
|
* Tests for {@link EmailSetPasswordCommand}.
|
||||||
@ -102,7 +102,7 @@ public class EmailSetPasswordCommandTest {
|
|||||||
command.runCommand(player, Collections.singletonList("abc123"));
|
command.runCommand(player, Collections.singletonList("abc123"));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(validationService, dataSource);
|
verifyNoInteractions(validationService, dataSource);
|
||||||
verify(commonService).send(player, MessageKey.CHANGE_PASSWORD_EXPIRED);
|
verify(commonService).send(player, MessageKey.CHANGE_PASSWORD_EXPIRED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,8 @@ import static org.mockito.ArgumentMatchers.anyString;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link RecoverEmailCommand}.
|
* Test for {@link RecoverEmailCommand}.
|
||||||
@ -89,7 +89,7 @@ public class RecoverEmailCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(commonService).send(sender, MessageKey.INCOMPLETE_EMAIL_SETTINGS);
|
verify(commonService).send(sender, MessageKey.INCOMPLETE_EMAIL_SETTINGS);
|
||||||
verifyZeroInteractions(dataSource, passwordSecurity);
|
verifyNoInteractions(dataSource, passwordSecurity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -106,7 +106,7 @@ public class RecoverEmailCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(emailService).hasAllInformation();
|
verify(emailService).hasAllInformation();
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
verify(commonService).send(sender, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
verify(commonService).send(sender, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import static org.hamcrest.Matchers.equalTo;
|
|||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,7 +43,7 @@ public class LoginCommandTest {
|
|||||||
command.executeCommand(sender, Collections.emptyList());
|
command.executeCommand(sender, Collections.emptyList());
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
verify(sender).sendMessage(argThat(containsString("/authme forcelogin <player>")));
|
verify(sender).sendMessage(argThat(containsString("/authme forcelogin <player>")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import java.util.Collections;
|
|||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +41,7 @@ public class LogoutCommandTest {
|
|||||||
command.executeCommand(sender, new ArrayList<String>());
|
command.executeCommand(sender, new ArrayList<String>());
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
verify(sender).sendMessage(argThat(containsString("only for players")));
|
verify(sender).sendMessage(argThat(containsString("only for players")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ import static org.mockito.ArgumentMatchers.eq;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,7 +86,7 @@ public class RegisterCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(sender).sendMessage(argThat(containsString("Player only!")));
|
verify(sender).sendMessage(argThat(containsString("Player only!")));
|
||||||
verifyZeroInteractions(management, emailService);
|
verifyNoInteractions(management, emailService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -102,7 +102,7 @@ public class RegisterCommandTest {
|
|||||||
verify(registrationCaptchaManager).isCaptchaRequired("test2");
|
verify(registrationCaptchaManager).isCaptchaRequired("test2");
|
||||||
verify(management).performRegister(eq(RegistrationMethod.TWO_FACTOR_REGISTRATION),
|
verify(management).performRegister(eq(RegistrationMethod.TWO_FACTOR_REGISTRATION),
|
||||||
argThat(hasEqualValuesOnAllFields(TwoFactorRegisterParams.of(player))));
|
argThat(hasEqualValuesOnAllFields(TwoFactorRegisterParams.of(player))));
|
||||||
verifyZeroInteractions(emailService);
|
verifyNoInteractions(emailService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -115,7 +115,7 @@ public class RegisterCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(commonService).send(player, MessageKey.USAGE_REGISTER);
|
verify(commonService).send(player, MessageKey.USAGE_REGISTER);
|
||||||
verifyZeroInteractions(management, emailService);
|
verifyNoInteractions(management, emailService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -130,7 +130,7 @@ public class RegisterCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(commonService).send(player, MessageKey.USAGE_REGISTER);
|
verify(commonService).send(player, MessageKey.USAGE_REGISTER);
|
||||||
verifyZeroInteractions(management, emailService);
|
verifyNoInteractions(management, emailService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -147,7 +147,7 @@ public class RegisterCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(commonService).send(player, MessageKey.USAGE_REGISTER);
|
verify(commonService).send(player, MessageKey.USAGE_REGISTER);
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -163,7 +163,7 @@ public class RegisterCommandTest {
|
|||||||
// then
|
// then
|
||||||
verify(commonService).send(player, MessageKey.INCOMPLETE_EMAIL_SETTINGS);
|
verify(commonService).send(player, MessageKey.INCOMPLETE_EMAIL_SETTINGS);
|
||||||
verify(emailService).hasAllInformation();
|
verify(emailService).hasAllInformation();
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -181,7 +181,7 @@ public class RegisterCommandTest {
|
|||||||
// then
|
// then
|
||||||
verify(validationService).validateEmail(playerMail);
|
verify(validationService).validateEmail(playerMail);
|
||||||
verify(commonService).send(player, MessageKey.INVALID_EMAIL);
|
verify(commonService).send(player, MessageKey.INVALID_EMAIL);
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -200,7 +200,7 @@ public class RegisterCommandTest {
|
|||||||
// then
|
// then
|
||||||
verify(commonService).send(player, MessageKey.USAGE_REGISTER);
|
verify(commonService).send(player, MessageKey.USAGE_REGISTER);
|
||||||
verify(emailService).hasAllInformation();
|
verify(emailService).hasAllInformation();
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -236,7 +236,7 @@ public class RegisterCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(commonService).send(player, MessageKey.PASSWORD_MATCH_ERROR);
|
verify(commonService).send(player, MessageKey.PASSWORD_MATCH_ERROR);
|
||||||
verifyZeroInteractions(management, emailService);
|
verifyNoInteractions(management, emailService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -287,7 +287,7 @@ public class RegisterCommandTest {
|
|||||||
verify(registrationCaptchaManager).isCaptchaRequired("Waaa");
|
verify(registrationCaptchaManager).isCaptchaRequired("Waaa");
|
||||||
verify(validationService).validateEmail(email);
|
verify(validationService).validateEmail(email);
|
||||||
verify(commonService).send(player, MessageKey.INVALID_EMAIL);
|
verify(commonService).send(player, MessageKey.INVALID_EMAIL);
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -321,7 +321,7 @@ public class RegisterCommandTest {
|
|||||||
// then
|
// then
|
||||||
verify(registrationCaptchaManager).isCaptchaRequired(name);
|
verify(registrationCaptchaManager).isCaptchaRequired(name);
|
||||||
verify(commonService).send(player, MessageKey.CAPTCHA_FOR_REGISTRATION_REQUIRED, captcha);
|
verify(commonService).send(player, MessageKey.CAPTCHA_FOR_REGISTRATION_REQUIRED, captcha);
|
||||||
verifyZeroInteractions(management, validationService);
|
verifyNoInteractions(management, validationService);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Player mockPlayerWithName(String name) {
|
private static Player mockPlayerWithName(String name) {
|
||||||
|
@ -18,7 +18,7 @@ import java.util.Collections;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link AddTotpCommand}.
|
* Test for {@link AddTotpCommand}.
|
||||||
@ -47,7 +47,7 @@ public class AddTotpCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(messages).send(player, MessageKey.NOT_LOGGED_IN);
|
verify(messages).send(player, MessageKey.NOT_LOGGED_IN);
|
||||||
verifyZeroInteractions(generateTotpService);
|
verifyNoInteractions(generateTotpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -63,7 +63,7 @@ public class AddTotpCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(messages).send(player, MessageKey.TWO_FACTOR_ALREADY_ENABLED);
|
verify(messages).send(player, MessageKey.TWO_FACTOR_ALREADY_ENABLED);
|
||||||
verifyZeroInteractions(generateTotpService);
|
verifyNoInteractions(generateTotpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -27,7 +27,7 @@ import static org.mockito.Mockito.mock;
|
|||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.only;
|
import static org.mockito.Mockito.only;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link ConfirmTotpCommand}.
|
* Test for {@link ConfirmTotpCommand}.
|
||||||
@ -98,7 +98,7 @@ public class ConfirmTotpCommandTest {
|
|||||||
verify(generateTotpService, never()).removeGenerateTotpKey(any(Player.class));
|
verify(generateTotpService, never()).removeGenerateTotpKey(any(Player.class));
|
||||||
verify(playerCache, only()).getAuth(playerName);
|
verify(playerCache, only()).getAuth(playerName);
|
||||||
verify(messages).send(player, MessageKey.TWO_FACTOR_ENABLE_ERROR_WRONG_CODE);
|
verify(messages).send(player, MessageKey.TWO_FACTOR_ENABLE_ERROR_WRONG_CODE);
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -118,7 +118,7 @@ public class ConfirmTotpCommandTest {
|
|||||||
verify(generateTotpService, only()).getGeneratedTotpKey(player);
|
verify(generateTotpService, only()).getGeneratedTotpKey(player);
|
||||||
verify(playerCache, only()).getAuth(playerName);
|
verify(playerCache, only()).getAuth(playerName);
|
||||||
verify(messages).send(player, MessageKey.TWO_FACTOR_ENABLE_ERROR_NO_CODE);
|
verify(messages).send(player, MessageKey.TWO_FACTOR_ENABLE_ERROR_NO_CODE);
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -135,7 +135,7 @@ public class ConfirmTotpCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(playerCache, only()).getAuth(playerName);
|
verify(playerCache, only()).getAuth(playerName);
|
||||||
verifyZeroInteractions(generateTotpService, dataSource);
|
verifyNoInteractions(generateTotpService, dataSource);
|
||||||
verify(messages).send(player, MessageKey.TWO_FACTOR_ALREADY_ENABLED);
|
verify(messages).send(player, MessageKey.TWO_FACTOR_ALREADY_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ public class ConfirmTotpCommandTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(playerCache, only()).getAuth(playerName);
|
verify(playerCache, only()).getAuth(playerName);
|
||||||
verifyZeroInteractions(generateTotpService, dataSource);
|
verifyNoInteractions(generateTotpService, dataSource);
|
||||||
verify(messages).send(player, MessageKey.NOT_LOGGED_IN);
|
verify(messages).send(player, MessageKey.NOT_LOGGED_IN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import static org.mockito.BDDMockito.given;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.only;
|
import static org.mockito.Mockito.only;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link RemoveTotpCommand}.
|
* Test for {@link RemoveTotpCommand}.
|
||||||
@ -105,7 +105,7 @@ public class RemoveTotpCommandTest {
|
|||||||
command.runCommand(player, singletonList(inputCode));
|
command.runCommand(player, singletonList(inputCode));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
verify(messages, only()).send(player, MessageKey.TWO_FACTOR_INVALID_CODE);
|
verify(messages, only()).send(player, MessageKey.TWO_FACTOR_INVALID_CODE);
|
||||||
verify(playerCache, only()).getAuth(name);
|
verify(playerCache, only()).getAuth(name);
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ public class RemoveTotpCommandTest {
|
|||||||
command.runCommand(player, singletonList(inputCode));
|
command.runCommand(player, singletonList(inputCode));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(dataSource, totpAuthenticator);
|
verifyNoInteractions(dataSource, totpAuthenticator);
|
||||||
verify(messages, only()).send(player, MessageKey.TWO_FACTOR_NOT_ENABLED_ERROR);
|
verify(messages, only()).send(player, MessageKey.TWO_FACTOR_NOT_ENABLED_ERROR);
|
||||||
verify(playerCache, only()).getAuth(name);
|
verify(playerCache, only()).getAuth(name);
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ public class RemoveTotpCommandTest {
|
|||||||
command.runCommand(player, singletonList(inputCode));
|
command.runCommand(player, singletonList(inputCode));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(dataSource, totpAuthenticator);
|
verifyNoInteractions(dataSource, totpAuthenticator);
|
||||||
verify(messages, only()).send(player, MessageKey.NOT_LOGGED_IN);
|
verify(messages, only()).send(player, MessageKey.NOT_LOGGED_IN);
|
||||||
verify(playerCache, only()).getAuth(name);
|
verify(playerCache, only()).getAuth(name);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import static org.junit.Assert.assertThat;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +60,7 @@ public class UnregisterCommandTest {
|
|||||||
// then
|
// then
|
||||||
verify(playerCache).isAuthenticated(name);
|
verify(playerCache).isAuthenticated(name);
|
||||||
verify(commonService).send(player, MessageKey.NOT_LOGGED_IN);
|
verify(commonService).send(player, MessageKey.NOT_LOGGED_IN);
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -79,7 +79,7 @@ public class UnregisterCommandTest {
|
|||||||
verify(playerCache).isAuthenticated(name);
|
verify(playerCache).isAuthenticated(name);
|
||||||
verify(codeManager).codeExistOrGenerateNew(name);
|
verify(codeManager).codeExistOrGenerateNew(name);
|
||||||
verify(commonService).send(player, MessageKey.VERIFICATION_CODE_REQUIRED);
|
verify(commonService).send(player, MessageKey.VERIFICATION_CODE_REQUIRED);
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -110,7 +110,7 @@ public class UnregisterCommandTest {
|
|||||||
command.executeCommand(sender, Collections.singletonList("password"));
|
command.executeCommand(sender, Collections.singletonList("password"));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(playerCache, management);
|
verifyNoInteractions(playerCache, management);
|
||||||
verify(sender).sendMessage(argThat(containsString("/authme unregister <player>")));
|
verify(sender).sendMessage(argThat(containsString("/authme unregister <player>")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import static org.mockito.ArgumentMatchers.eq;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link TempbanManager}.
|
* Test for {@link TempbanManager}.
|
||||||
@ -139,7 +139,7 @@ public class TempbanManagerTest {
|
|||||||
manager.tempbanPlayer(player);
|
manager.tempbanPlayer(player);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(player, bukkitService);
|
verifyNoInteractions(player, bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -20,7 +20,7 @@ import static org.mockito.BDDMockito.given;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.only;
|
import static org.mockito.Mockito.only;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link VerificationCodeManager}.
|
* Test for {@link VerificationCodeManager}.
|
||||||
@ -82,7 +82,7 @@ public class VerificationCodeManagerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verifyZeroInteractions(permissionsManager, dataSource);
|
verifyNoInteractions(permissionsManager, dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -98,7 +98,7 @@ public class VerificationCodeManagerTest {
|
|||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verify(permissionsManager).hasPermission(player, PlayerPermission.VERIFICATION_CODE);
|
verify(permissionsManager).hasPermission(player, PlayerPermission.VERIFICATION_CODE);
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link AllowFlightRestoreType}.
|
* Test for {@link AllowFlightRestoreType}.
|
||||||
@ -78,7 +78,7 @@ public class AllowFlightRestoreTypeTest {
|
|||||||
AllowFlightRestoreType.NOTHING.restoreAllowFlight(player2, limboWithoutFly);
|
AllowFlightRestoreType.NOTHING.restoreAllowFlight(player2, limboWithoutFly);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(player1, player2);
|
verifyNoInteractions(player1, player2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -94,7 +94,7 @@ public class AllowFlightRestoreTypeTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
if (type == noInteractionType) {
|
if (type == noInteractionType) {
|
||||||
verifyZeroInteractions(player);
|
verifyNoInteractions(player);
|
||||||
} else {
|
} else {
|
||||||
verify(player).setAllowFlight(false);
|
verify(player).setAllowFlight(false);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ import static org.mockito.ArgumentMatchers.eq;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link LimboPlayerTaskManager}.
|
* Test for {@link LimboPlayerTaskManager}.
|
||||||
@ -97,7 +97,7 @@ public class LimboPlayerTaskManagerTest {
|
|||||||
limboPlayerTaskManager.registerMessageTask(player, limboPlayer, LimboMessageType.LOG_IN);
|
limboPlayerTaskManager.registerMessageTask(player, limboPlayer, LimboMessageType.LOG_IN);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(limboPlayer, bukkitService);
|
verifyNoInteractions(limboPlayer, bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -173,7 +173,7 @@ public class LimboPlayerTaskManagerTest {
|
|||||||
limboPlayerTaskManager.registerTimeoutTask(player, limboPlayer);
|
limboPlayerTaskManager.registerTimeoutTask(player, limboPlayer);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(limboPlayer, bukkitService);
|
verifyNoInteractions(limboPlayer, bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -15,7 +15,7 @@ import static org.hamcrest.Matchers.equalTo;
|
|||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link LimboServiceHelper}.
|
* Test for {@link LimboServiceHelper}.
|
||||||
@ -83,7 +83,7 @@ public class LimboServiceHelperTest {
|
|||||||
LimboPlayer result3 = limboServiceHelper.merge(null, null);
|
LimboPlayer result3 = limboServiceHelper.merge(null, null);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(limbo);
|
verifyNoInteractions(limbo);
|
||||||
assertThat(result1, equalTo(limbo));
|
assertThat(result1, equalTo(limbo));
|
||||||
assertThat(result2, equalTo(limbo));
|
assertThat(result2, equalTo(limbo));
|
||||||
assertThat(result3, nullValue());
|
assertThat(result3, nullValue());
|
||||||
|
@ -34,7 +34,7 @@ import static org.mockito.BDDMockito.given;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.only;
|
import static org.mockito.Mockito.only;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link LimboService}, and {@link LimboServiceHelper}.
|
* Test for {@link LimboService}, and {@link LimboServiceHelper}.
|
||||||
@ -222,7 +222,7 @@ public class LimboServiceTest {
|
|||||||
limboService.replaceTasksAfterRegistration(player);
|
limboService.replaceTasksAfterRegistration(player);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(taskManager);
|
verifyNoInteractions(taskManager);
|
||||||
verify(authGroupHandler).setGroup(player, null, AuthGroupType.REGISTERED_UNAUTHENTICATED);
|
verify(authGroupHandler).setGroup(player, null, AuthGroupType.REGISTERED_UNAUTHENTICATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,11 @@ import org.junit.runners.Parameterized;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
@ -21,7 +23,7 @@ import static org.mockito.Mockito.mock;
|
|||||||
public abstract class AbstractSqlDataSourceResourceClosingTest extends AbstractResourceClosingTest {
|
public abstract class AbstractSqlDataSourceResourceClosingTest extends AbstractResourceClosingTest {
|
||||||
|
|
||||||
/** List of DataSource method names not to test. */
|
/** List of DataSource method names not to test. */
|
||||||
private static final Set<String> IGNORED_METHODS = ImmutableSet.of("reload", "getType");
|
private static final Set<String> IGNORED_METHODS = ImmutableSet.of("reload", "getType", "isCached");
|
||||||
|
|
||||||
private static Settings settings;
|
private static Settings settings;
|
||||||
|
|
||||||
@ -64,12 +66,8 @@ public abstract class AbstractSqlDataSourceResourceClosingTest extends AbstractR
|
|||||||
|
|
||||||
/* Get all methods of the DataSource interface, minus the ones in the ignored list. */
|
/* Get all methods of the DataSource interface, minus the ones in the ignored list. */
|
||||||
private static List<Method> getDataSourceMethods() {
|
private static List<Method> getDataSourceMethods() {
|
||||||
List<Method> publicMethods = new ArrayList<>();
|
return Arrays.stream(DataSource.class.getDeclaredMethods())
|
||||||
for (Method method : DataSource.class.getDeclaredMethods()) {
|
.filter(method -> !IGNORED_METHODS.contains(method.getName()) && !method.isSynthetic())
|
||||||
if (!IGNORED_METHODS.contains(method.getName()) && !method.isSynthetic()) {
|
.collect(Collectors.toList());
|
||||||
publicMethods.add(method);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return publicMethods;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class SQLiteIntegrationTest extends AbstractDataSourceIntegrationTest {
|
|||||||
TestHelper.returnDefaultsForAllProperties(settings);
|
TestHelper.returnDefaultsForAllProperties(settings);
|
||||||
set(DatabaseSettings.MYSQL_DATABASE, "sqlite-test");
|
set(DatabaseSettings.MYSQL_DATABASE, "sqlite-test");
|
||||||
set(DatabaseSettings.MYSQL_TABLE, "authme");
|
set(DatabaseSettings.MYSQL_TABLE, "authme");
|
||||||
TestHelper.setRealLogger();
|
TestHelper.setupLogger();
|
||||||
|
|
||||||
Path sqlInitFile = TestHelper.getJarPath(TestHelper.PROJECT_ROOT + "datasource/sql-initialize.sql");
|
Path sqlInitFile = TestHelper.getJarPath(TestHelper.PROJECT_ROOT + "datasource/sql-initialize.sql");
|
||||||
// Note ljacqu 20160221: It appears that we can only run one statement per Statement.execute() so we split
|
// Note ljacqu 20160221: It appears that we can only run one statement per Statement.execute() so we split
|
||||||
|
@ -30,11 +30,6 @@ public class SqlDataSourceUtilsTest {
|
|||||||
logger = TestHelper.setupLogger();
|
logger = TestHelper.setupLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenConstructor() {
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(SqlDataSourceUtils.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldLogException() {
|
public void shouldLogException() {
|
||||||
// given
|
// given
|
||||||
|
@ -21,8 +21,8 @@ import static org.mockito.Mockito.mock;
|
|||||||
import static org.mockito.Mockito.only;
|
import static org.mockito.Mockito.only;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,7 +51,7 @@ public class AbstractDataSourceConverterTest {
|
|||||||
// then
|
// then
|
||||||
verify(sender).sendMessage(argThat(containsString("Please configure your connection to SQLITE")));
|
verify(sender).sendMessage(argThat(containsString("Please configure your connection to SQLITE")));
|
||||||
verify(destination, only()).getType();
|
verify(destination, only()).getType();
|
||||||
verifyZeroInteractions(source);
|
verifyNoInteractions(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -72,7 +72,7 @@ public class AbstractDataSourceConverterTest {
|
|||||||
// then
|
// then
|
||||||
verify(sender).sendMessage("The data source to convert from could not be initialized");
|
verify(sender).sendMessage("The data source to convert from could not be initialized");
|
||||||
verify(destination, only()).getType();
|
verify(destination, only()).getType();
|
||||||
verifyZeroInteractions(source);
|
verifyNoInteractions(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -26,7 +26,7 @@ import static org.mockito.BDDMockito.given;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,7 +81,7 @@ public class CrazyLoginConverterTest {
|
|||||||
crazyLoginConverter.execute(sender);
|
crazyLoginConverter.execute(sender);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
verify(sender).sendMessage(argThat(containsString("file not found")));
|
verify(sender).sendMessage(argThat(containsString("file not found")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link NoOpExtension}.
|
* Test for {@link NoOpExtension}.
|
||||||
@ -49,6 +49,6 @@ public class NoOpExtensionTest {
|
|||||||
extension.saveAuth(auth, connection);
|
extension.saveAuth(auth, connection);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(connection, auth);
|
verifyNoInteractions(connection, auth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import static org.mockito.Mockito.mock;
|
|||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.only;
|
import static org.mockito.Mockito.only;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link EntityListener}.
|
* Test for {@link EntityListener}.
|
||||||
@ -76,7 +76,7 @@ public class EntityListenerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(listenerService).shouldCancelEvent(event);
|
verify(listenerService).shouldCancelEvent(event);
|
||||||
verifyZeroInteractions(event);
|
verifyNoInteractions(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -140,7 +140,7 @@ public class EntityListenerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(listenerService).shouldCancelEvent(event);
|
verify(listenerService).shouldCancelEvent(event);
|
||||||
verifyZeroInteractions(event);
|
verifyNoInteractions(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -156,7 +156,7 @@ public class EntityListenerTest {
|
|||||||
listener.onProjectileLaunch(event);
|
listener.onProjectileLaunch(event);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(listenerService);
|
verifyNoInteractions(listenerService);
|
||||||
verify(event, never()).setCancelled(anyBoolean());
|
verify(event, never()).setCancelled(anyBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import java.util.function.Consumer;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests simple listener methods that should cancel an event when the listener service says so.
|
* Tests simple listener methods that should cancel an event when the listener service says so.
|
||||||
@ -54,7 +54,7 @@ public final class EventCancelVerifier {
|
|||||||
event = mock(clazz);
|
event = mock(clazz);
|
||||||
mockShouldCancel(false, listenerService, event);
|
mockShouldCancel(false, listenerService, event);
|
||||||
listenerMethod.accept(event);
|
listenerMethod.accept(event);
|
||||||
verifyZeroInteractions(event);
|
verifyNoInteractions(event);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import static org.junit.Assert.assertThat;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link ListenerService}.
|
* Test for {@link ListenerService}.
|
||||||
@ -91,7 +91,7 @@ public class ListenerServiceTest {
|
|||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verify(playerCache).isAuthenticated(playerName);
|
verify(playerCache).isAuthenticated(playerName);
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -110,7 +110,7 @@ public class ListenerServiceTest {
|
|||||||
assertThat(result, equalTo(true));
|
assertThat(result, equalTo(true));
|
||||||
verify(playerCache).isAuthenticated(playerName);
|
verify(playerCache).isAuthenticated(playerName);
|
||||||
// makes sure the setting is checked first = avoid unnecessary DB operation
|
// makes sure the setting is checked first = avoid unnecessary DB operation
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -147,7 +147,7 @@ public class ListenerServiceTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -182,7 +182,7 @@ public class ListenerServiceTest {
|
|||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verify(playerCache).isAuthenticated(playerName);
|
verify(playerCache).isAuthenticated(playerName);
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -210,7 +210,7 @@ public class ListenerServiceTest {
|
|||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(true));
|
assertThat(result, equalTo(true));
|
||||||
verify(playerCache).isAuthenticated(playerName);
|
verify(playerCache).isAuthenticated(playerName);
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Player mockPlayerWithName(String name) {
|
private static Player mockPlayerWithName(String name) {
|
||||||
|
@ -39,8 +39,8 @@ import static org.junit.Assert.fail;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link OnJoinVerifier}.
|
* Test for {@link OnJoinVerifier}.
|
||||||
@ -89,7 +89,7 @@ public class OnJoinVerifierTest {
|
|||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verify(event).getResult();
|
verify(event).getResult();
|
||||||
verifyNoMoreInteractions(event);
|
verifyNoMoreInteractions(event);
|
||||||
verifyZeroInteractions(bukkitService, dataSource, permissionsManager);
|
verifyNoInteractions(bukkitService, dataSource, permissionsManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -109,7 +109,7 @@ public class OnJoinVerifierTest {
|
|||||||
assertThat(result, equalTo(true));
|
assertThat(result, equalTo(true));
|
||||||
assertThat(event.getResult(), equalTo(PlayerLoginEvent.Result.KICK_FULL));
|
assertThat(event.getResult(), equalTo(PlayerLoginEvent.Result.KICK_FULL));
|
||||||
assertThat(event.getKickMessage(), equalTo(serverFullMessage));
|
assertThat(event.getKickMessage(), equalTo(serverFullMessage));
|
||||||
verifyZeroInteractions(bukkitService, dataSource);
|
verifyNoInteractions(bukkitService, dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -133,7 +133,7 @@ public class OnJoinVerifierTest {
|
|||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
assertThat(event.getResult(), equalTo(PlayerLoginEvent.Result.ALLOWED));
|
assertThat(event.getResult(), equalTo(PlayerLoginEvent.Result.ALLOWED));
|
||||||
// First player is VIP, so expect no interactions there and second player to have been kicked
|
// First player is VIP, so expect no interactions there and second player to have been kicked
|
||||||
verifyZeroInteractions(onlinePlayers.get(0));
|
verifyNoInteractions(onlinePlayers.get(0));
|
||||||
verify(onlinePlayers.get(1)).kickPlayer("kick for vip");
|
verify(onlinePlayers.get(1)).kickPlayer("kick for vip");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ public class OnJoinVerifierTest {
|
|||||||
assertThat(result, equalTo(true));
|
assertThat(result, equalTo(true));
|
||||||
assertThat(event.getResult(), equalTo(PlayerLoginEvent.Result.KICK_FULL));
|
assertThat(event.getResult(), equalTo(PlayerLoginEvent.Result.KICK_FULL));
|
||||||
assertThat(event.getKickMessage(), equalTo("kick full server"));
|
assertThat(event.getKickMessage(), equalTo("kick full server"));
|
||||||
verifyZeroInteractions(onlinePlayers.get(0));
|
verifyNoInteractions(onlinePlayers.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -254,7 +254,7 @@ public class OnJoinVerifierTest {
|
|||||||
onJoinVerifier.checkNameCasing(name, auth);
|
onJoinVerifier.checkNameCasing(name, auth);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -269,7 +269,7 @@ public class OnJoinVerifierTest {
|
|||||||
|
|
||||||
// when / then
|
// when / then
|
||||||
onJoinVerifier.checkNameCasing(name, auth);
|
onJoinVerifier.checkNameCasing(name, auth);
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -311,7 +311,7 @@ public class OnJoinVerifierTest {
|
|||||||
onJoinVerifier.checkNameCasing(name, auth);
|
onJoinVerifier.checkNameCasing(name, auth);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -324,7 +324,7 @@ public class OnJoinVerifierTest {
|
|||||||
onJoinVerifier.checkNameCasing(name, auth);
|
onJoinVerifier.checkNameCasing(name, auth);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -368,7 +368,7 @@ public class OnJoinVerifierTest {
|
|||||||
onJoinVerifier.checkSingleSession(name);
|
onJoinVerifier.checkSingleSession(name);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(bukkitService);
|
verifyNoInteractions(bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -397,7 +397,7 @@ public class OnJoinVerifierTest {
|
|||||||
onJoinVerifier.checkAntibot(name, isAuthAvailable);
|
onJoinVerifier.checkAntibot(name, isAuthAvailable);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(permissionsManager, antiBotService);
|
verifyNoInteractions(permissionsManager, antiBotService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -412,7 +412,7 @@ public class OnJoinVerifierTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(permissionsManager).hasPermissionOffline(name, PlayerStatePermission.BYPASS_ANTIBOT);
|
verify(permissionsManager).hasPermissionOffline(name, PlayerStatePermission.BYPASS_ANTIBOT);
|
||||||
verifyZeroInteractions(antiBotService);
|
verifyNoInteractions(antiBotService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -446,12 +446,12 @@ public class OnJoinVerifierTest {
|
|||||||
given(settings.getProperty(ProtectionSettings.ENABLE_PROTECTION)).willReturn(false);
|
given(settings.getProperty(ProtectionSettings.ENABLE_PROTECTION)).willReturn(false);
|
||||||
given(settings.getProperty(ProtectionSettings.ENABLE_PROTECTION_REGISTERED)).willReturn(true);
|
given(settings.getProperty(ProtectionSettings.ENABLE_PROTECTION_REGISTERED)).willReturn(true);
|
||||||
onJoinVerifier.checkPlayerCountry(name, ip, false);
|
onJoinVerifier.checkPlayerCountry(name, ip, false);
|
||||||
verifyZeroInteractions(validationService);
|
verifyNoInteractions(validationService);
|
||||||
|
|
||||||
// protection for registered players disabled
|
// protection for registered players disabled
|
||||||
given(settings.getProperty(ProtectionSettings.ENABLE_PROTECTION_REGISTERED)).willReturn(false);
|
given(settings.getProperty(ProtectionSettings.ENABLE_PROTECTION_REGISTERED)).willReturn(false);
|
||||||
onJoinVerifier.checkPlayerCountry(name, ip, true);
|
onJoinVerifier.checkPlayerCountry(name, ip, true);
|
||||||
verifyZeroInteractions(validationService);
|
verifyNoInteractions(validationService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -83,8 +83,8 @@ import static org.mockito.Mockito.only;
|
|||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link PlayerListener}.
|
* Test for {@link PlayerListener}.
|
||||||
@ -140,7 +140,7 @@ public class PlayerListenerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(event.isCancelled(), equalTo(true));
|
assertThat(event.isCancelled(), equalTo(true));
|
||||||
verifyZeroInteractions(player, management, antiBotService);
|
verifyNoInteractions(player, management, antiBotService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -176,7 +176,7 @@ public class PlayerListenerTest {
|
|||||||
// then
|
// then
|
||||||
assertThat(event.isCancelled(), equalTo(false));
|
assertThat(event.isCancelled(), equalTo(false));
|
||||||
verify(antiBotService).wasPlayerKicked(name);
|
verify(antiBotService).wasPlayerKicked(name);
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -205,7 +205,7 @@ public class PlayerListenerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(event, only()).getMessage();
|
verify(event, only()).getMessage();
|
||||||
verifyZeroInteractions(listenerService, messages);
|
verifyNoInteractions(listenerService, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -220,7 +220,7 @@ public class PlayerListenerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(event, only()).getMessage();
|
verify(event, only()).getMessage();
|
||||||
verifyZeroInteractions(listenerService, messages);
|
verifyNoInteractions(listenerService, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -241,7 +241,7 @@ public class PlayerListenerTest {
|
|||||||
verify(event).getMessage();
|
verify(event).getMessage();
|
||||||
verifyNoMoreInteractions(event);
|
verifyNoMoreInteractions(event);
|
||||||
verify(listenerService).shouldCancelEvent(player);
|
verify(listenerService).shouldCancelEvent(player);
|
||||||
verifyZeroInteractions(messages);
|
verifyNoInteractions(messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -290,7 +290,7 @@ public class PlayerListenerTest {
|
|||||||
listener.onPlayerChat(event);
|
listener.onPlayerChat(event);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(event, listenerService, messages);
|
verifyNoInteractions(event, listenerService, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -324,7 +324,7 @@ public class PlayerListenerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(listenerService).shouldCancelEvent(event.getPlayer());
|
verify(listenerService).shouldCancelEvent(event.getPlayer());
|
||||||
verifyZeroInteractions(event, messages);
|
verifyNoInteractions(event, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -400,7 +400,7 @@ public class PlayerListenerTest {
|
|||||||
listener.onPlayerMove(event);
|
listener.onPlayerMove(event);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(event);
|
verifyNoInteractions(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -551,7 +551,7 @@ public class PlayerListenerTest {
|
|||||||
listener.onPlayerRespawn(event);
|
listener.onPlayerRespawn(event);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(listenerService);
|
verifyNoInteractions(listenerService);
|
||||||
verify(event, never()).setRespawnLocation(any());
|
verify(event, never()).setRespawnLocation(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,7 +568,7 @@ public class PlayerListenerTest {
|
|||||||
listener.onPlayerRespawn(event);
|
listener.onPlayerRespawn(event);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(spawnLoader);
|
verifyNoInteractions(spawnLoader);
|
||||||
verify(event, never()).setRespawnLocation(any());
|
verify(event, never()).setRespawnLocation(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,7 +659,7 @@ public class PlayerListenerTest {
|
|||||||
// then
|
// then
|
||||||
verify(validationService).isUnrestricted(name);
|
verify(validationService).isUnrestricted(name);
|
||||||
verifyNoModifyingCalls(event);
|
verifyNoModifyingCalls(event);
|
||||||
verifyZeroInteractions(onJoinVerifier);
|
verifyNoInteractions(onJoinVerifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -717,7 +717,7 @@ public class PlayerListenerTest {
|
|||||||
verify(validationService).isUnrestricted(name);
|
verify(validationService).isUnrestricted(name);
|
||||||
verify(onJoinVerifier).checkSingleSession(name);
|
verify(onJoinVerifier).checkSingleSession(name);
|
||||||
verify(onJoinVerifier).checkIsValidName(name);
|
verify(onJoinVerifier).checkIsValidName(name);
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
verifyNoModifyingCalls(preLoginEvent);
|
verifyNoModifyingCalls(preLoginEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -780,7 +780,7 @@ public class PlayerListenerTest {
|
|||||||
// then
|
// then
|
||||||
verify(validationService).isUnrestricted(name);
|
verify(validationService).isUnrestricted(name);
|
||||||
verify(onJoinVerifier).refusePlayerForFullServer(loginEvent);
|
verify(onJoinVerifier).refusePlayerForFullServer(loginEvent);
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
verifyNoModifyingCalls(loginEvent);
|
verifyNoModifyingCalls(loginEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -805,7 +805,7 @@ public class PlayerListenerTest {
|
|||||||
verify(validationService).isUnrestricted(name);
|
verify(validationService).isUnrestricted(name);
|
||||||
verify(onJoinVerifier).checkIsValidName(name);
|
verify(onJoinVerifier).checkIsValidName(name);
|
||||||
// Check that we don't talk with the data source before performing checks that don't require it
|
// Check that we don't talk with the data source before performing checks that don't require it
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
verify(event).setKickMessage(message);
|
verify(event).setKickMessage(message);
|
||||||
verify(event).setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
verify(event).setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
||||||
}
|
}
|
||||||
@ -844,7 +844,7 @@ public class PlayerListenerTest {
|
|||||||
// then
|
// then
|
||||||
assertThat(event.getQuitMessage(), nullValue());
|
assertThat(event.getQuitMessage(), nullValue());
|
||||||
verify(antiBotService).wasPlayerKicked(name);
|
verify(antiBotService).wasPlayerKicked(name);
|
||||||
verifyZeroInteractions(management);
|
verifyNoInteractions(management);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -942,7 +942,7 @@ public class PlayerListenerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(event.isCancelled(), equalTo(false));
|
assertThat(event.isCancelled(), equalTo(false));
|
||||||
verifyZeroInteractions(bukkitService);
|
verifyNoInteractions(bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -980,7 +980,7 @@ public class PlayerListenerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(event.getJoinMessage(), equalTo(joinMsg));
|
assertThat(event.getJoinMessage(), equalTo(joinMsg));
|
||||||
verifyZeroInteractions(joinMessageService);
|
verifyNoInteractions(joinMessageService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -996,7 +996,7 @@ public class PlayerListenerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(event.getJoinMessage(), nullValue());
|
assertThat(event.getJoinMessage(), nullValue());
|
||||||
verifyZeroInteractions(joinMessageService);
|
verifyNoInteractions(joinMessageService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -1017,7 +1017,7 @@ public class PlayerListenerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(event.getJoinMessage(), equalTo("Hello doooew (aka Displ)"));
|
assertThat(event.getJoinMessage(), equalTo("Hello doooew (aka Displ)"));
|
||||||
verifyZeroInteractions(joinMessageService);
|
verifyNoInteractions(joinMessageService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package fr.xephi.authme.listener;
|
package fr.xephi.authme.listener;
|
||||||
|
|
||||||
import fr.xephi.authme.TestHelper;
|
import fr.xephi.authme.TestHelper;
|
||||||
import fr.xephi.authme.service.PluginHookService;
|
|
||||||
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
|
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
import org.bukkit.event.server.PluginDisableEvent;
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
import org.bukkit.event.server.PluginEnableEvent;
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
@ -20,8 +20,8 @@ import static org.mockito.BDDMockito.given;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.reset;
|
import static org.mockito.Mockito.reset;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link ServerListener}.
|
* Test for {@link ServerListener}.
|
||||||
@ -65,7 +65,7 @@ public class ServerListenerTest {
|
|||||||
});
|
});
|
||||||
checkEnableHandling(MULTIVERSE, () -> verify(pluginHookService).tryHookToMultiverse());
|
checkEnableHandling(MULTIVERSE, () -> verify(pluginHookService).tryHookToMultiverse());
|
||||||
checkEnableHandling(PROTOCOL_LIB, () -> verify(protocolLibService).setup());
|
checkEnableHandling(PROTOCOL_LIB, () -> verify(protocolLibService).setup());
|
||||||
checkEnableHandling("UnknownPlugin", () -> verifyZeroInteractions(pluginHookService, spawnLoader));
|
checkEnableHandling("UnknownPlugin", () -> verifyNoInteractions(pluginHookService, spawnLoader));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -78,7 +78,7 @@ public class ServerListenerTest {
|
|||||||
});
|
});
|
||||||
checkDisableHandling(MULTIVERSE, () -> verify(pluginHookService).unhookMultiverse());
|
checkDisableHandling(MULTIVERSE, () -> verify(pluginHookService).unhookMultiverse());
|
||||||
checkDisableHandling(PROTOCOL_LIB, () -> verify(protocolLibService).disable());
|
checkDisableHandling(PROTOCOL_LIB, () -> verify(protocolLibService).disable());
|
||||||
checkDisableHandling("UnknownPlugin", () -> verifyZeroInteractions(pluginHookService, spawnLoader));
|
checkDisableHandling("UnknownPlugin", () -> verifyNoInteractions(pluginHookService, spawnLoader));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkEnableHandling(String pluginName, Runnable verifier) {
|
private void checkEnableHandling(String pluginName, Runnable verifier) {
|
||||||
|
@ -64,7 +64,7 @@ public class PermissionsManagerInitializationTest {
|
|||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpLogger() {
|
public static void setUpLogger() {
|
||||||
TestHelper.setRealLogger();
|
TestHelper.setupLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@ -36,7 +36,7 @@ import static org.mockito.Mockito.doAnswer;
|
|||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.internal.verification.VerificationModeFactory.only;
|
import static org.mockito.internal.verification.VerificationModeFactory.only;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,7 +78,7 @@ public class AsynchronousLoginTest {
|
|||||||
// then
|
// then
|
||||||
verify(playerCache, only()).isAuthenticated(name);
|
verify(playerCache, only()).isAuthenticated(name);
|
||||||
verify(commonService).send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
verify(commonService).send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -198,7 +198,7 @@ public class AsynchronousLoginTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verifyZeroInteractions(bukkitService);
|
verifyNoInteractions(bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -214,7 +214,7 @@ public class AsynchronousLoginTest {
|
|||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verify(commonService).hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS);
|
verify(commonService).hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS);
|
||||||
verifyZeroInteractions(bukkitService);
|
verifyNoInteractions(bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -28,7 +28,7 @@ import static org.mockito.BDDMockito.given;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.only;
|
import static org.mockito.Mockito.only;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link AsyncRegister}.
|
* Test for {@link AsyncRegister}.
|
||||||
@ -64,7 +64,7 @@ public class AsyncRegisterTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(commonService).send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
verify(commonService).send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
||||||
verifyZeroInteractions(dataSource, executor);
|
verifyNoInteractions(dataSource, executor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -82,7 +82,7 @@ public class AsyncRegisterTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(commonService).send(player, MessageKey.REGISTRATION_DISABLED);
|
verify(commonService).send(player, MessageKey.REGISTRATION_DISABLED);
|
||||||
verifyZeroInteractions(dataSource, executor);
|
verifyNoInteractions(dataSource, executor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -102,7 +102,7 @@ public class AsyncRegisterTest {
|
|||||||
// then
|
// then
|
||||||
verify(commonService).send(player, MessageKey.NAME_ALREADY_REGISTERED);
|
verify(commonService).send(player, MessageKey.NAME_ALREADY_REGISTERED);
|
||||||
verify(dataSource, only()).isAuthAvailable(name);
|
verify(dataSource, only()).isAuthAvailable(name);
|
||||||
verifyZeroInteractions(executor);
|
verifyNoInteractions(executor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -28,7 +28,7 @@ import static org.mockito.ArgumentMatchers.anyString;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link EmailRegisterExecutor}.
|
* Test for {@link EmailRegisterExecutor}.
|
||||||
@ -158,7 +158,7 @@ public class EmailRegisterExecutorTest {
|
|||||||
// then
|
// then
|
||||||
verify(emailService).sendPasswordMail("Laleh", "test@example.com", password);
|
verify(emailService).sendPasswordMail("Laleh", "test@example.com", password);
|
||||||
verify(commonService).send(player, MessageKey.EMAIL_SEND_FAILURE);
|
verify(commonService).send(player, MessageKey.EMAIL_SEND_FAILURE);
|
||||||
verifyZeroInteractions(syncProcessManager);
|
verifyNoInteractions(syncProcessManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertIsCloseTo(long value1, long value2, long tolerance) {
|
private static void assertIsCloseTo(long value1, long value2, long tolerance) {
|
||||||
|
@ -31,7 +31,7 @@ import static org.mockito.ArgumentMatchers.anyString;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link PasswordRegisterExecutor}.
|
* Test for {@link PasswordRegisterExecutor}.
|
||||||
@ -138,7 +138,7 @@ public class PasswordRegisterExecutorTest {
|
|||||||
executor.executePostPersistAction(params);
|
executor.executePostPersistAction(params);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(bukkitService, asynchronousLogin);
|
verifyNoInteractions(bukkitService, asynchronousLogin);
|
||||||
verify(syncProcessManager).processSyncPasswordRegister(player);
|
verify(syncProcessManager).processSyncPasswordRegister(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,10 +38,4 @@ public class PlayerAuthBuilderHelperTest {
|
|||||||
assertThat(Math.abs(auth.getRegistrationDate() - System.currentTimeMillis()), lessThan(1000L));
|
assertThat(Math.abs(auth.getRegistrationDate() - System.currentTimeMillis()), lessThan(1000L));
|
||||||
assertThat(auth.getPassword(), equalToHash("myHash0001"));
|
assertThat(auth.getPassword(), equalToHash("myHash0001"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenConstructor() {
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(PlayerAuthBuilderHelper.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ import static org.mockito.Mockito.mock;
|
|||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.only;
|
import static org.mockito.Mockito.only;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link AsynchronousUnregister}.
|
* Test for {@link AsynchronousUnregister}.
|
||||||
@ -94,7 +94,7 @@ public class AsynchronousUnregisterTest {
|
|||||||
// then
|
// then
|
||||||
verify(service).send(player, MessageKey.WRONG_PASSWORD);
|
verify(service).send(player, MessageKey.WRONG_PASSWORD);
|
||||||
verify(passwordSecurity).comparePassword(userPassword, password, name);
|
verify(passwordSecurity).comparePassword(userPassword, password, name);
|
||||||
verifyZeroInteractions(dataSource, limboService, teleportationService, bukkitService, bungeeSender);
|
verifyNoInteractions(dataSource, limboService, teleportationService, bukkitService, bungeeSender);
|
||||||
verify(player, only()).getName();
|
verify(player, only()).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ public class AsynchronousUnregisterTest {
|
|||||||
verify(passwordSecurity).comparePassword(userPassword, password, name);
|
verify(passwordSecurity).comparePassword(userPassword, password, name);
|
||||||
verify(dataSource).removeAuth(name);
|
verify(dataSource).removeAuth(name);
|
||||||
verify(playerCache).removePlayer(name);
|
verify(playerCache).removePlayer(name);
|
||||||
verifyZeroInteractions(teleportationService, limboService);
|
verifyNoInteractions(teleportationService, limboService);
|
||||||
verifyCalledUnregisterEventFor(player);
|
verifyCalledUnregisterEventFor(player);
|
||||||
verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name);
|
verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name);
|
||||||
verify(commandManager).runCommandsOnUnregister(player);
|
verify(commandManager).runCommandsOnUnregister(player);
|
||||||
@ -216,7 +216,7 @@ public class AsynchronousUnregisterTest {
|
|||||||
verify(passwordSecurity).comparePassword(userPassword, password, name);
|
verify(passwordSecurity).comparePassword(userPassword, password, name);
|
||||||
verify(dataSource).removeAuth(name);
|
verify(dataSource).removeAuth(name);
|
||||||
verify(service).send(player, MessageKey.ERROR);
|
verify(service).send(player, MessageKey.ERROR);
|
||||||
verifyZeroInteractions(teleportationService, bukkitService, bungeeSender);
|
verifyNoInteractions(teleportationService, bukkitService, bungeeSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -241,7 +241,7 @@ public class AsynchronousUnregisterTest {
|
|||||||
verify(passwordSecurity).comparePassword(userPassword, password, name);
|
verify(passwordSecurity).comparePassword(userPassword, password, name);
|
||||||
verify(dataSource).removeAuth(name);
|
verify(dataSource).removeAuth(name);
|
||||||
verify(playerCache).removePlayer(name);
|
verify(playerCache).removePlayer(name);
|
||||||
verifyZeroInteractions(teleportationService);
|
verifyNoInteractions(teleportationService);
|
||||||
verifyCalledUnregisterEventFor(player);
|
verifyCalledUnregisterEventFor(player);
|
||||||
verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name);
|
verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name);
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ public class AsynchronousUnregisterTest {
|
|||||||
// then
|
// then
|
||||||
verify(dataSource).removeAuth(name);
|
verify(dataSource).removeAuth(name);
|
||||||
verify(playerCache).removePlayer(name);
|
verify(playerCache).removePlayer(name);
|
||||||
verifyZeroInteractions(teleportationService);
|
verifyNoInteractions(teleportationService);
|
||||||
verifyCalledUnregisterEventFor(null);
|
verifyCalledUnregisterEventFor(null);
|
||||||
verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name);
|
verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name);
|
||||||
}
|
}
|
||||||
@ -303,7 +303,7 @@ public class AsynchronousUnregisterTest {
|
|||||||
// then
|
// then
|
||||||
verify(dataSource).removeAuth(name);
|
verify(dataSource).removeAuth(name);
|
||||||
verify(service).send(initiator, MessageKey.ERROR);
|
verify(service).send(initiator, MessageKey.ERROR);
|
||||||
verifyZeroInteractions(playerCache, teleportationService, bukkitService, bungeeSender);
|
verifyNoInteractions(playerCache, teleportationService, bukkitService, bungeeSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -24,7 +24,7 @@ import static org.junit.Assert.assertThat;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link TotpAuthenticator}.
|
* Test for {@link TotpAuthenticator}.
|
||||||
@ -62,9 +62,9 @@ public class TotpAuthenticatorTest {
|
|||||||
// then
|
// then
|
||||||
assertThat(key1.getTotpKey(), stringWithLength(16));
|
assertThat(key1.getTotpKey(), stringWithLength(16));
|
||||||
assertThat(key2.getTotpKey(), stringWithLength(16));
|
assertThat(key2.getTotpKey(), stringWithLength(16));
|
||||||
assertThat(key1.getAuthenticatorQrCodeUrl(), startsWith("https://chart.googleapis.com/chart?chs=200x200"));
|
assertThat(key1.getAuthenticatorQrCodeUrl(), startsWith("https://api.qrserver.com/v1/create-qr-code/?data="));
|
||||||
assertThat(key1.getAuthenticatorQrCodeUrl(), containsString("MCtopia"));
|
assertThat(key1.getAuthenticatorQrCodeUrl(), containsString("MCtopia"));
|
||||||
assertThat(key2.getAuthenticatorQrCodeUrl(), startsWith("https://chart.googleapis.com/chart?chs=200x200"));
|
assertThat(key2.getAuthenticatorQrCodeUrl(), startsWith("https://api.qrserver.com/v1/create-qr-code/?data="));
|
||||||
assertThat(key1.getTotpKey(), not(equalTo(key2.getTotpKey())));
|
assertThat(key1.getTotpKey(), not(equalTo(key2.getTotpKey())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ public class TotpAuthenticatorTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verifyZeroInteractions(googleAuthenticator);
|
verifyNoInteractions(googleAuthenticator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -29,7 +29,7 @@ import static org.mockito.Mockito.mock;
|
|||||||
import static org.mockito.Mockito.only;
|
import static org.mockito.Mockito.only;
|
||||||
import static org.mockito.Mockito.reset;
|
import static org.mockito.Mockito.reset;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link AntiBotService}.
|
* Test for {@link AntiBotService}.
|
||||||
@ -76,7 +76,7 @@ public class AntiBotServiceTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(antiBotService.getAntiBotStatus(), equalTo(AntiBotService.AntiBotStatus.DISABLED));
|
assertThat(antiBotService.getAntiBotStatus(), equalTo(AntiBotService.AntiBotStatus.DISABLED));
|
||||||
verifyZeroInteractions(bukkitService);
|
verifyNoInteractions(bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -29,7 +29,7 @@ import static org.mockito.Mockito.doReturn;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.only;
|
import static org.mockito.Mockito.only;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link BukkitService}.
|
* Test for {@link BukkitService}.
|
||||||
@ -127,7 +127,7 @@ public class BukkitServiceTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(spy).scheduleSyncDelayedTask(task);
|
verify(spy).scheduleSyncDelayedTask(task);
|
||||||
verifyZeroInteractions(task);
|
verifyNoInteractions(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -188,7 +188,7 @@ public class BukkitServiceTest {
|
|||||||
spy.runTaskOptionallyAsync(task);
|
spy.runTaskOptionallyAsync(task);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(task);
|
verifyNoInteractions(task);
|
||||||
verify(spy).runTaskAsynchronously(task);
|
verify(spy).runTaskAsynchronously(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,9 +12,7 @@ import org.junit.BeforeClass;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
import org.mockito.stubbing.Answer;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@ -110,11 +108,6 @@ public class MigrationServiceTest {
|
|||||||
verifyNoMoreInteractions(settings, dataSource, sha256);
|
verifyNoMoreInteractions(settings, dataSource, sha256);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenEmptyConstructorOnly() {
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(MigrationService.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PlayerAuth authWithNickAndHash(String nick, String hash) {
|
private static PlayerAuth authWithNickAndHash(String nick, String hash) {
|
||||||
return PlayerAuth.builder()
|
return PlayerAuth.builder()
|
||||||
.name(nick)
|
.name(nick)
|
||||||
@ -123,12 +116,9 @@ public class MigrationServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void setSha256MockToUppercase(Sha256 sha256) {
|
private static void setSha256MockToUppercase(Sha256 sha256) {
|
||||||
given(sha256.computeHash(anyString(), anyString())).willAnswer(new Answer<HashedPassword>() {
|
given(sha256.computeHash(anyString(), anyString())).willAnswer(invocation -> {
|
||||||
@Override
|
String plainPassword = invocation.getArgument(0);
|
||||||
public HashedPassword answer(InvocationOnMock invocation) {
|
return new HashedPassword(plainPassword.toUpperCase(), null);
|
||||||
String plainPassword = invocation.getArgument(0);
|
|
||||||
return new HashedPassword(plainPassword.toUpperCase(), null);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@ import static org.mockito.Mockito.mock;
|
|||||||
import static org.mockito.Mockito.only;
|
import static org.mockito.Mockito.only;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link SessionService}.
|
* Test for {@link SessionService}.
|
||||||
@ -66,7 +66,7 @@ public class SessionServiceTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verifyZeroInteractions(dataSource);
|
verifyNoInteractions(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -32,7 +32,7 @@ import static org.mockito.Mockito.mock;
|
|||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link TeleportationService}.
|
* Test for {@link TeleportationService}.
|
||||||
@ -77,8 +77,8 @@ public class TeleportationServiceTest {
|
|||||||
teleportationService.teleportOnJoin(player);
|
teleportationService.teleportOnJoin(player);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(player);
|
verifyNoInteractions(player);
|
||||||
verifyZeroInteractions(bukkitService);
|
verifyNoInteractions(bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -134,7 +134,7 @@ public class TeleportationServiceTest {
|
|||||||
verify(player, never()).teleport(any(Location.class));
|
verify(player, never()).teleport(any(Location.class));
|
||||||
verify(spawnLoader).getFirstSpawn();
|
verify(spawnLoader).getFirstSpawn();
|
||||||
verify(spawnLoader, never()).getSpawnLocation(any(Player.class));
|
verify(spawnLoader, never()).getSpawnLocation(any(Player.class));
|
||||||
verifyZeroInteractions(bukkitService);
|
verifyNoInteractions(bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -148,7 +148,7 @@ public class TeleportationServiceTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(player, never()).teleport(any(Location.class));
|
verify(player, never()).teleport(any(Location.class));
|
||||||
verifyZeroInteractions(bukkitService);
|
verifyNoInteractions(bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -162,7 +162,7 @@ public class TeleportationServiceTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(player, never()).teleport(any(Location.class));
|
verify(player, never()).teleport(any(Location.class));
|
||||||
verifyZeroInteractions(bukkitService);
|
verifyNoInteractions(bukkitService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -226,7 +226,7 @@ public class TeleportationServiceTest {
|
|||||||
teleportationService.teleportOnLogin(player, auth, limbo);
|
teleportationService.teleportOnLogin(player, auth, limbo);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(player, auth, limbo, bukkitService, spawnLoader);
|
verifyNoInteractions(player, auth, limbo, bukkitService, spawnLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -270,7 +270,7 @@ public class TeleportationServiceTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(player, never()).teleport(spawn);
|
verify(player, never()).teleport(spawn);
|
||||||
verifyZeroInteractions(bukkitService, spawnLoader);
|
verifyNoInteractions(bukkitService, spawnLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -387,7 +387,7 @@ public class TeleportationServiceTest {
|
|||||||
teleportationService.teleportOnLogin(player, auth, limbo);
|
teleportationService.teleportOnLogin(player, auth, limbo);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(player);
|
verifyNoInteractions(player);
|
||||||
verify(limbo, times(2)).getLocation();
|
verify(limbo, times(2)).getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ import static org.junit.Assert.assertThat;
|
|||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link ValidationService}.
|
* Test for {@link ValidationService}.
|
||||||
@ -277,7 +277,7 @@ public class ValidationServiceTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(true));
|
assertThat(result, equalTo(true));
|
||||||
verifyZeroInteractions(geoIpService);
|
verifyNoInteractions(geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -21,7 +21,7 @@ import java.util.logging.Logger;
|
|||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.internal.verification.VerificationModeFactory.times;
|
import static org.mockito.internal.verification.VerificationModeFactory.times;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,6 +76,6 @@ public class SettingsWarnerTest {
|
|||||||
settingsWarner.logWarningsForMisconfigurations();
|
settingsWarner.logWarningsForMisconfigurations();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(logger);
|
verifyNoInteractions(logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.hasSize;
|
|||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link WelcomeMessageConfiguration}.
|
* Test for {@link WelcomeMessageConfiguration}.
|
||||||
@ -81,7 +81,7 @@ public class WelcomeMessageConfigurationTest {
|
|||||||
// then
|
// then
|
||||||
assertThat(result, hasSize(2));
|
assertThat(result, hasSize(2));
|
||||||
assertThat(result, contains(welcomeMessage.split("\\n")));
|
assertThat(result, contains(welcomeMessage.split("\\n")));
|
||||||
verifyZeroInteractions(player, playerCache, geoIpService, bukkitService, server);
|
verifyNoInteractions(player, playerCache, geoIpService, bukkitService, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -104,7 +104,7 @@ public class WelcomeMessageConfigurationTest {
|
|||||||
assertThat(result.get(0), equalTo("Hello Bobby, your IP is 123.45.66.77"));
|
assertThat(result.get(0), equalTo("Hello Bobby, your IP is 123.45.66.77"));
|
||||||
assertThat(result.get(1), equalTo("Your country is Syldavia."));
|
assertThat(result.get(1), equalTo("Your country is Syldavia."));
|
||||||
assertThat(result.get(2), equalTo("Welcome to CrazyServer!"));
|
assertThat(result.get(2), equalTo("Welcome to CrazyServer!"));
|
||||||
verifyZeroInteractions(server, playerCache);
|
verifyNoInteractions(server, playerCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -28,8 +28,8 @@ import static org.mockito.Mockito.mock;
|
|||||||
import static org.mockito.Mockito.only;
|
import static org.mockito.Mockito.only;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link CommandManager}.
|
* Test for {@link CommandManager}.
|
||||||
@ -80,7 +80,7 @@ public class CommandManagerTest {
|
|||||||
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(60L));
|
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(60L));
|
||||||
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(120L));
|
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(120L));
|
||||||
verifyNoMoreInteractions(bukkitService);
|
verifyNoMoreInteractions(bukkitService);
|
||||||
verifyZeroInteractions(geoIpService);
|
verifyNoInteractions(geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -101,7 +101,7 @@ public class CommandManagerTest {
|
|||||||
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(120L));
|
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(120L));
|
||||||
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(180L));
|
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(180L));
|
||||||
verifyNoMoreInteractions(bukkitService);
|
verifyNoMoreInteractions(bukkitService);
|
||||||
verifyZeroInteractions(geoIpService);
|
verifyNoInteractions(geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -124,7 +124,7 @@ public class CommandManagerTest {
|
|||||||
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(180L));
|
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(180L));
|
||||||
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(240L));
|
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(240L));
|
||||||
verifyNoMoreInteractions(bukkitService);
|
verifyNoMoreInteractions(bukkitService);
|
||||||
verifyZeroInteractions(geoIpService);
|
verifyNoInteractions(geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -145,7 +145,7 @@ public class CommandManagerTest {
|
|||||||
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(120L));
|
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(120L));
|
||||||
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(180L));
|
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(180L));
|
||||||
verifyNoMoreInteractions(bukkitService);
|
verifyNoMoreInteractions(bukkitService);
|
||||||
verifyZeroInteractions(geoIpService);
|
verifyNoInteractions(geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -163,7 +163,7 @@ public class CommandManagerTest {
|
|||||||
verify(bukkitService).dispatchCommand(any(Player.class), eq("list"));
|
verify(bukkitService).dispatchCommand(any(Player.class), eq("list"));
|
||||||
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(100L));
|
verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(100L));
|
||||||
verifyNoMoreInteractions(bukkitService);
|
verifyNoMoreInteractions(bukkitService);
|
||||||
verifyZeroInteractions(geoIpService);
|
verifyNoInteractions(geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -178,7 +178,7 @@ public class CommandManagerTest {
|
|||||||
// then
|
// then
|
||||||
verify(bukkitService).dispatchConsoleCommand("msg Bobby Session login!");
|
verify(bukkitService).dispatchConsoleCommand("msg Bobby Session login!");
|
||||||
verifyNoMoreInteractions(bukkitService);
|
verifyNoMoreInteractions(bukkitService);
|
||||||
verifyZeroInteractions(geoIpService);
|
verifyNoInteractions(geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -193,7 +193,7 @@ public class CommandManagerTest {
|
|||||||
// then
|
// then
|
||||||
verify(bukkitService).dispatchConsoleCommand("pay Bobby 30");
|
verify(bukkitService).dispatchConsoleCommand("pay Bobby 30");
|
||||||
verifyNoMoreInteractions(bukkitService);
|
verifyNoMoreInteractions(bukkitService);
|
||||||
verifyZeroInteractions(geoIpService);
|
verifyNoInteractions(geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -206,7 +206,7 @@ public class CommandManagerTest {
|
|||||||
manager.runCommandsOnFirstLogin(player, Arrays.asList("u", "wot", "m8"));
|
manager.runCommandsOnFirstLogin(player, Arrays.asList("u", "wot", "m8"));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(bukkitService, geoIpService);
|
verifyNoInteractions(bukkitService, geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -220,7 +220,7 @@ public class CommandManagerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(bukkitService, only()).dispatchConsoleCommand("broadcast bob has joined");
|
verify(bukkitService, only()).dispatchConsoleCommand("broadcast bob has joined");
|
||||||
verifyZeroInteractions(geoIpService);
|
verifyNoInteractions(geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -234,7 +234,7 @@ public class CommandManagerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(bukkitService, only()).dispatchConsoleCommand("broadcast Bobby has joined");
|
verify(bukkitService, only()).dispatchConsoleCommand("broadcast Bobby has joined");
|
||||||
verifyZeroInteractions(geoIpService);
|
verifyNoInteractions(geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -265,7 +265,7 @@ public class CommandManagerTest {
|
|||||||
// then
|
// then
|
||||||
verify(bukkitService).dispatchConsoleCommand("broadcast Bobby (127.0.0.3) logged out");
|
verify(bukkitService).dispatchConsoleCommand("broadcast Bobby (127.0.0.3) logged out");
|
||||||
verifyNoMoreInteractions(bukkitService);
|
verifyNoMoreInteractions(bukkitService);
|
||||||
verifyZeroInteractions(geoIpService);
|
verifyNoInteractions(geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -278,7 +278,7 @@ public class CommandManagerTest {
|
|||||||
manager.runCommandsOnRegister(player);
|
manager.runCommandsOnRegister(player);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(bukkitService, geoIpService);
|
verifyNoInteractions(bukkitService, geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -294,12 +294,6 @@ public class CommandManagerTest {
|
|||||||
verify(bukkitService).dispatchConsoleCommand("msg Bobby sad to see you go!");
|
verify(bukkitService).dispatchConsoleCommand("msg Bobby sad to see you go!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenConstructorInSettingsHolderClass() {
|
|
||||||
// given / when / then
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(CommandSettingsHolder.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initManager() {
|
private void initManager() {
|
||||||
manager = new CommandManager(testFolder, bukkitService, geoIpService, commandMigrationService);
|
manager = new CommandManager(testFolder, bukkitService, geoIpService, commandMigrationService);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package fr.xephi.authme.settings.properties;
|
package fr.xephi.authme.settings.properties;
|
||||||
|
|
||||||
import ch.jalu.configme.configurationdata.ConfigurationData;
|
import ch.jalu.configme.configurationdata.ConfigurationData;
|
||||||
import fr.xephi.authme.TestHelper;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.closeTo;
|
import static org.hamcrest.Matchers.closeTo;
|
||||||
@ -24,9 +23,4 @@ public class AuthMeSettingsRetrieverTest {
|
|||||||
assertThat((double) configurationData.getProperties().size(),
|
assertThat((double) configurationData.getProperties().size(),
|
||||||
closeTo(182, 10));
|
closeTo(182, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenConstructor() {
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(AuthMeSettingsRetriever.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -98,13 +98,6 @@ public class SettingsClassConsistencyTest {
|
|||||||
configData.getProperties(), hasSize((int) totalProperties));
|
configData.getProperties(), hasSize((int) totalProperties));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenEmptyConstructorOnly() {
|
|
||||||
for (Class<?> clazz : classes) {
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(clazz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isValidConstantField(Field field) {
|
private static boolean isValidConstantField(Field field) {
|
||||||
int modifiers = field.getModifiers();
|
int modifiers = field.getModifiers();
|
||||||
return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers);
|
return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers);
|
||||||
|
@ -39,7 +39,7 @@ import static org.mockito.BDDMockito.given;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +77,7 @@ public class PurgeServiceTest {
|
|||||||
purgeService.runAutoPurge();
|
purgeService.runAutoPurge();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(bukkitService, dataSource);
|
verifyNoInteractions(bukkitService, dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -90,7 +90,7 @@ public class PurgeServiceTest {
|
|||||||
purgeService.runAutoPurge();
|
purgeService.runAutoPurge();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verifyZeroInteractions(bukkitService, dataSource);
|
verifyNoInteractions(bukkitService, dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -127,7 +127,7 @@ public class PurgeServiceTest {
|
|||||||
verify(dataSource).getRecordsToPurge(delay);
|
verify(dataSource).getRecordsToPurge(delay);
|
||||||
verify(dataSource, never()).purgeRecords(anyCollection());
|
verify(dataSource, never()).purgeRecords(anyCollection());
|
||||||
verify(sender).sendMessage("No players to purge");
|
verify(sender).sendMessage("No players to purge");
|
||||||
verifyZeroInteractions(bukkitService, permissionsManager);
|
verifyNoInteractions(bukkitService, permissionsManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -160,7 +160,7 @@ public class PurgeServiceTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(sender).sendMessage(argThat(containsString("Purge is already in progress")));
|
verify(sender).sendMessage(argThat(containsString("Purge is already in progress")));
|
||||||
verifyZeroInteractions(bukkitService, dataSource, permissionsManager);
|
verifyNoInteractions(bukkitService, dataSource, permissionsManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package fr.xephi.authme.util;
|
package fr.xephi.authme.util;
|
||||||
|
|
||||||
import fr.xephi.authme.ReflectionTestUtils;
|
import fr.xephi.authme.ReflectionTestUtils;
|
||||||
import fr.xephi.authme.TestHelper;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@ -55,12 +54,6 @@ public class ExceptionUtilsTest {
|
|||||||
assertThat(resultUoe, sameInstance(uoe));
|
assertThat(resultUoe, sameInstance(uoe));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenConstructor() {
|
|
||||||
// given / when / then
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(ExceptionUtils.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldFormatException() {
|
public void shouldFormatException() {
|
||||||
// given
|
// given
|
||||||
|
@ -185,12 +185,6 @@ public class FileUtilsTest {
|
|||||||
assertThat(dirAsFile.isFile(), equalTo(true));
|
assertThat(dirAsFile.isFile(), equalTo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenConstructor() {
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(FileUtils.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldCreateCurrentTimestampString() {
|
public void shouldCreateCurrentTimestampString() {
|
||||||
// given / when
|
// given / when
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package fr.xephi.authme.util;
|
package fr.xephi.authme.util;
|
||||||
|
|
||||||
import fr.xephi.authme.TestHelper;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
@ -50,10 +49,4 @@ public class InternetProtocolUtilsTest {
|
|||||||
assertThat(InternetProtocolUtils.isLoopbackAddress("127.0.0.1"), equalTo(true));
|
assertThat(InternetProtocolUtils.isLoopbackAddress("127.0.0.1"), equalTo(true));
|
||||||
assertThat(InternetProtocolUtils.isLoopbackAddress("::1"), equalTo(true));
|
assertThat(InternetProtocolUtils.isLoopbackAddress("::1"), equalTo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHavePrivateConstructor() {
|
|
||||||
// given / when / then
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(InternetProtocolUtils.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.doThrow;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,12 +34,6 @@ public class PlayerUtilsTest {
|
|||||||
assertThat(result, equalTo(ip));
|
assertThat(result, equalTo(ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenConstructor() {
|
|
||||||
// given / when / then
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(PlayerUtils.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldCheckIfIsNpc() {
|
public void shouldCheckIfIsNpc() {
|
||||||
// given
|
// given
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package fr.xephi.authme.util;
|
package fr.xephi.authme.util;
|
||||||
|
|
||||||
import fr.xephi.authme.TestHelper;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -84,11 +83,4 @@ public class RandomStringUtilsTest {
|
|||||||
|
|
||||||
// then - throw exception
|
// then - throw exception
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenConstructor() {
|
|
||||||
// given / when / then
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(RandomStringUtils.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package fr.xephi.authme.util;
|
package fr.xephi.authme.util;
|
||||||
|
|
||||||
import fr.xephi.authme.TestHelper;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
@ -77,11 +76,6 @@ public class StringUtilsTest {
|
|||||||
assertThat(StringUtils.getDifference("test", "something"), greaterThan(0.88));
|
assertThat(StringUtils.getDifference("test", "something"), greaterThan(0.88));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenConstructor() {
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(StringUtils.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldCheckIfHasNeedleInWord() {
|
public void shouldCheckIfHasNeedleInWord() {
|
||||||
// given/when/then
|
// given/when/then
|
||||||
|
@ -16,11 +16,10 @@ import java.util.logging.Logger;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.greaterThan;
|
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link Utils}.
|
* Test for {@link Utils}.
|
||||||
@ -56,12 +55,6 @@ public class UtilsTest {
|
|||||||
assertThat(result.toString(), equalTo(".*?"));
|
assertThat(result.toString(), equalTo(".*?"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHavePrivateConstructorOnly() {
|
|
||||||
// given / when / then
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(Utils.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldLogAndSendMessage() {
|
public void shouldLogAndSendMessage() {
|
||||||
// given
|
// given
|
||||||
@ -102,7 +95,7 @@ public class UtilsTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(logger).info(message);
|
verify(logger).info(message);
|
||||||
verifyZeroInteractions(sender);
|
verifyNoInteractions(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -144,7 +137,7 @@ public class UtilsTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
verify(logger).warning(message);
|
verify(logger).warning(message);
|
||||||
verifyZeroInteractions(sender);
|
verifyNoInteractions(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package fr.xephi.authme.util.lazytags;
|
package fr.xephi.authme.util.lazytags;
|
||||||
|
|
||||||
import fr.xephi.authme.TestHelper;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -40,11 +39,4 @@ public class TagBuilderTest {
|
|||||||
assertThat(tag, instanceOf(DependentTag.class));
|
assertThat(tag, instanceOf(DependentTag.class));
|
||||||
assertThat(tag.getValue(24d), equalTo("26.4"));
|
assertThat(tag.getValue(24d), equalTo("26.4"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldHaveHiddenConstructor() {
|
|
||||||
// given / when / then
|
|
||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(TagBuilder.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
## AuthMe Configuration
|
## AuthMe Configuration
|
||||||
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
|
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
|
||||||
with which you can configure various settings. This following is the initial contents of
|
with which you can configure various settings. The following is the initial contents of
|
||||||
the generated config.yml file.
|
the generated config.yml file.
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
|
@ -2,9 +2,8 @@ package tools.docs.translations;
|
|||||||
|
|
||||||
import ch.jalu.configme.resource.PropertyReader;
|
import ch.jalu.configme.resource.PropertyReader;
|
||||||
import ch.jalu.configme.resource.YamlFileReader;
|
import ch.jalu.configme.resource.YamlFileReader;
|
||||||
import fr.xephi.authme.message.MessagePathHelper;
|
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import tools.utils.ToolsConstants;
|
import fr.xephi.authme.message.MessagePathHelper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -12,13 +11,14 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static tools.utils.FileIoUtils.listFilesOrThrow;
|
import static tools.utils.FileIoUtils.listFilesOrThrow;
|
||||||
|
import static tools.utils.ToolsConstants.MAIN_RESOURCES_ROOT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gathers all available translations of AuthMe.
|
* Gathers all available translations of AuthMe.
|
||||||
*/
|
*/
|
||||||
public class TranslationsGatherer {
|
public class TranslationsGatherer {
|
||||||
|
|
||||||
private static final String MESSAGES_FOLDER = ToolsConstants.MAIN_RESOURCES_ROOT + MessagePathHelper.MESSAGES_FOLDER;
|
private static final String MESSAGES_FOLDER = MAIN_RESOURCES_ROOT + MessagePathHelper.MESSAGES_FOLDER;
|
||||||
|
|
||||||
private List<TranslationInfo> translationInfo = new ArrayList<>();
|
private List<TranslationInfo> translationInfo = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -109,6 +109,12 @@ public class HelpTranslationVerifier {
|
|||||||
return commandPaths;
|
return commandPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates all paths of the properties that are used to define the help translation of the given command definition.
|
||||||
|
*
|
||||||
|
* @param command the command to create the paths for
|
||||||
|
* @return all yaml paths that can be used to translate the command
|
||||||
|
*/
|
||||||
private List<String> getYamlPaths(CommandDescription command) {
|
private List<String> getYamlPaths(CommandDescription command) {
|
||||||
// e.g. commands.authme.register
|
// e.g. commands.authme.register
|
||||||
String commandPath = "commands." + CommandUtils.constructParentList(command).stream()
|
String commandPath = "commands." + CommandUtils.constructParentList(command).stream()
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package tools.messages;
|
package tools.messages;
|
||||||
|
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import fr.xephi.authme.message.MessagePathHelper;
|
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
|
import fr.xephi.authme.message.MessagePathHelper;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import tools.utils.ToolTask;
|
import tools.utils.ToolTask;
|
||||||
import tools.utils.ToolsConstants;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -19,6 +18,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import static fr.xephi.authme.message.MessagePathHelper.DEFAULT_MESSAGES_FILE;
|
import static fr.xephi.authme.message.MessagePathHelper.DEFAULT_MESSAGES_FILE;
|
||||||
import static tools.utils.FileIoUtils.listFilesOrThrow;
|
import static tools.utils.FileIoUtils.listFilesOrThrow;
|
||||||
|
import static tools.utils.ToolsConstants.MAIN_RESOURCES_ROOT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task to verify the keys in the messages files.
|
* Task to verify the keys in the messages files.
|
||||||
@ -26,7 +26,7 @@ import static tools.utils.FileIoUtils.listFilesOrThrow;
|
|||||||
public final class VerifyMessagesTask implements ToolTask {
|
public final class VerifyMessagesTask implements ToolTask {
|
||||||
|
|
||||||
/** The folder containing the message files. */
|
/** The folder containing the message files. */
|
||||||
private static final String MESSAGES_FOLDER = ToolsConstants.MAIN_RESOURCES_ROOT + MessagePathHelper.MESSAGES_FOLDER;
|
private static final String MESSAGES_FOLDER = MAIN_RESOURCES_ROOT + MessagePathHelper.MESSAGES_FOLDER;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTaskName() {
|
public String getTaskName() {
|
||||||
@ -47,13 +47,14 @@ public final class VerifyMessagesTask implements ToolTask {
|
|||||||
if (StringUtils.isEmpty(inputFile)) {
|
if (StringUtils.isEmpty(inputFile)) {
|
||||||
messageFiles = getMessagesFiles();
|
messageFiles = getMessagesFiles();
|
||||||
} else {
|
} else {
|
||||||
File customFile = new File(ToolsConstants.MAIN_RESOURCES_ROOT, MessagePathHelper.createMessageFilePath(inputFile));
|
File customFile = new File(MAIN_RESOURCES_ROOT, MessagePathHelper.createMessageFilePath(inputFile));
|
||||||
messageFiles = Collections.singletonList(customFile);
|
messageFiles = Collections.singletonList(customFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileConfiguration defaultFileConfiguration = null;
|
FileConfiguration defaultFileConfiguration = null;
|
||||||
if (addMissingKeys) {
|
if (addMissingKeys) {
|
||||||
defaultFileConfiguration = YamlConfiguration.loadConfiguration(new File(ToolsConstants.MAIN_RESOURCES_ROOT, DEFAULT_MESSAGES_FILE));
|
defaultFileConfiguration = YamlConfiguration.loadConfiguration(
|
||||||
|
new File(MAIN_RESOURCES_ROOT, DEFAULT_MESSAGES_FILE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the given files
|
// Verify the given files
|
||||||
|
@ -42,7 +42,7 @@ settings:
|
|||||||
maxNicknameLength: 16
|
maxNicknameLength: 16
|
||||||
# When this setting is enabled, online players can't be kicked out
|
# When this setting is enabled, online players can't be kicked out
|
||||||
# due to "Logged in from another Location"
|
# due to "Logged in from another Location"
|
||||||
# This setting will prevent potetial security exploits.
|
# This setting will prevent potential security exploits.
|
||||||
ForceSingleSession: true
|
ForceSingleSession: true
|
||||||
ForceSpawnLocOnJoin:
|
ForceSpawnLocOnJoin:
|
||||||
# If enabled, every player will be teleported to the world spawnpoint
|
# If enabled, every player will be teleported to the world spawnpoint
|
||||||
@ -61,7 +61,7 @@ settings:
|
|||||||
SaveQuitLocation: false
|
SaveQuitLocation: false
|
||||||
# To activate the restricted user feature you need
|
# To activate the restricted user feature you need
|
||||||
# to enable this option and configure the
|
# to enable this option and configure the
|
||||||
# AllowedRestrctedUser field.
|
# AllowedRestrictedUser field.
|
||||||
AllowRestrictedUser: false
|
AllowRestrictedUser: false
|
||||||
# The restricted user feature will kick players listed below
|
# The restricted user feature will kick players listed below
|
||||||
# if they don't match of the defined ip address.
|
# if they don't match of the defined ip address.
|
||||||
@ -87,7 +87,7 @@ settings:
|
|||||||
# After how many time players who fail to login or register
|
# After how many time players who fail to login or register
|
||||||
# should be kicked? Set to 0 to disable.
|
# should be kicked? Set to 0 to disable.
|
||||||
timeout: 30
|
timeout: 30
|
||||||
# Regex sintax of allowed characters in the player name.
|
# Regex syntax of allowed characters in the player name.
|
||||||
allowedNicknameCharacters: '[a-zA-Z0-9_]*'
|
allowedNicknameCharacters: '[a-zA-Z0-9_]*'
|
||||||
# How far can unregistered players walk? Set to 0
|
# How far can unregistered players walk? Set to 0
|
||||||
# for unlimited radius
|
# for unlimited radius
|
||||||
|
2
src/test/resources/simplelogger.properties
Normal file
2
src/test/resources/simplelogger.properties
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Suppress INFO statements when a new Hikari pool is being created
|
||||||
|
org.slf4j.simpleLogger.log.com.zaxxer.hikari=WARN
|
Loading…
Reference in New Issue
Block a user