File tree 1 file changed +24
-0
lines changed
src/main/kotlin/no/nav/security/mock/oauth2
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import no.nav.security.mock.oauth2.token.OAuth2TokenCallback
29
29
import okhttp3.HttpUrl
30
30
import okhttp3.mockwebserver.MockResponse
31
31
import okhttp3.mockwebserver.RecordedRequest
32
+ import okio.Buffer
32
33
import java.io.IOException
33
34
import java.net.InetAddress
34
35
import java.net.URI
@@ -139,6 +140,29 @@ open class MockOAuth2Server(
139
140
)
140
141
)
141
142
}
143
+
144
+ companion object {
145
+ /* *
146
+ * This attempts to reference a method that does not exist in com.squareup.okio:okio < 2.4.0,
147
+ * and incidentally also com.squareup.okhttp3:mockwebserver < 4.3.0.
148
+ *
149
+ * The method is required by mock-oauth2-server, see [no.nav.security.mock.oauth2.extensions.RecordedRequest.asOAuth2HttpRequest()].
150
+ *
151
+ * If the block throws a RuntimeException, an incompatible version of the okio library was included in the classpath.
152
+ *
153
+ * This is true for e.g. Spring Boot projects, which as of version 2.6.1 still uses mockwebserver 3.14.9 as the
154
+ * [default managed dependency version](https://docs.spring.io/spring-boot/docs/2.6.1/reference/html/dependency-versions.html).
155
+ *
156
+ * We recommend that users of this library use a matching version of mockwebserver.
157
+ */
158
+ init {
159
+ try {
160
+ Buffer ().copy()
161
+ } catch (e: NoSuchMethodError ) {
162
+ throw RuntimeException (" Unsupported version of com.squareup.okhttp3:mockwebserver in classpath. Version should be >= 4.9.2" , e)
163
+ }
164
+ }
165
+ }
142
166
}
143
167
144
168
internal fun Map <String , Any >.toJwtClaimsSet (): JWTClaimsSet =
You can’t perform that action at this time.
0 commit comments