Skip to content

Commit

Permalink
Upgrade packages (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthick-vinod authored Mar 31, 2024
1 parent 8e71985 commit 3452f0e
Show file tree
Hide file tree
Showing 15 changed files with 155 additions and 181 deletions.
42 changes: 22 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask

buildscript {
ext.kotlin_version = '1.8.10'
ext.ktor_version = '2.2.4'
ext.kotlin_version = '1.9.23'
ext.ktor_version = '2.3.9'
ext.koin_version = '3.4.3'
ext.shadow_version = '8.1.1'
ext.exposed_version = "0.37.3"
ext.jooq_version = '3.16.15'
ext.hikari_cp_version = "5.0.1"
ext.junit_version = '5.9.2'
ext.flyway_version = '9.16.0'
ext.casbin_version = '1.32.2'
ext.postgres_jdbc_driver = '42.5.4'
ext.detekt_version = '1.19.0'
ext.jooq_version = '3.16.23'
ext.hikari_cp_version = "5.1.0"
ext.junit_version = '5.10.0'
ext.flyway_version = '9.22.3'
ext.casbin_version = '1.55.0'
ext.postgres_jdbc_driver = '42.7.3'
ext.detekt_version = '1.23.6'
ext.cohort_version = '1.7.3'

repositories {
Expand All @@ -39,7 +39,7 @@ plugins {
id "io.gitlab.arturbosch.detekt" version "$detekt_version"
id "org.jlleitschuh.gradle.ktlint" version "12.0.3"
id "jacoco"
id "org.openapi.generator" version "5.3.0"
id "org.openapi.generator" version "7.4.0"
id "com.osacky.doctor" version "0.8.0"
}

Expand Down Expand Up @@ -80,9 +80,11 @@ compileTestKotlin {
test {
jvmArgs("--add-opens", "java.base/java.time=ALL-UNNAMED")
useJUnitPlatform()
maxParallelForks = 2
testLogging.showStandardStreams(true)
finalizedBy jacocoTestReport // report is always generated after tests run
}

jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
Expand Down Expand Up @@ -350,8 +352,8 @@ dependencies {
implementation("io.ktor:ktor-server-auth:$ktor_version")


implementation('ch.qos.logback:logback-classic:1.4.7')
implementation('org.codehaus.janino:janino:3.1.8')
implementation('ch.qos.logback:logback-classic:1.5.3')
implementation('org.codehaus.janino:janino:3.1.12')
implementation("com.zaxxer:HikariCP:$hikari_cp_version") // DB connection pooling
implementation("org.flywaydb:flyway-core:$flyway_version") // DB Migrations
implementation("org.postgresql:postgresql:$postgres_jdbc_driver") // DB JDBC driver
Expand All @@ -371,8 +373,8 @@ dependencies {
implementation "io.insert-koin:koin-logger-slf4j:$koin_version"

// Logging
implementation 'io.github.microutils:kotlin-logging:2.1.21'
implementation 'org.slf4j:slf4j-simple:1.7.36'
implementation 'io.github.microutils:kotlin-logging:3.0.5'
implementation 'org.slf4j:slf4j-simple:2.0.12'

// Metrics
implementation "io.ktor:ktor-server-metrics-micrometer:$ktor_version"
Expand Down Expand Up @@ -404,7 +406,7 @@ dependencies {
implementation("com.sksamuel.cohort:cohort-logback:$cohort_version")

// AWS
implementation platform('software.amazon.awssdk:bom:2.18.25')
implementation platform('software.amazon.awssdk:bom:2.25.20')
implementation("software.amazon.awssdk:cognitoidentity")
implementation("software.amazon.awssdk:cognitoidentityprovider")
implementation("software.amazon.awssdk:ses")
Expand All @@ -416,8 +418,8 @@ dependencies {
implementation("net.pwall.mustache:kotlin-mustache:0.10")

// OkHttp Client
implementation("com.squareup.okhttp3:okhttp:4.10.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.10.0")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")

// Test dependencies
testImplementation("io.ktor:ktor-server-test-host:$ktor_version")
Expand All @@ -427,9 +429,9 @@ dependencies {
testImplementation('io.mockk:mockk:1.13.4')
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junit_version")

testImplementation 'org.testcontainers:junit-jupiter:1.17.6'
testImplementation 'org.testcontainers:testcontainers:1.17.6'
testImplementation 'org.testcontainers:postgresql:1.17.6'
testImplementation 'org.testcontainers:junit-jupiter:1.19.7'
testImplementation 'org.testcontainers:testcontainers:1.19.7'
testImplementation 'org.testcontainers:postgresql:1.19.7'
}

// configure jOOQ task such that it only executes when something has changed that potentially affects the generated JOOQ sources
Expand Down
6 changes: 2 additions & 4 deletions detekt_config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
formatting:
ImportOrdering:
layout: '*'

style:
ForbiddenComment:
allowedPatterns: 'TODO:'
MaxLineLength:
maxLineLength: 200
UseCheckOrError:
active: false

complexity:
LongMethod:
Expand Down
4 changes: 0 additions & 4 deletions src/main/kotlin/com/hypto/iam/server/extensions/Mappers.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.hypto.iam.server.extensions

import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.hypto.iam.server.db.tables.pojos.Actions
import com.hypto.iam.server.db.tables.pojos.AuditEntries
import com.hypto.iam.server.db.tables.pojos.Credentials
Expand Down Expand Up @@ -40,8 +38,6 @@ import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

val hrnFactory = getKoinInstance<HrnFactory>()
val scopeListTypeToken = object : TypeToken<List<String>>() {}.type
private val gson: Gson = getKoinInstance()

fun Credential.Companion.from(record: CredentialsRecord): Credential {
return Credential(
Expand Down
11 changes: 1 addition & 10 deletions src/main/kotlin/com/hypto/iam/server/idp/CognitoProviderImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class CognitoIdentityProviderImpl : IdentityProvider, KoinComponent {
try {
return when (userCredentials) {
is PasswordCredentials -> createUserWithPassword(context, identityGroup, userCredentials)
is AccessTokenCredentials -> createUserWithAccessToken(context, identityGroup, userCredentials)
is AccessTokenCredentials -> TODO("Not implemented")
else -> throw UnsupportedCredentialsException("Credential type not supported")
}
} catch (e: UsernameExistsException) {
Expand All @@ -173,15 +173,6 @@ class CognitoIdentityProviderImpl : IdentityProvider, KoinComponent {
}
}

private fun createUserWithAccessToken(
context: RequestContext,
identityGroup: IdentityGroup,
userCredentials: AccessTokenCredentials,
): User {
logger.info("Creating cognito user with access token")
TODO("Not implemented")
}

override suspend fun getUser(
identityGroup: IdentityGroup,
userName: String,
Expand Down
13 changes: 6 additions & 7 deletions src/test/kotlin/com/hypto/iam/server/apis/ActionApiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import io.ktor.http.ContentType
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpStatusCode
import io.ktor.http.contentType
import io.ktor.http.withCharset
import io.ktor.server.config.ApplicationConfig
import io.ktor.server.testing.testApplication
import org.junit.jupiter.api.Assertions.assertEquals
Expand Down Expand Up @@ -53,7 +52,7 @@ class ActionApiTest : AbstractContainerBaseTest() {
val responseBody = gson.fromJson(response.bodyAsText(), Action::class.java)
assertEquals(HttpStatusCode.Created, response.status)
assertEquals(
ContentType.Application.Json.withCharset(Charsets.UTF_8),
ContentType.Application.Json,
response.contentType(),
)
assertEquals(
Expand Down Expand Up @@ -88,7 +87,7 @@ class ActionApiTest : AbstractContainerBaseTest() {
}
assertEquals(HttpStatusCode.OK, response.status)
assertEquals(
ContentType.Application.Json.withCharset(Charsets.UTF_8),
ContentType.Application.Json,
response.contentType(),
)

Expand Down Expand Up @@ -125,7 +124,7 @@ class ActionApiTest : AbstractContainerBaseTest() {
}
assertEquals(HttpStatusCode.Forbidden, response.status)
assertEquals(
ContentType.Application.Json.withCharset(Charsets.UTF_8),
ContentType.Application.Json,
response.contentType(),
)

Expand All @@ -152,7 +151,7 @@ class ActionApiTest : AbstractContainerBaseTest() {
header(HttpHeaders.Authorization, "Bearer $rootUserToken")
}
assertEquals(HttpStatusCode.OK, response.status)
assertEquals(ContentType.Application.Json.withCharset(Charsets.UTF_8), response.contentType())
assertEquals(ContentType.Application.Json, response.contentType())
val responseBody = gson.fromJson(response.bodyAsText(), BaseSuccessResponse::class.java)
assertEquals(true, responseBody.success)

Expand Down Expand Up @@ -189,7 +188,7 @@ class ActionApiTest : AbstractContainerBaseTest() {
}
assertEquals(HttpStatusCode.OK, response.status)
assertEquals(
ContentType.Application.Json.withCharset(Charsets.UTF_8),
ContentType.Application.Json,
response.contentType(),
)

Expand Down Expand Up @@ -224,7 +223,7 @@ class ActionApiTest : AbstractContainerBaseTest() {
}
assertEquals(HttpStatusCode.OK, response.status)
assertEquals(
ContentType.Application.Json.withCharset(Charsets.UTF_8),
ContentType.Application.Json,
response.contentType(),
)

Expand Down
28 changes: 13 additions & 15 deletions src/test/kotlin/com/hypto/iam/server/apis/CredentialApiKtTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import io.ktor.http.ContentType.Application.Json
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpStatusCode
import io.ktor.http.contentType
import io.ktor.http.withCharset
import io.ktor.server.config.ApplicationConfig
import io.ktor.server.testing.testApplication
import io.mockk.coEvery
Expand All @@ -34,7 +33,6 @@ import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
import java.util.UUID
import kotlin.text.Charsets.UTF_8

internal class CredentialApiKtTest : AbstractContainerBaseTest() {
private val gson: Gson by inject()
Expand Down Expand Up @@ -65,7 +63,7 @@ internal class CredentialApiKtTest : AbstractContainerBaseTest() {
setBody(gson.toJson(requestBody))
}
Assertions.assertEquals(HttpStatusCode.Created, response.status)
Assertions.assertEquals(Json.withCharset(UTF_8), response.contentType())
Assertions.assertEquals(Json, response.contentType())
Assertions.assertEquals(
createdOrganization.id,
response.headers[Constants.X_ORGANIZATION_HEADER],
Expand Down Expand Up @@ -105,7 +103,7 @@ internal class CredentialApiKtTest : AbstractContainerBaseTest() {
}
Assertions.assertEquals(HttpStatusCode.Created, response.status)
Assertions.assertEquals(
Json.withCharset(UTF_8),
Json,
response.contentType(),
)

Expand Down Expand Up @@ -147,7 +145,7 @@ internal class CredentialApiKtTest : AbstractContainerBaseTest() {
}
Assertions.assertEquals(HttpStatusCode.BadRequest, response.status)
Assertions.assertEquals(
Json.withCharset(UTF_8),
Json,
response.contentType(),
)
deleteOrganization(createdOrganization.id)
Expand Down Expand Up @@ -187,7 +185,7 @@ internal class CredentialApiKtTest : AbstractContainerBaseTest() {
}
Assertions.assertEquals(HttpStatusCode.NotFound, response.status)
Assertions.assertEquals(
Json.withCharset(UTF_8),
Json,
response.contentType(),
)
deleteOrganization(createdOrganization.id)
Expand Down Expand Up @@ -231,7 +229,7 @@ internal class CredentialApiKtTest : AbstractContainerBaseTest() {
header(HttpHeaders.Authorization, "Bearer $rootUserToken")
}
Assertions.assertEquals(HttpStatusCode.OK, response.status)
Assertions.assertEquals(Json.withCharset(UTF_8), response.contentType())
Assertions.assertEquals(Json, response.contentType())

// Validate that credential has been deleted
response =
Expand Down Expand Up @@ -281,7 +279,7 @@ internal class CredentialApiKtTest : AbstractContainerBaseTest() {
header(HttpHeaders.Authorization, "Bearer $rootUserToken")
}
Assertions.assertEquals(HttpStatusCode.NotFound, response.status)
Assertions.assertEquals(Json.withCharset(UTF_8), response.contentType())
Assertions.assertEquals(Json, response.contentType())

deleteOrganization(createdOrganization.id)
}
Expand Down Expand Up @@ -312,7 +310,7 @@ internal class CredentialApiKtTest : AbstractContainerBaseTest() {
header(HttpHeaders.Authorization, "Bearer $rootUserToken2")
}
Assertions.assertEquals(HttpStatusCode.Forbidden, response.status)
Assertions.assertEquals(Json.withCharset(UTF_8), response.contentType())
Assertions.assertEquals(Json, response.contentType())
deleteOrganization(organization1.id)
deleteOrganization(organizationResponse2.organization.id)
}
Expand Down Expand Up @@ -343,7 +341,7 @@ internal class CredentialApiKtTest : AbstractContainerBaseTest() {
header(HttpHeaders.Authorization, "Bearer ${createdCredentials.secret}")
}
Assertions.assertEquals(HttpStatusCode.OK, response.status)
Assertions.assertEquals(Json.withCharset(UTF_8), response.contentType())
Assertions.assertEquals(Json, response.contentType())

val responseBody = gson.fromJson(response.bodyAsText(), Credential::class.java)
Assertions.assertNull(responseBody.validUntil)
Expand Down Expand Up @@ -374,7 +372,7 @@ internal class CredentialApiKtTest : AbstractContainerBaseTest() {
header(HttpHeaders.Authorization, "Bearer $rootUserToken")
}
Assertions.assertEquals(HttpStatusCode.NotFound, response.status)
Assertions.assertEquals(Json.withCharset(UTF_8), response.contentType())
Assertions.assertEquals(Json, response.contentType())

deleteOrganization(createdOrganization.id)
}
Expand All @@ -399,7 +397,7 @@ internal class CredentialApiKtTest : AbstractContainerBaseTest() {
header(HttpHeaders.Authorization, "Bearer $rootUserToken")
}
Assertions.assertEquals(HttpStatusCode.BadRequest, response.status)
Assertions.assertEquals(Json.withCharset(UTF_8), response.contentType())
Assertions.assertEquals(Json, response.contentType())
deleteOrganization(createdOrganization.id)
}
}
Expand Down Expand Up @@ -432,7 +430,7 @@ internal class CredentialApiKtTest : AbstractContainerBaseTest() {
header(HttpHeaders.Authorization, "Bearer $rootUserToken")
}
Assertions.assertEquals(HttpStatusCode.OK, response.status)
Assertions.assertEquals(Json.withCharset(UTF_8), response.contentType())
Assertions.assertEquals(Json, response.contentType())

val responseBody = gson.fromJson(response.bodyAsText(), ListCredentialResponse::class.java)
Assertions.assertEquals(2, responseBody.credentials.size)
Expand Down Expand Up @@ -463,7 +461,7 @@ internal class CredentialApiKtTest : AbstractContainerBaseTest() {
header(HttpHeaders.Authorization, "Bearer $rootUserToken")
}
Assertions.assertEquals(HttpStatusCode.NotFound, response.status)
Assertions.assertEquals(Json.withCharset(UTF_8), response.contentType())
Assertions.assertEquals(Json, response.contentType())
}
}

Expand All @@ -486,7 +484,7 @@ internal class CredentialApiKtTest : AbstractContainerBaseTest() {
header(HttpHeaders.Authorization, "Bearer $rootUserToken")
}
Assertions.assertEquals(HttpStatusCode.OK, response.status)
Assertions.assertEquals(Json.withCharset(UTF_8), response.contentType())
Assertions.assertEquals(Json, response.contentType())

val responseBody = gson.fromJson(response.bodyAsText(), ListCredentialResponse::class.java)
Assertions.assertEquals(0, responseBody.credentials.size)
Expand Down
3 changes: 1 addition & 2 deletions src/test/kotlin/com/hypto/iam/server/apis/KeyApiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import io.ktor.http.ContentType.Application.Json
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpStatusCode
import io.ktor.http.contentType
import io.ktor.http.withCharset
import io.ktor.server.config.ApplicationConfig
import io.ktor.server.testing.testApplication
import org.junit.jupiter.api.Assertions.assertEquals
Expand Down Expand Up @@ -63,7 +62,7 @@ class KeyApiTest : AbstractContainerBaseTest() {
}
assertEquals(HttpStatusCode.OK, response.status)
assertEquals(
Json.withCharset(Charsets.UTF_8),
Json,
response.contentType(),
)
val publicKeyResponse = gson.fromJson(response.bodyAsText(), KeyResponse::class.java)
Expand Down
Loading

0 comments on commit 3452f0e

Please sign in to comment.