Fixed tests

This commit is contained in:
Risto Lahtela 2022-01-06 15:50:59 +02:00
parent a7478645bd
commit 243dc0a748
2 changed files with 15 additions and 7 deletions

View File

@ -28,7 +28,6 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import utilities.TestConstants;
import utilities.mocks.objects.TestRunnableFactory;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@ -46,9 +45,9 @@ class ActiveCookieStoreTest {
when(dbSystem.getDatabase()).thenReturn(db);
underTest = new ActiveCookieStore(
activeCookieExpiryCleanupTask, Mockito.mock(PlanConfig.class),
Mockito.mock(ActiveCookieExpiryCleanupTask.class),
Mockito.mock(PlanConfig.class),
dbSystem,
new TestRunnableFactory(),
Mockito.mock(Processing.class)
);
user = new User(TestConstants.PLAYER_ONE_NAME, "console", null, PassEncryptUtil.createHash("testPass"), 0, WebUser.getPermissionsForLevel(0));

View File

@ -18,6 +18,7 @@ package com.djrapitops.plan.storage.database.queries;
import com.djrapitops.plan.delivery.domain.WebUser;
import com.djrapitops.plan.delivery.domain.auth.User;
import com.djrapitops.plan.delivery.webserver.auth.ActiveCookieExpiryCleanupTask;
import com.djrapitops.plan.delivery.webserver.auth.ActiveCookieStore;
import com.djrapitops.plan.processing.Processing;
import com.djrapitops.plan.settings.config.PlanConfig;
@ -30,7 +31,6 @@ import com.djrapitops.plan.utilities.PassEncryptUtil;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import utilities.TestConstants;
import utilities.mocks.objects.TestRunnableFactory;
import java.util.Collections;
import java.util.Map;
@ -78,7 +78,7 @@ public interface WebUserQueriesTest extends DatabaseTestPreparer {
userIsRegistered();
User user = db().query(WebUserQueries.fetchUser(WEB_USERNAME)).orElseThrow(AssertionError::new);
ActiveCookieStore cookieStore = new ActiveCookieStore(activeCookieExpiryCleanupTask, Mockito.mock(PlanConfig.class), dbSystem(), new TestRunnableFactory(), Mockito.mock(Processing.class));
ActiveCookieStore cookieStore = createActiveCookieStore();
String cookie = cookieStore.generateNewCookie(user);
@ -92,7 +92,7 @@ public interface WebUserQueriesTest extends DatabaseTestPreparer {
userIsRegistered();
User user = db().query(WebUserQueries.fetchUser(WEB_USERNAME)).orElseThrow(AssertionError::new);
ActiveCookieStore cookieStore = new ActiveCookieStore(activeCookieExpiryCleanupTask, Mockito.mock(PlanConfig.class), dbSystem(), new TestRunnableFactory(), Mockito.mock(Processing.class));
ActiveCookieStore cookieStore = createActiveCookieStore();
String cookie = cookieStore.generateNewCookie(user);
@ -106,7 +106,7 @@ public interface WebUserQueriesTest extends DatabaseTestPreparer {
userIsRegistered();
User user = db().query(WebUserQueries.fetchUser(WEB_USERNAME)).orElseThrow(AssertionError::new);
ActiveCookieStore cookieStore = new ActiveCookieStore(activeCookieExpiryCleanupTask, Mockito.mock(PlanConfig.class), dbSystem(), new TestRunnableFactory(), Mockito.mock(Processing.class));
ActiveCookieStore cookieStore = createActiveCookieStore();
String cookie = cookieStore.generateNewCookie(user);
@ -117,6 +117,15 @@ public interface WebUserQueriesTest extends DatabaseTestPreparer {
assertTrue(db().query(WebUserQueries.fetchActiveCookies()).isEmpty());
}
private ActiveCookieStore createActiveCookieStore() {
return new ActiveCookieStore(
Mockito.mock(ActiveCookieExpiryCleanupTask.class),
Mockito.mock(PlanConfig.class),
dbSystem(),
Mockito.mock(Processing.class)
);
}
@Test
default void removeEverythingRemovesCookies() {
activeCookieStoreSavesCookies();