Skip to content

Commit da2aa2d

Browse files
committed
chore(jvm): adapt tests to new keypackage api
1 parent 0a4c7a6 commit da2aa2d

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

crypto-ffi/bindings/jvm/src/test/kotlin/com/wire/crypto/E2EITest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ internal class E2EITest : HasMockDeliveryService() {
220220

221221
bob.transaction { ctx -> ctx.createConversation(id, CREDENTIAL_TYPE_DEFAULT, CONVERSATION_CONFIGURATION_DEFAULT) }
222222

223-
val aliceKp = alice.transaction { ctx -> ctx.clientKeypackages(CIPHERSUITE_DEFAULT, CREDENTIAL_TYPE_DEFAULT, 1U).first() }
223+
val aliceKp = alice.transaction { ctx -> ctx.clientKeypackagesShort(1u).first() }
224224
bob.transaction { ctx -> ctx.addClientsToConversation(id, listOf(aliceKp)) }
225225
val welcome = HasMockDeliveryService.mockDeliveryService.getLatestWelcome()
226226
val groupId = alice.transaction { ctx -> ctx.processWelcomeMessage(welcome, CUSTOM_CONFIGURATION_DEFAULT).id }

crypto-ffi/bindings/jvm/src/test/kotlin/com/wire/crypto/MLSTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ class MLSTest : HasMockDeliveryService() {
153153
// by default, no key packages are generated
154154
assertThat(
155155
alice.transaction { ctx ->
156-
ctx.clientValidKeypackagesCount(CIPHERSUITE_DEFAULT, CREDENTIAL_TYPE_DEFAULT)
156+
ctx.getKeypackages().size
157157
}
158-
).isEqualTo(0.toULong())
158+
).isEqualTo(0)
159159
assertThat(alice.transaction { ctx -> ctx.clientKeypackagesShort(200U) }).isNotEmpty().hasSize(200)
160160
assertThat(
161161
alice.transaction { ctx ->
162-
ctx.clientValidKeypackagesCount(CIPHERSUITE_DEFAULT, CREDENTIAL_TYPE_DEFAULT)
162+
ctx.getKeypackages().size
163163
}
164-
).isEqualTo(200.toULong())
164+
).isEqualTo(200)
165165
}
166166

167167
@Test

crypto-ffi/bindings/jvm/src/test/kotlin/com/wire/crypto/testutils/TestUtils.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,19 @@ suspend fun CoreCryptoContext.createConversationShort(
105105
id: ConversationId
106106
) = createConversation(id, CREDENTIAL_TYPE_DEFAULT, CONVERSATION_CONFIGURATION_DEFAULT)
107107

108-
/** Shorthand for getting keypackages with defaults */
109-
suspend fun CoreCryptoContext.clientKeypackagesShort(amount: UInt) = clientKeypackages(CIPHERSUITE_DEFAULT, CREDENTIAL_TYPE_DEFAULT, amount)
108+
/** Shorthand for generating keypackages with defaults */
109+
suspend fun CoreCryptoContext.clientKeypackagesShort(amount: UInt): List<Keypackage> {
110+
val credentials = findCredentials(
111+
clientId = null,
112+
publicKey = null,
113+
ciphersuite = CIPHERSUITE_DEFAULT,
114+
credentialType = CREDENTIAL_TYPE_DEFAULT,
115+
earliestValidity = null
116+
)
117+
val credential = credentials.last()
118+
119+
return List(amount.toInt()) { _ ->
120+
// cycle through credentials if amount > credentials.size
121+
generateKeypackage(credential)
122+
}
123+
}

0 commit comments

Comments
 (0)