[PM-25826] Update folderRelationships type for cipher import (#5885)

This commit is contained in:
Patrick Honkonen 2025-09-17 17:49:16 -04:00 committed by GitHub
parent ff03f49f43
commit 0f899df83c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 7 deletions

View File

@ -41,7 +41,7 @@ class CredentialExchangeImportManagerImpl(
)
},
folders = emptyList(),
folderRelationships = emptyMap(),
folderRelationships = emptyList(),
),
)
}

View File

@ -8,9 +8,8 @@ import kotlinx.serialization.Serializable
*
* @property folders A list of folders to import.
* @property ciphers A list of ciphers to import.
* @property folderRelationships A map of cipher folder relationships to import. Key correlates to
* the index of the cipher in the ciphers list. Value correlates to the index of the folder in the
* folders list.
* @property folderRelationships A list of cipher-folder relationships to import. Each entry maps a
* cipher index (Key) to a folder index (Value).
*/
@Serializable
data class ImportCiphersJsonRequest(
@ -19,7 +18,7 @@ data class ImportCiphersJsonRequest(
@SerialName("ciphers")
val ciphers: List<CipherJsonRequest>,
@SerialName("folderRelationships")
val folderRelationships: Map<Int, Int>,
val folderRelationships: List<Int32Int32KeyValuePairJson>,
) {
/**
* Represents a folder request with an optional [id] if the folder already exists.
@ -34,4 +33,18 @@ data class ImportCiphersJsonRequest(
@SerialName("id")
val id: String?,
)
/**
* A key-value pair of 32-bit integers, used for mapping relationships.
*
* @property key The key, typically an index.
* @property value The value, typically an index.
*/
@Serializable
data class Int32Int32KeyValuePairJson(
@SerialName("key")
val key: Int,
@SerialName("value")
val value: Int,
)
}

View File

@ -350,7 +350,7 @@ class CiphersServiceTest : BaseServiceTest() {
request = ImportCiphersJsonRequest(
ciphers = listOf(createMockCipherJsonRequest(number = 1)),
folders = emptyList(),
folderRelationships = emptyMap(),
folderRelationships = emptyList(),
),
)
assertEquals(ImportCiphersResponseJson.Success, result.getOrThrow())
@ -363,7 +363,7 @@ class CiphersServiceTest : BaseServiceTest() {
request = ImportCiphersJsonRequest(
ciphers = listOf(createMockCipherJsonRequest(number = 1)),
folders = emptyList(),
folderRelationships = emptyMap(),
folderRelationships = emptyList(),
),
)
assertTrue(result.isFailure)