Skip to content

Commit

Permalink
fix: Libraries compatibility: openapi generator, kotlinx coroutines a…
Browse files Browse the repository at this point in the history
…nd ktor client
  • Loading branch information
Zoe Maas committed Oct 27, 2024
1 parent 88d43fb commit 7b8df9f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ junit = "4.13.2"
kotlin = "2.0.0"
ktor = "2.3.11"
kotlinxSerialization = "1.7.1"
kotlinxCoroutines = "1.9.0"
kotlinxCoroutines = "1.8.0"
springboot = "3.3.1"
springDependencyManagement = "1.1.5"
kermitLogging = "2.0.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object DefaultCallbacks {

fun <CallbackType: IFetchCallbackMarkerType> fetchService(): CallbackType {
if (fetchCallbackService == null) {
throw IllegalStateException("No default Crypto Platform Callback implementation was registered")
throw IllegalStateException("No default Fetch Platform Callback implementation was registered")
}
return fetchCallbackService as CallbackType
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class DefaultTrustChainJSImpl(
) : ITrustChainCallbackServiceJS, ITrustChainCallbackMarkerType {
override fun resolve(
entityIdentifier: String, trustAnchors: Array<String>, maxDepth: Int
): Promise<Array<String>?> = CoroutineScope(context = CoroutineName("")).async {
): Promise<Array<String>?> = CoroutineScope(context = CoroutineName(TRUST_CHAIN_SERVICE_JS_SCOPE)).async {
val cache = SimpleCache<String, String>()
val chain: MutableList<String> = arrayListOf()
return@async try {
Expand All @@ -109,7 +109,7 @@ class DefaultTrustChainJSImpl(
cache: SimpleCache<String, String>,
depth: Int,
maxDepth: Int
): Promise<Array<String>?> = CoroutineScope(context = CoroutineName("TEST")).async {
): Promise<Array<String>?> = CoroutineScope(context = CoroutineName(TRUST_CHAIN_SERVICE_JS_SCOPE)).async {
if (depth == maxDepth) return@async null

val entityConfigurationJwt = fetchService(fetchService ?: DefaultCallbacks.fetchService()).fetchStatement(
Expand Down Expand Up @@ -171,7 +171,7 @@ class DefaultTrustChainJSImpl(
cache: SimpleCache<String, String>,
depth: Int,
maxDepth: Int
): Promise<Array<String>?> = CoroutineScope(context = CoroutineName("TEST")).async {
): Promise<Array<String>?> = CoroutineScope(context = CoroutineName(TRUST_CHAIN_SERVICE_JS_SCOPE)).async {
try {
val authorityConfigurationEndpoint = getEntityConfigurationEndpoint(authority)

Expand Down Expand Up @@ -260,8 +260,8 @@ class DefaultTrustChainJSImpl(
if (authorityEntityConfiguration.authorityHints?.isNotEmpty() == true) {
chain.add(subordinateStatementJwt)
val result =
buildTrustChainRecursive(authority, trustAnchors, chain, cache, depth, maxDepth)
if (result != null) return@async result.await()
buildTrustChainRecursive(authority, trustAnchors, chain, cache, depth, maxDepth).await()
if (result != null) return@async result
chain.removeLast()
}
} catch (_: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,56 +72,56 @@ actual class TrustChainTest {
val trustChain = client.resolveTrustChainJS(
"https://spid.wbss.it/Spid/oidc/rp/ipasv_lt",
arrayOf("https://oidc.registry.servizicie.interno.gov.it")
)
).await()

assertNotNull(trustChain)

assertEquals(4, trustChain.await()?.size ?: 0)
assertEquals(4, trustChain.size)

assertEquals(
trustChain.await()?.get(0),
trustChain[0],
mockResponses.find { it[0] == "https://spid.wbss.it/Spid/oidc/rp/ipasv_lt/.well-known/openid-federation" }
?.get(1)
)

assertEquals(
trustChain.await()?.get(1),
trustChain[1],
mockResponses.find { it[0] == "https://spid.wbss.it/Spid/oidc/sa/fetch?sub=https://spid.wbss.it/Spid/oidc/rp/ipasv_lt" }
?.get(1)
)

assertEquals(
trustChain.await()?.get(2),
trustChain[2],
mockResponses.find { it[0] == "https://oidc.registry.servizicie.interno.gov.it/fetch?sub=https://spid.wbss.it/Spid/oidc/sa" }
?.get(1)
)

assertEquals(
trustChain.await()?.get(3),
trustChain[3],
mockResponses.find { it[0] == "https://oidc.registry.servizicie.interno.gov.it/.well-known/openid-federation" }
?.get(1)
)

val trustChain2 = client.resolveTrustChainJS(
"https://spid.wbss.it/Spid/oidc/sa",
arrayOf("https://oidc.registry.servizicie.interno.gov.it")
)
).await()

assertNotNull(trustChain2)
assertEquals(3, trustChain2.await()?.size ?: 0)
assertEquals(3, trustChain2.size)
assertEquals(
trustChain2.await()?.get(0),
trustChain2[0],
mockResponses.find { it[0] == "https://spid.wbss.it/Spid/oidc/sa/.well-known/openid-federation" }?.get(1)
)

assertEquals(
trustChain2.await()?.get(1),
trustChain2[1],
mockResponses.find { it[0] == "https://oidc.registry.servizicie.interno.gov.it/fetch?sub=https://spid.wbss.it/Spid/oidc/sa" }
?.get(1)
)

assertEquals(
trustChain2.await()?.get(2),
trustChain2[2],
mockResponses.find { it[0] == "https://oidc.registry.servizicie.interno.gov.it/.well-known/openid-federation" }
?.get(1)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ fun <T> T.toUrlEncodedJsonValue(serializer: KSerializer<T>): String {
* input An URL encoded input string
* @return Decoded String
*/
@ExperimentalJsExport
@JsExport
fun urlDecodeValue(input: String): String {
return buildString {
Expand Down

0 comments on commit 7b8df9f

Please sign in to comment.