Make SignedKeyList.data and signature nullable.

There are some cases where the backend will return null strings
for SignedKeyList.signature, we adapt the model to be able to handle
these cases.
This commit is contained in:
marin thiercelin 2021-11-08 12:11:08 +01:00
parent d9e2002051
commit 17316b31b6
No known key found for this signature in database
GPG Key ID: 117C025B1F21B2C6
6 changed files with 21 additions and 10 deletions

View File

@ -1,3 +1,14 @@
## Key [1.16.1]
08 Nov, 2021
### Changes
Handle the case where the signed key list has a null signature.
Modifies:
- `SignedKeyListEntity` (embedded in `PublicAddressEntity` and `AddressEntity`)
- `PublicSignedKeyList`
- `SignedKeyListResponse`
## Test Android Instrumented [1.15.3]
05 Nov, 2021

View File

@ -23,7 +23,7 @@ plugins {
kotlin("android")
}
libVersion = Version(1, 16, 0)
libVersion = Version(1, 16, 1)
android()

View File

@ -24,7 +24,7 @@ import kotlinx.serialization.Serializable
@Serializable
data class SignedKeyListResponse(
@SerialName("Data")
val data: String,
val data: String?,
@SerialName("Signature")
val signature: String
val signature: String?
)

View File

@ -22,6 +22,6 @@ import androidx.room.Entity
@Entity
data class SignedKeyListEntity(
val data: String,
val signature: String
val data: String?,
val signature: String?
)

View File

@ -40,7 +40,7 @@ class PrivateKeyRepositoryImpl(
) : PrivateKeyRepository {
private fun PrivateAddressKey.creationRequest(): CreateAddressKeyRequest {
val signedKeyList = checkNotNull(signedKeyList) { "Signed key list for key creation is null"}
val signedKeyList = checkNotNull(signedKeyList) { "Signed key list for key creation is null" }
return CreateAddressKeyRequest(
addressId = addressId,
privateKey = privateKey.key,
@ -48,8 +48,8 @@ class PrivateKeyRepositoryImpl(
token = token,
signature = signature,
signedKeyList = SignedKeyListRequest(
signedKeyList.data,
signedKeyList.signature
checkNotNull(signedKeyList.data) { "Signed key list's data of new key can't be null" },
checkNotNull(signedKeyList.signature) { "Signed key list's signature of new key can't be null" },
)
)
}

View File

@ -21,6 +21,6 @@ package me.proton.core.key.domain.entity.key
import me.proton.core.crypto.common.pgp.Signature
data class PublicSignedKeyList(
val data: String,
val signature: Signature
val data: String?,
val signature: Signature?
)