Search in sources :

Example 16 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class ConfigUpdaterTest method proxyConfigIsPatchedCorrectly.

@Test
void proxyConfigIsPatchedCorrectly() throws IOException, IllegalAccessException {
    Path configPath = tempDir.resolve("oldconfig.yml");
    Files.copy(oldBungeeConfig.toPath(), configPath, StandardCopyOption.REPLACE_EXISTING);
    PlanConfig config = new PlanConfig(configPath.toFile(), null, null, new TestPluginLogger());
    UNDER_TEST.applyConfigUpdate(config);
    // Ensure that added settings are present
    copyMissingFrom(config, newBungeeConfig);
    TestSettings.assertValidDefaultValuesForAllSettings(config, TestSettings.getProxySettings());
}
Also used : Path(java.nio.file.Path) TestPluginLogger(utilities.TestPluginLogger) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 17 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class ConfigUpdaterTest method serverMoveChangesDoNotLeaveNewEmptyValues.

@Test
void serverMoveChangesDoNotLeaveNewEmptyValues() throws IOException {
    Path configPath = tempDir.resolve("oldconfig.yml");
    Files.copy(oldConfig.toPath(), configPath, StandardCopyOption.REPLACE_EXISTING);
    PlanConfig config = new PlanConfig(configPath.toFile(), null, null, new TestPluginLogger());
    ConfigChange[] changes = UNDER_TEST.configEnhancementPatch();
    assertMoveChangesAreAppliedProperly(config, changes);
}
Also used : Path(java.nio.file.Path) TestPluginLogger(utilities.TestPluginLogger) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 18 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class TimeAmountFormatterDefaultTest method setUpFormatter.

@BeforeAll
static void setUpFormatter() {
    PlanConfig config = Mockito.mock(PlanConfig.class);
    when(config.get(FormatSettings.YEAR)).thenReturn("1 year, ");
    when(config.get(FormatSettings.YEARS)).thenReturn("%years% years, ");
    when(config.get(FormatSettings.MONTH)).thenReturn("1 month, ");
    when(config.get(FormatSettings.YEAR)).thenReturn("1 year, ");
    when(config.get(FormatSettings.MONTH)).thenReturn("1 month, ");
    when(config.get(FormatSettings.MONTHS)).thenReturn("%months% months, ");
    when(config.get(FormatSettings.DAY)).thenReturn("1d ");
    when(config.get(FormatSettings.DAYS)).thenReturn("%days%d ");
    when(config.get(FormatSettings.HOURS)).thenReturn("%hours%h ");
    when(config.get(FormatSettings.MINUTES)).thenReturn("%minutes%m ");
    when(config.get(FormatSettings.SECONDS)).thenReturn("%seconds%s");
    when(config.get(FormatSettings.ZERO_SECONDS)).thenReturn("0s");
    underTest = new TimeAmountFormatter(config);
}
Also used : PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) TimeAmountFormatter(com.djrapitops.plan.delivery.formatting.time.TimeAmountFormatter) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 19 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class AccessControlTest method setUpClass.

