mirror of
https://github.com/bitwarden/android.git
synced 2026-10-22 02:53:19 -05:00
[PM-44810] fix: [Defect] Android - When Send Control Policy includes "Vault Items,"… [bug-factory poc]
Automated fix from the AI-49 bug factory. Proof: ./gradlew :app:testStandardDebugUnitTest --tests "com.x8bit.bitwarden.data.auth.repository.util.SyncResponseJsonExtensionsTest" must fail on base and pass with the fix.
This commit is contained in:
1 parent
43d7b8b2de
commit
5dc3788996
2 files changed
+34
-1
No files matched your search
+4
-1
@@ -1,5 +1,6 @@
|
||||
package com.x8bit.bitwarden.data.auth.repository.model
|
||||
|
||||
import com.bitwarden.core.data.serializer.SafeListSerializer
|
||||
import com.bitwarden.network.model.SendAccessTypeJson
|
||||
import com.bitwarden.network.model.SendTypeJson
|
||||
import com.bitwarden.network.model.SyncResponseJson
|
||||
@@ -128,7 +129,8 @@ sealed class PolicyInformation {
|
||||
* when [whoCanAccess] is [SendAccessTypeJson.SPECIFIC_PEOPLE].
|
||||
* @property deletionHours The number of hours until a Send is deleted, if enforced.
|
||||
* @property allowedSendTypes The types of Sends that are allowed to be created, if
|
||||
* restricted.
|
||||
* restricted. Send types unknown to this client are dropped rather than failing the decode of
|
||||
* the whole policy.
|
||||
*/
|
||||
@Serializable
|
||||
data class SendControls(
|
||||
@@ -147,6 +149,7 @@ sealed class PolicyInformation {
|
||||
@SerialName("deletionHours")
|
||||
val deletionHours: Int?,
|
||||
|
||||
@Serializable(with = SafeListSerializer::class)
|
||||
@SerialName("allowedSendTypes")
|
||||
val allowedSendTypes: List<SendTypeJson>?,
|
||||
) : PolicyInformation()
|
||||
|
||||
+30
@@ -195,6 +195,36 @@ class SyncResponseJsonExtensionsTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Suppress("MaxLineLength")
|
||||
fun `policyInformation drops unknown allowedSendTypes and keeps the rest of the SendControls policy`() {
|
||||
val policy = createMockSdkPolicy(
|
||||
type = PolicyType.SEND_CONTROLS,
|
||||
data = """
|
||||
{
|
||||
"disableSend": false,
|
||||
"disableHideEmail": true,
|
||||
"whoCanAccess": 2,
|
||||
"allowedDomains": "bitwarden.com",
|
||||
"deletionHours": 168,
|
||||
"allowedSendTypes": [0, 2]
|
||||
}
|
||||
""".trimIndent(),
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
PolicyInformation.SendControls(
|
||||
disableSend = false,
|
||||
disableHideEmail = true,
|
||||
whoCanAccess = SendAccessTypeJson.SPECIFIC_PEOPLE,
|
||||
allowedDomains = "bitwarden.com",
|
||||
deletionHours = 168,
|
||||
allowedSendTypes = listOf(SendTypeJson.TEXT),
|
||||
),
|
||||
policy.policyInformation,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Suppress("MaxLineLength")
|
||||
fun `policyInformation converts the OrganizationUserNotification Json data to policy information`() {
|
||||
|
||||
Reference in new issue
Block a user