Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ fun Cipher.toEncryptedNetworkCipherResponse(
shouldViewPassword = viewPassword,
key = key,
encryptedFor = encryptedFor,
archivedDate = archivedDate?.let { ZonedDateTime.ofInstant(it, ZoneOffset.UTC) },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is intended to be UTC?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@david-livefront I matched what we already have for deletedDate . Is there a way to confirm this? Should I ask the sdk team?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it does not matter, I'm just not a fan of using ZonedDateTimes 😄. I prefer Instants

)

/**
Expand Down Expand Up @@ -389,6 +390,7 @@ fun SyncResponseJson.Cipher.toEncryptedSdkCipher(): Cipher =
creationDate = creationDate.toInstant(),
deletedDate = deletedDate?.toInstant(),
revisionDate = revisionDate.toInstant(),
archivedDate = archivedDate?.toInstant(),
)

/**
Expand Down Expand Up @@ -704,4 +706,5 @@ fun Cipher.toFailureCipherListView(): CipherListView =
deletedDate = deletedDate,
revisionDate = revisionDate,
copyableFields = emptyList(),
archivedDate = archivedDate,
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fun VaultAddEditState.ViewState.Content.toCipherView(): CipherView =
creationDate = common.originalCipher?.creationDate ?: Instant.now(),
deletedDate = common.originalCipher?.deletedDate,
revisionDate = common.originalCipher?.revisionDate ?: Instant.now(),
archivedDate = common.originalCipher?.archivedDate,

// Type specific section
type = type.toCipherType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ private const val CIPHER_JSON = """
"folderId": "mockFolderId-1",
"organizationId": "mockOrganizationId-1",
"deletedDate": "2023-10-27T12:00:00.000Z",
"archivedDate": "2023-10-27T12:00:00.000Z",
"identity": {
"passportNumber": "mockPassportNumber-1",
"lastName": "mockLastName-1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fun createMockCipherListView(
.takeIf { type is CipherListViewType.Login }
.orEmpty(),
isDeleted: Boolean = false,
isArchived: Boolean = false,
): CipherListView = CipherListView(
id = id,
organizationId = organizationId,
Expand All @@ -66,6 +67,7 @@ fun createMockCipherListView(
revisionDate = revisionDate,
creationDate = creationDate,
deletedDate = if (isDeleted) Instant.parse(DEFAULT_TIMESTAMP) else null,
archivedDate = if (isArchived) Instant.parse(DEFAULT_TIMESTAMP) else null,
attachments = attachments,
organizationUseTotp = organizationUseTotp,
edit = edit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fun createMockCipherView(
),
card: CardView? = createMockCardView(number = number).takeIf { cipherType == CipherType.CARD },
attachments: List<AttachmentView> = listOf(createMockAttachmentView(number = number)),
isArchived: Boolean = false,
): CipherView =
CipherView(
id = "mockId-$number",
Expand All @@ -73,12 +74,17 @@ fun createMockCipherView(
type = cipherType,
login = login.takeIf { cipherType == CipherType.LOGIN },
creationDate = clock.instant(),
revisionDate = clock.instant(),
deletedDate = if (isDeleted) {
clock.instant()
} else {
null
},
revisionDate = clock.instant(),
archivedDate = if (isArchived) {
clock.instant()
} else {
null
},
attachments = attachments,
card = card,
fields = listOf(createMockFieldView(number = number)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fun createMockSdkCipher(number: Int, clock: Clock = FIXED_CLOCK): Cipher =
creationDate = clock.instant(),
deletedDate = clock.instant(),
revisionDate = clock.instant(),
archivedDate = clock.instant(),
attachments = listOf(createMockSdkAttachment(number = number)),
card = createMockSdkCard(number = number),
fields = listOf(createMockSdkField(number = number)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ private val DEFAULT_BASE_CIPHER_VIEW: CipherView = CipherView(
creationDate = FIXED_CLOCK.instant(),
deletedDate = null,
revisionDate = FIXED_CLOCK.instant(),
archivedDate = null,
sshKey = null,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ fun createCipherView(type: CipherType, isEmpty: Boolean): CipherView =
creationDate = Instant.ofEpochSecond(1_000L),
deletedDate = null,
revisionDate = Instant.ofEpochSecond(1_000L),
archivedDate = null,
sshKey = createSshKeyView(isEmpty),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class VaultAddItemStateExtensionsTest {
creationDate = Instant.MIN,
deletedDate = null,
revisionDate = Instant.MIN,
archivedDate = null,
sshKey = null,
),
result,
Expand Down Expand Up @@ -299,6 +300,7 @@ class VaultAddItemStateExtensionsTest {
creationDate = Instant.MIN,
deletedDate = null,
revisionDate = Instant.MIN,
archivedDate = null,
sshKey = null,
),
result,
Expand Down Expand Up @@ -432,6 +434,7 @@ class VaultAddItemStateExtensionsTest {
creationDate = Instant.MIN,
deletedDate = null,
revisionDate = Instant.MIN,
archivedDate = null,
sshKey = null,
),
result,
Expand Down Expand Up @@ -619,6 +622,7 @@ class VaultAddItemStateExtensionsTest {
creationDate = Instant.MIN,
deletedDate = null,
revisionDate = Instant.MIN,
archivedDate = null,
sshKey = null,
),
result,
Expand Down Expand Up @@ -762,6 +766,7 @@ class VaultAddItemStateExtensionsTest {
creationDate = Instant.MIN,
deletedDate = null,
revisionDate = Instant.MIN,
archivedDate = null,
sshKey = SshKeyView(
publicKey = "mockPublicKey-1",
privateKey = "mockPrivateKey-1",
Expand Down Expand Up @@ -981,6 +986,7 @@ private val DEFAULT_BASE_CIPHER_VIEW: CipherView = CipherView(
creationDate = Instant.MIN,
deletedDate = null,
revisionDate = Instant.MIN,
archivedDate = null,
sshKey = null,
)

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ androidxRoom = "2.8.0"
androidxSecurityCrypto = "1.1.0"
androidxSplash = "1.1.0-rc01"
androidxWork = "2.10.4"
bitwardenSdk = "1.0.0-3005-5a722fd2"
bitwardenSdk = "1.0.0-3101-0eba924a"
crashlytics = "3.0.6"
detekt = "1.23.8"
firebaseBom = "34.2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ data class SyncResponseJson(
* @property card The card of the cipher.
* @property key The key of the cipher (nullable).
* @property encryptedFor ID of the user who the cipher is encrypted by.
* @property archivedDate The archived date of the cipher (nullable).
*/
@Serializable
data class Cipher(
Expand Down Expand Up @@ -532,6 +533,10 @@ data class SyncResponseJson(

@SerialName("encryptedFor")
val encryptedFor: String?,

@SerialName("archivedDate")
@Contextual
val archivedDate: ZonedDateTime?,
) {
/**
* Represents an attachment in the vault response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ private const val CREATE_ATTACHMENT_SUCCESS_JSON = """
"privateKey": "mockPrivateKey-1",
"keyFingerprint": "mockKeyFingerprint-1"
},
"encryptedFor": "mockEncryptedFor-1"
"encryptedFor": "mockEncryptedFor-1",
"archivedDate": "2023-10-27T12:00:00.00Z"
}
}
"""
Expand Down Expand Up @@ -631,7 +632,8 @@ private const val CREATE_RESTORE_UPDATE_CIPHER_SUCCESS_JSON = """
"privateKey": "mockPrivateKey-1",
"keyFingerprint": "mockKeyFingerprint-1"
},
"encryptedFor": "mockEncryptedFor-1"
"encryptedFor": "mockEncryptedFor-1",
"archivedDate": "2023-10-27T12:00:00.00Z"
}
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ private const val SYNC_SUCCESS_JSON = """
"privateKey": "mockPrivateKey-1",
"keyFingerprint": "mockKeyFingerprint-1"
},
"encryptedFor": "mockEncryptedFor-1"
"encryptedFor": "mockEncryptedFor-1",
"archivedDate": "2023-10-27T12:00:00.00Z"
}
],
"domains": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fun createMockCipher(
creationDate: ZonedDateTime = MOCK_ZONED_DATE_TIME,
revisionDate: ZonedDateTime = MOCK_ZONED_DATE_TIME,
deletedDate: ZonedDateTime? = MOCK_ZONED_DATE_TIME,
archivedDate: ZonedDateTime? = MOCK_ZONED_DATE_TIME,
attachments: List<SyncResponseJson.Cipher.Attachment>? = listOf(
createMockAttachment(number = number),
),
Expand Down Expand Up @@ -61,6 +62,7 @@ fun createMockCipher(
creationDate = creationDate,
revisionDate = revisionDate,
deletedDate = deletedDate,
archivedDate = archivedDate,
attachments = attachments,
fields = fields,
isFavorite = isFavorite,
Expand Down