This issue aims to fix the issue that is brought up in most cases in all server tests
SessionsPluginsTest > generate fake user, bail if invalid password, accept if valid password STANDARD_ERROR
[Test worker] INFO org.noelware.charted.common.ReflectionUtils - Finding field [_database] in class [Builder]!
[Test worker] INFO org.noelware.charted.common.ReflectionUtils - Finding field [_redis] in class [Builder]!
[Test worker @coroutine#53] INFO org.noelware.charted.server.testing.TestBootstrapPhase - Initializing bootstrapping phase for tests...
[Test worker @coroutine#53] INFO com.zaxxer.hikari.HikariDataSource - Postgres-HikariPool - Starting...
[Test worker @coroutine#53] INFO com.zaxxer.hikari.pool.HikariPool - Postgres-HikariPool - Added connection org.postgresql.jdbc.PgConnection@52bb3dcd
[Test worker @coroutine#53] INFO com.zaxxer.hikari.HikariDataSource - Postgres-HikariPool - Start completed.
[Test worker @coroutine#53] INFO org.noelware.charted.server.testing.TestBootstrapPhase - Connected to Postgres test container, running all migrations!
[Test worker @coroutine#53] INFO Exposed - Preparing create tables statements took 9ms
[Test worker @coroutine#53] INFO Exposed - Executing create tables statements took 27ms
[Test worker @coroutine#53] INFO Exposed - Extracting table columns took 8ms
[Test worker @coroutine#53] INFO Exposed - Extracting column constraints took 82ms
[Test worker @coroutine#53] INFO Exposed - Preparing alter table statements took 92ms
[Test worker @coroutine#53] INFO Exposed - Executing alter table statements took 34ms
[Test worker @coroutine#53] INFO Exposed - Checking mapping consistence took 40ms
[Test worker @coroutine#53] INFO org.noelware.charted.server.testing.TestBootstrapPhase - Ran all pending migrations! Connecting to Redis...
[Test worker @coroutine#53] INFO org.noelware.charted.modules.redis.DefaultRedisClient - Connecting to the Redis server...
[Test worker @coroutine#53] INFO org.noelware.charted.modules.redis.DefaultRedisClient - Checking connection...
[Test worker @coroutine#53] INFO org.noelware.charted.modules.redis.DefaultRedisClient - Connected to Redis in [3ms]
[Test worker @coroutine#53] INFO org.noelware.charted.server.testing.TestBootstrapPhase - Connected to Redis! Initializing storage driver...
[Test worker @coroutine#53] INFO org.noelware.charted.modules.storage.DefaultStorageHandler - Determining which storage service to use!
[Test worker @coroutine#53] INFO org.noelware.charted.modules.storage.DefaultStorageHandler - Configured to use storage trailer remi:filesystem
[Test worker @coroutine#53] INFO org.noelware.remi.support.filesystem.FilesystemStorageService - Initialized filesystem storage service on directory [./.data] with drive [/dev/sdb2 (fuseblk)]
[Test worker @coroutine#53] INFO org.noelware.charted.server.testing.TestBootstrapPhase - Initialized storage driver, now starting up Koin...
[Test worker @coroutine#53] INFO org.noelware.charted.modules.apikeys.DefaultApiKeyManager - Collecting all API key expirations from Redis...
[Test worker @coroutine#53] INFO org.noelware.charted.modules.apikeys.DefaultApiKeyManager - Took 637098µs to collect 0 sessions from Redis!
[Test worker @coroutine#53] INFO org.noelware.charted.modules.sessions.SessionManager - Collecting all sessions from Redis...
[Test worker @coroutine#53] INFO org.noelware.charted.modules.sessions.SessionManager - Took 367411µs to collect 0 sessions from Redis!
[Test worker @coroutine#53] WARN org.koin.core.Koin - (+) override index 'org.noelware.ktor.endpoints.AbstractEndpoint::_root_' -> '[Singleton:'org.noelware.charted.server.endpoints.v1.api.repositories.RepositoriesEndpoints',binds:org.noelware.ktor.endpoints.AbstractEndpoint]'
[Test worker @coroutine#53] WARN org.koin.core.Koin - (+) override index 'org.noelware.ktor.endpoints.AbstractEndpoint::_root_' -> '[Singleton:'org.noelware.charted.server.endpoints.v1.api.admin.AdminEndpoints',binds:org.noelware.ktor.endpoints.AbstractEndpoint]'
[Test worker @coroutine#53] WARN org.koin.core.Koin - (+) override index 'org.noelware.ktor.endpoints.AbstractEndpoint::_root_' -> '[Singleton:'org.noelware.charted.server.endpoints.v1.api.OrganizationsEndpoint',binds:org.noelware.ktor.endpoints.AbstractEndpoint]'
[Test worker @coroutine#53] WARN org.koin.core.Koin - (+) override index 'org.noelware.ktor.endpoints.AbstractEndpoint::_root_' -> '[Singleton:'org.noelware.charted.server.endpoints.v1.InfoEndpoint',binds:org.noelware.ktor.endpoints.AbstractEndpoint]'
[Test worker @coroutine#53] INFO org.koin.core.Koin - loaded 28 definitions in 0.241333 ms
[Test worker] INFO org.noelware.charted.server.testing.TestChartedServer - Starting test server!
[Test worker @coroutine#56] INFO org.noelware.charted.modules.helm.charts.DefaultHelmChartModule - Creating missing directories if any...
[Test worker @coroutine#56] INFO org.noelware.charted.modules.helm.charts.DefaultHelmChartModule - Creating index.yaml for user [21242647142203392]
[DefaultDispatcher-worker-3 @call-context#57] INFO ktor.test - No ktor.deployment.watch patterns specified, automatic reload is not active.
[DefaultDispatcher-worker-3 @call-context#57] INFO org.noelware.ktor.plugin.NoelKtorRouting - Installing NoelKtorRouting into the base application!
[DefaultDispatcher-worker-3 @call-context#57] ERROR org.koin.core.Koin - * No instance found for org.noelware.charted.modules.elasticsearch.ElasticsearchModule on scope ['_root_']
[DefaultDispatcher-worker-3 @call-context#57] INFO org.noelware.ktor.plugin.NoelKtorRouting - Now registering 10 endpoints to Ktor...
[DefaultDispatcher-worker-3 @call-context#57] INFO ktor.test - Application started in 0.008 seconds.
[DefaultDispatcher-worker-3 @call-context#57] INFO org.noelware.charted.server.plugins.LogPluginKt - API server has started [30s]
[Charted-CoroutineExecutor[0] @coroutine#61] WARN Exposed - Transaction attempt #1 failed: java.sql.SQLException: HikariDataSource HikariDataSource (Postgres-HikariPool) has been closed.. Statement(s): SELECT users.id, users.gravatar_email, users.description, users.avatar_hash, users.created_at, users.updated_at, users.username, users."password", users.flags, users.email, users."name" FROM users WHERE users.username = ?
org.jetbrains.exposed.exceptions.ExposedSQLException: java.sql.SQLException: HikariDataSource HikariDataSource (Postgres-HikariPool) has been closed.
SQL: [SELECT users.id, users.gravatar_email, users.description, users.avatar_hash, users.created_at, users.updated_at, users.username, users."password", users.flags, users.email, users."name" FROM users WHERE users.username = ?]
at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_core(Statement.kt:49)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:141)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:127)
at org.jetbrains.exposed.sql.AbstractQuery.iterator(AbstractQuery.kt:61)
at org.jetbrains.exposed.sql.IterableExKt$mapLazy$1.iterator(IterableEx.kt:136)
at kotlin.collections.CollectionsKt___CollectionsKt.firstOrNull(_Collections.kt:269)
at org.noelware.charted.server.plugins.SessionsPlugin$doBasicAuth$user$1.invokeSuspend(SessionsPlugin.kt:323)
at org.noelware.charted.server.plugins.SessionsPlugin$doBasicAuth$user$1.invoke(SessionsPlugin.kt)
at org.noelware.charted.server.plugins.SessionsPlugin$doBasicAuth$user$1.invoke(SessionsPlugin.kt)
at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt$suspendedTransactionAsyncInternal$1.invokeSuspend(Suspended.kt:129)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.sql.SQLException: HikariDataSource HikariDataSource (Postgres-HikariPool) has been closed.
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:96)
at org.jetbrains.exposed.sql.Database$Companion$connect$3.invoke(Database.kt:141)
at org.jetbrains.exposed.sql.Database$Companion$connect$3.invoke(Database.kt:138)
at org.jetbrains.exposed.sql.Database$Companion$doConnect$3.invoke(Database.kt:126)
at org.jetbrains.exposed.sql.Database$Companion$doConnect$3.invoke(Database.kt:127)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction$connectionLazy$1.invoke(ThreadLocalTransactionManager.kt:76)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction$connectionLazy$1.invoke(ThreadLocalTransactionManager.kt:75)
at kotlin.UnsafeLazyImpl.getValue(Lazy.kt:81)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction.getConnection(ThreadLocalTransactionManager.kt:89)
at org.jetbrains.exposed.sql.Transaction.getConnection(Transaction.kt)
at org.jetbrains.exposed.sql.statements.Statement.prepared(Statement.kt:24)
at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_core(Statement.kt:47)
... 14 more
[DefaultDispatcher-worker-3 @request#57] ERROR org.noelware.charted.server.internal.DefaultChartedServer - Unknown exception had occurred while handling request [GET /users/@me]
org.jetbrains.exposed.exceptions.ExposedSQLException: java.sql.SQLException: HikariDataSource HikariDataSource (Postgres-HikariPool) has been closed.
SQL: [Failed on expanding args for SELECT: org.jetbrains.exposed.sql.Query@6ef00534]
at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_core(Statement.kt:49)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:141)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:127)
at org.jetbrains.exposed.sql.AbstractQuery.iterator(AbstractQuery.kt:61)
at org.jetbrains.exposed.sql.IterableExKt$mapLazy$1.iterator(IterableEx.kt:136)
at kotlin.collections.CollectionsKt___CollectionsKt.firstOrNull(_Collections.kt:269)
at org.noelware.charted.server.plugins.SessionsPlugin$doBasicAuth$user$1.invokeSuspend(SessionsPlugin.kt:323)
at org.noelware.charted.server.plugins.SessionsPlugin$doBasicAuth$user$1.invoke(SessionsPlugin.kt)
at org.noelware.charted.server.plugins.SessionsPlugin$doBasicAuth$user$1.invoke(SessionsPlugin.kt)
at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt$suspendedTransactionAsyncInternal$1.invokeSuspend(Suspended.kt:129)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.sql.SQLException: HikariDataSource HikariDataSource (Postgres-HikariPool) has been closed.
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:96)
at org.jetbrains.exposed.sql.Database$Companion$connect$3.invoke(Database.kt:141)
at org.jetbrains.exposed.sql.Database$Companion$connect$3.invoke(Database.kt:138)
at org.jetbrains.exposed.sql.Database$Companion$doConnect$3.invoke(Database.kt:126)
at org.jetbrains.exposed.sql.Database$Companion$doConnect$3.invoke(Database.kt:127)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction$connectionLazy$1.invoke(ThreadLocalTransactionManager.kt:76)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction$connectionLazy$1.invoke(ThreadLocalTransactionManager.kt:75)
at kotlin.UnsafeLazyImpl.getValue(Lazy.kt:81)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction.getConnection(ThreadLocalTransactionManager.kt:89)
at org.jetbrains.exposed.sql.Transaction.getConnection(Transaction.kt)
at org.jetbrains.exposed.sql.statements.Statement.prepared(Statement.kt:24)
at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_core(Statement.kt:47)
... 14 more
[DefaultDispatcher-worker-3 @request#57] INFO org.noelware.charted.server.plugins.LogPluginKt - GET HTTP/1.1 /users/@me :: 500 Internal Server Error [Ktor client] [21ms]
SessionsPluginsTest > generate fake user, bail if invalid password, accept if valid password FAILED
org.opentest4j.AssertionFailedError: expected: <500 Internal Server Error> but was: <401 Unauthorized>
at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at app//org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at app//org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
at app//org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1153)
at app//kotlin.test.junit5.JUnit5Asserter.assertEquals(JUnitSupport.kt:32)
at app//kotlin.test.AssertionsKt__AssertionsKt.assertEquals(Assertions.kt:63)
at app//kotlin.test.AssertionsKt.assertEquals(Unknown Source)
at app//kotlin.test.AssertionsKt__AssertionsKt.assertEquals$default(Assertions.kt:62)
at app//kotlin.test.AssertionsKt.assertEquals$default(Unknown Source)
at app//org.noelware.charted.server.testing.plugins.SessionsPluginsTest$test4$1.invokeSuspend(SessionsPluginsTest.kt:131)
at app//kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at app//kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at app//kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
at app//kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
at app//kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
at app//kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at app//kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
at app//kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
at app//io.ktor.server.testing.TestApplicationKt.testApplication(TestApplication.kt:288)
at app//org.noelware.charted.server.testing.TestChartedServer.start(TestChartedServer.kt:116)
at app//org.noelware.charted.server.testing.AbstractChartedServerTest.withChartedServer(AbstractChartedServerTest.kt:116)
at app//org.noelware.charted.server.testing.plugins.SessionsPluginsTest.test4(SessionsPluginsTest.kt:119)
This issue aims to fix the issue that is brought up in most cases in all server tests