Skip to content

Commit

Permalink
refactor: Fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmathew committed Aug 19, 2024
1 parent bb94439 commit ba25e3c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.sphereon.oid.fed.common.httpclient

import com.sphereon.oid.fed.common.jwt.KMSInterface
import com.sphereon.oid.fed.openapi.models.JWTHeader
import io.ktor.client.*
import io.ktor.client.call.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.sphereon.oid.fed.common.jwt

import com.sphereon.oid.fed.common.mapper.JsonMapper
import com.sphereon.oid.fed.openapi.models.JWTHeader
import kotlinx.serialization.json.JsonObject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.sphereon.oid.fed.common.jwt

import com.sphereon.oid.fed.openapi.models.EntityConfigurationStatement
import com.sphereon.oid.fed.openapi.models.JWTHeader
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.sphereon.oid.fed.common.jwt

import com.sphereon.oid.fed.common.jwt.Jose.generateKeyPair
import com.sphereon.oid.fed.openapi.models.EntityStatement
import com.sphereon.oid.fed.openapi.models.JWTHeader
import com.sphereon.oid.fed.openapi.models.JWKS
import com.sphereon.oid.fed.openapi.models.JWTHeader
import kotlinx.coroutines.async
import kotlinx.coroutines.await
import kotlinx.coroutines.test.runTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.sphereon.oid.fed.common.jwt

import com.nimbusds.jose.*
import com.nimbusds.jose.JWSHeader
import com.nimbusds.jose.JWSSigner
import com.nimbusds.jose.JWSVerifier
import com.nimbusds.jose.crypto.RSASSASigner
import com.nimbusds.jose.crypto.RSASSAVerifier
import com.nimbusds.jose.jwk.RSAKey
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.sphereon.oid.fed.common.httpclient

import com.nimbusds.jose.jwk.gen.RSAKeyGenerator
import com.sphereon.oid.fed.openapi.models.*
import com.sphereon.oid.fed.openapi.models.EntityStatement
import com.sphereon.oid.fed.openapi.models.JWTHeader
import io.ktor.client.engine.mock.*
import io.ktor.http.*
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.encodeToJsonElement
Expand Down Expand Up @@ -41,7 +41,10 @@ class OidFederationClientTest {
fun testGetEntityStatement() {
runBlocking {
val client = OidFederationClient(mockEngine)
val response = client.fetchEntityStatement("https://www.example.com?iss=https://edugain.org/federation&sub=https://openid.sunet.se", HttpMethod.Get)
val response = client.fetchEntityStatement(
"https://www.example.com?iss=https://edugain.org/federation&sub=https://openid.sunet.se",
HttpMethod.Get
)
assertEquals(jwt, response)
}
}
Expand All @@ -51,9 +54,11 @@ class OidFederationClientTest {
runBlocking {
val client = OidFederationClient(mockEngine)
val key = RSAKeyGenerator(2048).keyID("key1").generate()
val entityStatement = EntityStatement(iss = "https://edugain.org/federation", sub = "https://openid.sunet.se")
val entityStatement =
EntityStatement(iss = "https://edugain.org/federation", sub = "https://openid.sunet.se")
val payload: JsonObject = Json.encodeToJsonElement(entityStatement) as JsonObject
val response = client.fetchEntityStatement("https://www.example.com", HttpMethod.Post,
val response = client.fetchEntityStatement(
"https://www.example.com", HttpMethod.Post,
OidFederationClient.PostEntityParameters(
payload = payload,
header = JWTHeader(typ = "JWT", alg = "RS256", kid = key.keyID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ class JoseJwtTest {
val entityStatement = EntityStatement(iss = "test")
val payload: JsonObject = Json.encodeToJsonElement(entityStatement) as JsonObject
val signature = sign(
payload,
JWTHeader(alg = "RS256", typ = "JWT", kid = key.keyID),
mutableMapOf("key" to key)
payload, JWTHeader(alg = "RS256", typ = "JWT", kid = key.keyID), mutableMapOf("key" to key)
)
assertTrue { signature.startsWith("ey") }
}
Expand All @@ -32,9 +30,7 @@ class JoseJwtTest {
val entityStatement = EntityStatement(iss = "test")
val payload: JsonObject = Json.encodeToJsonElement(entityStatement) as JsonObject
val signature = sign(
payload,
JWTHeader(alg = "RS256", typ = "JWT", kid = key.keyID),
mutableMapOf("key" to key)
payload, JWTHeader(alg = "RS256", typ = "JWT", kid = key.keyID), mutableMapOf("key" to key)
)
assertTrue { verify(signature, key, emptyMap()) }
}
Expand Down

0 comments on commit ba25e3c

Please sign in to comment.