Skip to content

Commit a52b644

Browse files
authored
dependencies: bump deps and fix failing tests (#25)
1 parent 73a1393 commit a52b644

File tree

4 files changed

+56
-20
lines changed

4 files changed

+56
-20
lines changed

build.gradle.kts

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
import java.time.Duration
2-
3-
val assertjVersion = "3.17.2"
4-
val kotlinLoggingVersion = "1.8.3"
2+
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
3+
val assertjVersion = "3.18.1"
4+
val kotlinLoggingVersion = "2.0.4"
55
val logbackVersion = "1.2.3"
6-
val nimbusSdkVersion = "8.19.1"
7-
val mockWebServerVersion = "4.8.1"
8-
val jacksonVersion = "2.11.2"
9-
val nettyVersion = "4.1.56.Final"
10-
val junitJupiterVersion = "5.7.0-RC1"
11-
val kotlinVersion = "1.4.0"
6+
val nimbusSdkVersion = "8.32.1"
7+
val mockWebServerVersion = "4.9.0"
8+
val jacksonVersion = "2.12.1"
9+
val nettyVersion = "4.1.57.Final"
10+
val junitJupiterVersion = "5.7.0"
11+
val kotlinVersion = "1.4.21-2"
1212
val freemarkerVersion = "2.3.30"
13-
val kotestVersion = "4.2.5"
13+
val kotestVersion = "4.3.2"
1414

1515
val mavenRepoBaseUrl = "https://oss.sonatype.org"
1616
val mainClassKt = "no.nav.security.mock.oauth2.StandaloneMockOAuth2ServerKt"
1717

1818
plugins {
1919
application
20-
kotlin("jvm") version "1.4.0"
21-
id("org.jmailen.kotlinter") version "3.0.2"
22-
id("com.google.cloud.tools.jib") version "2.5.0"
23-
id("com.github.johnrengelman.shadow") version "6.0.0"
20+
kotlin("jvm") version "1.4.21"
21+
id("se.patrikerdes.use-latest-versions") version "0.2.15"
22+
id("com.github.ben-manes.versions") version "0.36.0"
23+
id("org.jmailen.kotlinter") version "3.3.0"
24+
id("com.google.cloud.tools.jib") version "2.7.1"
25+
id("com.github.johnrengelman.shadow") version "6.1.0"
2426
id("net.researchgate.release") version "2.8.1"
25-
id("io.codearte.nexus-staging") version "0.21.2"
27+
id("io.codearte.nexus-staging") version "0.22.0"
2628
id("de.marcphilipp.nexus-publish") version "0.4.0"
2729
`java-library`
2830
`maven-publish`
@@ -161,6 +163,38 @@ jib {
161163
skip()
162164
}
163165

166+
fun isNonStable(version: String): Boolean {
167+
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
168+
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
169+
val isStable = stableKeyword || regex.matches(version)
170+
return isStable.not()
171+
}
172+
173+
tasks.named("dependencyUpdates", DependencyUpdatesTask::class.java).configure {
174+
this.
175+
resolutionStrategy {
176+
componentSelection {
177+
all {
178+
if (isNonStable(candidate.version) ) {
179+
reject("Release candidate")
180+
}
181+
}
182+
}
183+
}
184+
}
185+
186+
tasks.named("useLatestVersions", se.patrikerdes.UseLatestVersionsTask::class.java).configure {
187+
updateBlacklist = listOf(
188+
"io.codearte:nexus-staging"
189+
)
190+
}
191+
192+
buildscript {
193+
dependencies {
194+
configurations.classpath.get().exclude("xerces", "xercesImpl")
195+
}
196+
}
197+
164198
tasks {
165199
withType<org.jmailen.gradle.kotlinter.tasks.LintTask> {
166200
dependsOn("formatKotlin")
@@ -207,6 +241,6 @@ tasks {
207241
}
208242

209243
withType<Wrapper> {
210-
gradleVersion = "6.6.1"
244+
gradleVersion = "6.8"
211245
}
212246
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/kotlin/no/nav/security/mock/oauth2/http/OAuth2HttpRequestHandler.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import no.nav.security.mock.oauth2.login.Login
4141
import no.nav.security.mock.oauth2.login.LoginRequestHandler
4242
import no.nav.security.mock.oauth2.token.DefaultOAuth2TokenCallback
4343
import no.nav.security.mock.oauth2.token.OAuth2TokenCallback
44+
import java.net.URLEncoder
45+
import java.nio.charset.Charset
4446

4547
private val log = KotlinLogging.logger {}
4648

@@ -127,12 +129,13 @@ class OAuth2HttpRequestHandler(
127129

128130
private fun handleException(error: Throwable): OAuth2HttpResponse {
129131
log.error("received exception when handling request.", error)
132+
val msg = URLEncoder.encode(error.message, Charset.forName("UTF-8"))
130133
val errorObject: ErrorObject = when (error) {
131134
is OAuth2Exception -> error.errorObject
132-
is ParseException -> error.errorObject ?: OAuth2Error.INVALID_REQUEST.setDescription("failed to parse request: ${error.message}")
135+
is ParseException -> error.errorObject ?: OAuth2Error.INVALID_REQUEST.setDescription("failed to parse request: $msg")
133136
is GeneralException -> error.errorObject
134137
else -> null
135-
} ?: OAuth2Error.SERVER_ERROR.setDescription("unexpected exception with message: ${error.message}")
138+
} ?: OAuth2Error.SERVER_ERROR.setDescription("unexpected exception with message: $msg")
136139
return oauth2Error(errorObject)
137140
}
138141
}

src/test/kotlin/no/nav/security/mock/oauth2/e2e/RefreshTokenGrantIntegrationTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ class RefreshTokenGrantIntegrationTest {
7171
refreshTokenResponse.idToken.subject shouldBe initialSubject
7272
refreshTokenResponse.idToken.audience shouldBe tokenResponseBeforeRefresh.idToken.audience
7373
refreshTokenResponse.accessToken.subject shouldBe initialSubject
74-
refreshTokenResponse.accessToken.audience shouldBe tokenResponseBeforeRefresh.accessToken.audience
7574
}
7675
}
7776

0 commit comments

Comments
 (0)