mirror of
https://github.com/bitwarden/android.git
synced 2026-03-21 13:52:07 -05:00
PM-18677: Policies for disabled organizations apply (#4801)
This commit is contained in:
@@ -70,7 +70,6 @@ class PolicyManagerImpl(
|
||||
.getOrganizations(userId)
|
||||
?.filter {
|
||||
it.shouldUsePolicies &&
|
||||
it.isEnabled &&
|
||||
it.status >= OrganizationStatusType.ACCEPTED &&
|
||||
!isOrganizationExemptFromPolicies(it, type)
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ fun SendEmpty(
|
||||
modifier = modifier.verticalScroll(rememberScrollState()),
|
||||
) {
|
||||
if (policyDisablesSend) {
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
BitwardenInfoCalloutCard(
|
||||
text = stringResource(id = R.string.send_disabled_warning),
|
||||
modifier = Modifier
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.x8bit.bitwarden.data.platform.manager
|
||||
import app.cash.turbine.test
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.AuthDiskSource
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.UserStateJson
|
||||
import com.x8bit.bitwarden.data.vault.datasource.network.model.OrganizationType
|
||||
import com.x8bit.bitwarden.data.vault.datasource.network.model.PolicyTypeJson
|
||||
import com.x8bit.bitwarden.data.vault.datasource.network.model.SyncResponseJson
|
||||
import com.x8bit.bitwarden.data.vault.datasource.network.model.createMockOrganization
|
||||
@@ -140,6 +141,31 @@ class PolicyManagerTest {
|
||||
assertTrue(policyManager.getActivePolicies(type = PolicyTypeJson.MASTER_PASSWORD).isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getActivePolicies returns active and applied policies for disabled organizations`() {
|
||||
val userState: UserStateJson = mockk {
|
||||
every { activeUserId } returns USER_ID
|
||||
}
|
||||
val policy = createMockPolicy(organizationId = "mockId-3", isEnabled = true)
|
||||
every { authDiskSource.userState } returns userState
|
||||
every {
|
||||
authDiskSource.getOrganizations(USER_ID)
|
||||
} returns listOf(
|
||||
createMockOrganization(
|
||||
number = 3,
|
||||
isEnabled = false,
|
||||
shouldUsePolicies = true,
|
||||
type = OrganizationType.USER,
|
||||
),
|
||||
)
|
||||
every { authDiskSource.getPolicies(USER_ID) } returns listOf(policy)
|
||||
|
||||
assertEquals(
|
||||
listOf(policy),
|
||||
policyManager.getActivePolicies(type = PolicyTypeJson.MASTER_PASSWORD),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getActivePolicies returns active and applied PasswordGenerator policies`() {
|
||||
val userState: UserStateJson = mockk {
|
||||
|
||||
@@ -36,12 +36,13 @@ fun createMockOrganization(
|
||||
isEnabled: Boolean = false,
|
||||
shouldUsePolicies: Boolean = false,
|
||||
shouldManageResetPassword: Boolean = false,
|
||||
type: OrganizationType = OrganizationType.ADMIN,
|
||||
): SyncResponseJson.Profile.Organization =
|
||||
SyncResponseJson.Profile.Organization(
|
||||
shouldUsePolicies = shouldUsePolicies,
|
||||
shouldUseKeyConnector = false,
|
||||
keyConnectorUrl = "mockKeyConnectorUrl-$number",
|
||||
type = OrganizationType.ADMIN,
|
||||
type = type,
|
||||
seats = 1,
|
||||
isEnabled = isEnabled,
|
||||
providerType = 1,
|
||||
|
||||
Reference in New Issue
Block a user