@BeforeAll
static void setUpClass(@TempDir Path tempDir) throws Exception {
    File file = tempDir.resolve("TestCert.p12").toFile();
    File testCert = TestResources.getTestResourceFile("TestCert.p12", ConfigUpdater.class);
    Files.copy(testCert.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
    String absolutePath = file.getAbsolutePath();
    PluginMockComponent component = new PluginMockComponent(tempDir);
    system = component.getPlanSystem();
    PlanConfig config = system.getConfigSystem().getConfig();
    config.set(WebserverSettings.CERTIFICATE_PATH, absolutePath);
    config.set(WebserverSettings.CERTIFICATE_KEYPASS, "test");
    config.set(WebserverSettings.CERTIFICATE_STOREPASS, "test");
    config.set(WebserverSettings.CERTIFICATE_ALIAS, "test");
    config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
    system.enable();
    User userLevel0 = new User("test0", "console", null, PassEncryptUtil.createHash("testPass"), 0, Collections.emptyList());
    User userLevel1 = new User("test1", "console", null, PassEncryptUtil.createHash("testPass"), 1, Collections.emptyList());
    User userLevel2 = new User("test2", TestConstants.PLAYER_ONE_NAME, TestConstants.PLAYER_ONE_UUID, PassEncryptUtil.createHash("testPass"), 2, Collections.emptyList());
    User userLevel100 = new User("test100", "console", null, PassEncryptUtil.createHash("testPass"), 100, Collections.emptyList());
    system.getDatabaseSystem().getDatabase().executeTransaction(new RegisterWebUserTransaction(userLevel0));
    system.getDatabaseSystem().getDatabase().executeTransaction(new RegisterWebUserTransaction(userLevel1));
    system.getDatabaseSystem().getDatabase().executeTransaction(new RegisterWebUserTransaction(userLevel2));
    system.getDatabaseSystem().getDatabase().executeTransaction(new RegisterWebUserTransaction(userLevel100));
    system.getDatabaseSystem().getDatabase().executeTransaction(new PlayerRegisterTransaction(TestConstants.PLAYER_ONE_UUID, () -> 0L, TestConstants.PLAYER_ONE_NAME));
    system.getDatabaseSystem().getDatabase().executeTransaction(new StoreServerInformationTransaction(new Server(TestConstants.SERVER_UUID, TestConstants.SERVER_NAME, address, TestConstants.VERSION)));
    Caller caller = system.getExtensionService().register(new ExtensionsDatabaseTest.PlayerExtension()).orElseThrow(AssertionError::new);
    caller.updatePlayerData(TestConstants.PLAYER_ONE_UUID, TestConstants.PLAYER_ONE_NAME);
    address = "https://localhost:" + TEST_PORT_NUMBER;
    cookieLevel0 = login(address, userLevel0.getUsername());
    cookieLevel1 = login(address, userLevel1.getUsername());
    cookieLevel2 = login(address, userLevel2.getUsername());
    cookieLevel100 = login(address, userLevel100.getUsername());
}
Also used : User(com.djrapitops.plan.delivery.domain.auth.User) RegisterWebUserTransaction(com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction) Server(com.djrapitops.plan.identification.Server) Caller(com.djrapitops.plan.extension.Caller) StoreServerInformationTransaction(com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) PluginMockComponent(utilities.mocks.PluginMockComponent) File(java.io.File) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 20 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class AFKTrackerTest method setUpAfkTracker.

@BeforeEach
void setUpAfkTracker() {
    PlanConfig config = Mockito.mock(PlanConfig.class);
    afkThreshold = TimeUnit.MINUTES.toMillis(1L);
    when(config.get(TimeSettings.AFK_THRESHOLD)).thenReturn(afkThreshold);
    new SessionCache().cacheSession(playerUUID, new ActiveSession(playerUUID, null, 0, null, null));
    underTest = new AFKTracker(config);
}
Also used : ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) SessionCache(com.djrapitops.plan.gathering.cache.SessionCache) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)31 Test (org.junit.jupiter.api.Test)17 BeforeAll (org.junit.jupiter.api.BeforeAll)7 Path (java.nio.file.Path)5 TestPluginLogger (utilities.TestPluginLogger)5 PluginMockComponent (utilities.mocks.PluginMockComponent)5 DBSystem (com.djrapitops.plan.storage.database.DBSystem)4 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)4 User (com.djrapitops.plan.delivery.domain.auth.User)3 SessionCache (com.djrapitops.plan.gathering.cache.SessionCache)3 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)3 SQLiteDB (com.djrapitops.plan.storage.database.SQLiteDB)3 RegisterWebUserTransaction (com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction)3 File (java.io.File)3 TimeAmountFormatter (com.djrapitops.plan.delivery.formatting.time.TimeAmountFormatter)2 Setting (com.djrapitops.plan.settings.config.paths.key.Setting)2 SQLDB (com.djrapitops.plan.storage.database.SQLDB)2 StoreConfigTransaction (com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction)2 ErrorLogger (com.djrapitops.plan.utilities.logging.ErrorLogger)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2