Skip to content

Commit fcfdec4

Browse files
sraptis-scyvkanellopoulos
authored andcommitted
Fix Client Authentication Type related unit tests
1 parent 4a669f2 commit fcfdec4

4 files changed

Lines changed: 34 additions & 12 deletions

File tree

wallet-core/src/test/java/eu/europa/ec/eudi/wallet/EudiWalletConfigTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package eu.europa.ec.eudi.wallet
1818

19+
import eu.europa.ec.eudi.wallet.issue.openid4vci.OpenId4VciManager
1920
import eu.europa.ec.eudi.wallet.logging.Logger
2021
import eu.europa.ec.eudi.wallet.transfer.openId4vp.ClientIdScheme
2122
import eu.europa.ec.eudi.wallet.transfer.openId4vp.EncryptionAlgorithm
@@ -42,7 +43,7 @@ class EudiWalletConfigTest {
4243
configureDocumentManager("storage/path")
4344
configureOpenId4Vci {
4445
withIssuerUrl("https://example.com")
45-
withClientId("client-id")
46+
withClientAuthenticationType(OpenId4VciManager.ClientAuthenticationType.AttestationBased)
4647
withAuthFlowRedirectionURI("eudi-openid4ci://authorize")
4748
}
4849
configureOpenId4Vp {
@@ -103,7 +104,7 @@ class EudiWalletConfigTest {
103104
config.openId4VpConfig?.encryptionMethods?.get(0)
104105
)
105106
assertEquals("https://example.com", config.openId4VciConfig?.issuerUrl)
106-
assertEquals("client-id", config.openId4VciConfig?.clientId)
107+
assertEquals(OpenId4VciManager.ClientAuthenticationType.AttestationBased, config.openId4VciConfig?.clientAuthenticationType)
107108
assertEquals("eudi-openid4ci://authorize", config.openId4VciConfig?.authFlowRedirectionURI)
108109

109110
assertEquals(true, config.dcapiConfig?.enabled)

wallet-core/src/test/java/eu/europa/ec/eudi/wallet/issue/openid4vci/OpenId4VciManagerBuilderTest.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class OpenId4VciManagerBuilderTest {
3131
private val walletKeyManager = mockk<WalletKeyManager>(relaxed = true)
3232
private val config = OpenId4VciManager.Config(
3333
issuerUrl = "https://issuer.example.com",
34-
clientId = "testClientId",
34+
clientAuthenticationType = OpenId4VciManager.ClientAuthenticationType.None("testClientId"),
3535
authFlowRedirectionURI = "app://redirect",
3636
dPoPUsage = OpenId4VciManager.Config.DPoPUsage.IfSupported(),
3737
parUsage = OpenId4VciManager.Config.ParUsage.IF_SUPPORTED,
@@ -68,4 +68,25 @@ class OpenId4VciManagerBuilderTest {
6868
builder.build()
6969
}
7070
}
71+
72+
@Test
73+
fun `Builder throws exception when walletAttestationsProvider is not set for AttestationBased authentication`() {
74+
val configWithAttestationBased = OpenId4VciManager.Config(
75+
issuerUrl = "https://issuer.example.com",
76+
clientAuthenticationType = OpenId4VciManager.ClientAuthenticationType.AttestationBased,
77+
authFlowRedirectionURI = "app://redirect",
78+
dPoPUsage = OpenId4VciManager.Config.DPoPUsage.IfSupported(),
79+
parUsage = OpenId4VciManager.Config.ParUsage.IF_SUPPORTED,
80+
)
81+
82+
val builder = OpenId4VciManager.Builder(context)
83+
.config(configWithAttestationBased)
84+
.documentManager(documentManager)
85+
.walletKeyManager(walletKeyManager)
86+
// Intentionally not setting walletAttestationsProvider
87+
88+
assertThrows(IllegalStateException::class.java) {
89+
builder.build()
90+
}
91+
}
7192
}

wallet-core/src/test/java/eu/europa/ec/eudi/wallet/issue/openid4vci/OpenId4VciManagerConfigBuilderParUsageTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class OpenId4VciManagerConfigBuilderParUsageTest(
3030
fun `ConfigBuilder set the parUsage property correctly`() {
3131
val builder = OpenId4VciManager.Config.Builder()
3232
.withIssuerUrl("https://issuer.example.com")
33-
.withClientId("testClientId")
33+
.withClientAuthenticationType(OpenId4VciManager.ClientAuthenticationType.None("testClientId"))
3434
.withAuthFlowRedirectionURI("app://redirect")
3535
.withParUsage(parUsage)
3636

wallet-core/src/test/java/eu/europa/ec/eudi/wallet/issue/openid4vci/OpenId4VciManagerConfigBuilderTest.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ import kotlin.test.assertIs
2828
class OpenId4VciManagerConfigBuilderTest {
2929

3030
@Test
31-
fun `ConfigBuilder builds Config with valid issuerUrl, clientId and authFlowRedirectionURI`() {
31+
fun `ConfigBuilder builds Config with valid issuerUrl, clientAuthenticationType and authFlowRedirectionURI`() {
3232
val builder = OpenId4VciManager.Config.Builder()
3333
.withIssuerUrl("https://issuer.example.com")
34-
.withClientId("testClientId")
34+
.withClientAuthenticationType(OpenId4VciManager.ClientAuthenticationType.AttestationBased)
3535
.withAuthFlowRedirectionURI("app://redirect")
3636

3737
val config = builder.build()
@@ -42,7 +42,7 @@ class OpenId4VciManagerConfigBuilderTest {
4242
@Test
4343
fun `ConfigBuilder throws exception when issuerUrl is not set`() {
4444
val builder = OpenId4VciManager.Config.Builder()
45-
.withClientId("testClientId")
45+
.withClientAuthenticationType(OpenId4VciManager.ClientAuthenticationType.AttestationBased)
4646
.withAuthFlowRedirectionURI("app://redirect")
4747

4848
assertThrows(IllegalStateException::class.java) {
@@ -51,7 +51,7 @@ class OpenId4VciManagerConfigBuilderTest {
5151
}
5252

5353
@Test
54-
fun `ConfigBuilder throws exception when clientId is not set`() {
54+
fun `ConfigBuilder throws exception when clientAuthenticationType is not set`() {
5555
val builder = OpenId4VciManager.Config.Builder()
5656
.withIssuerUrl("https://issuer.example.com")
5757
.withAuthFlowRedirectionURI("app://redirect")
@@ -65,7 +65,7 @@ class OpenId4VciManagerConfigBuilderTest {
6565
fun `ConfigBuilder throws exception when authFlowRedirectionURI is not set`() {
6666
val builder = OpenId4VciManager.Config.Builder()
6767
.withIssuerUrl("https://issuer.example.com")
68-
.withClientId("testClientId")
68+
.withClientAuthenticationType(OpenId4VciManager.ClientAuthenticationType.AttestationBased)
6969

7070
assertThrows(IllegalStateException::class.java) {
7171
builder.build()
@@ -76,13 +76,13 @@ class OpenId4VciManagerConfigBuilderTest {
7676
fun `ConfigBuilder sets issuerUrl correctly`() {
7777
val builder = OpenId4VciManager.Config.Builder()
7878
.withIssuerUrl("https://issuer.example.com")
79-
.withClientId("testClientId")
79+
.withClientAuthenticationType(OpenId4VciManager.ClientAuthenticationType.AttestationBased)
8080
.withAuthFlowRedirectionURI("app://redirect")
8181

8282
val config = builder.build()
8383

8484
assertEquals("https://issuer.example.com", config.issuerUrl)
85-
assertEquals("testClientId", config.clientId)
85+
assertEquals(OpenId4VciManager.ClientAuthenticationType.AttestationBased, config.clientAuthenticationType)
8686
assertEquals("app://redirect", config.authFlowRedirectionURI)
8787
assertIs<OpenId4VciManager.Config.DPoPUsage.IfSupported>(config.dPoPUsage)
8888
assertEquals(Algorithm.ESP256, config.dPoPUsage.algorithm)
@@ -92,7 +92,7 @@ class OpenId4VciManagerConfigBuilderTest {
9292
fun `ConfigBuilder sets useDPoPIfSupported correctly`() {
9393
val builder = OpenId4VciManager.Config.Builder()
9494
.withIssuerUrl("https://issuer.example.com")
95-
.withClientId("testClientId")
95+
.withClientAuthenticationType(OpenId4VciManager.ClientAuthenticationType.AttestationBased)
9696
.withAuthFlowRedirectionURI("app://redirect")
9797
.withDPoPUsage(OpenId4VciManager.Config.DPoPUsage.IfSupported())
9898

0 commit comments

Comments
 (0)