mirror of
https://github.com/bitwarden/ios.git
synced 2025-12-11 04:34:55 -06:00
PM-11275: Update useKeyConnector flag to keyConnectorEnabled (#863)
This commit is contained in:
parent
6dc82d9701
commit
c15028ee50
@ -139,7 +139,7 @@ extension DefaultKeyConnectorService: KeyConnectorService {
|
||||
|
||||
func getManagingOrganization() async throws -> Organization? {
|
||||
try await organizationService.fetchAllOrganizations()
|
||||
.first { $0.useKeyConnector && !$0.isAdmin }
|
||||
.first { $0.keyConnectorEnabled && !$0.isAdmin }
|
||||
}
|
||||
|
||||
func getMasterKeyFromKeyConnector(keyConnectorUrl: URL) async throws -> String {
|
||||
|
||||
@ -149,7 +149,7 @@ class KeyConnectorServiceTests: BitwardenTestCase { // swiftlint:disable:this ty
|
||||
.httpSuccess(testData: .emptyResponse),
|
||||
]
|
||||
organizationService.fetchAllOrganizationsResult = .success([
|
||||
.fixture(keyConnectorUrl: "https://example.com/key-connector", useKeyConnector: true),
|
||||
.fixture(keyConnectorEnabled: true, keyConnectorUrl: "https://example.com/key-connector"),
|
||||
])
|
||||
stateService.activeAccount = account
|
||||
stateService.accountEncryptionKeys["1"] = AccountEncryptionKeys(
|
||||
@ -195,7 +195,7 @@ class KeyConnectorServiceTests: BitwardenTestCase { // swiftlint:disable:this ty
|
||||
/// `migrateUser()` throws an error if the encrypted user key is missing.
|
||||
func test_migrateUser_missingEncryptedUserKey() async throws {
|
||||
organizationService.fetchAllOrganizationsResult = .success([
|
||||
.fixture(keyConnectorUrl: "https://https://example.com/key-connector", useKeyConnector: true),
|
||||
.fixture(keyConnectorEnabled: true, keyConnectorUrl: "https://https://example.com/key-connector"),
|
||||
])
|
||||
stateService.activeAccount = .fixture()
|
||||
stateService.accountEncryptionKeys["1"] = AccountEncryptionKeys(
|
||||
@ -214,7 +214,7 @@ class KeyConnectorServiceTests: BitwardenTestCase { // swiftlint:disable:this ty
|
||||
func test_migrateUser_deriveKeyConnectorError() async throws {
|
||||
clientService.mockCrypto.deriveKeyConnectorResult = .failure(BitwardenTestError.example)
|
||||
organizationService.fetchAllOrganizationsResult = .success([
|
||||
.fixture(keyConnectorUrl: "https://https://example.com/key-connector", useKeyConnector: true),
|
||||
.fixture(keyConnectorEnabled: true, keyConnectorUrl: "https://https://example.com/key-connector"),
|
||||
])
|
||||
stateService.activeAccount = .fixture()
|
||||
stateService.accountEncryptionKeys["1"] = AccountEncryptionKeys(
|
||||
@ -236,7 +236,7 @@ class KeyConnectorServiceTests: BitwardenTestCase { // swiftlint:disable:this ty
|
||||
.httpFailure(URLError(.networkConnectionLost)),
|
||||
]
|
||||
organizationService.fetchAllOrganizationsResult = .success([
|
||||
.fixture(keyConnectorUrl: "https://https://example.com/key-connector", useKeyConnector: true),
|
||||
.fixture(keyConnectorEnabled: true, keyConnectorUrl: "https://https://example.com/key-connector"),
|
||||
])
|
||||
stateService.activeAccount = .fixture()
|
||||
stateService.accountEncryptionKeys["1"] = AccountEncryptionKeys(
|
||||
@ -255,7 +255,7 @@ class KeyConnectorServiceTests: BitwardenTestCase { // swiftlint:disable:this ty
|
||||
/// but they don't.
|
||||
func test_userNeedsMigration_true() async throws {
|
||||
organizationService.fetchAllOrganizationsResult = .success([
|
||||
.fixture(useKeyConnector: true),
|
||||
.fixture(keyConnectorEnabled: true),
|
||||
])
|
||||
stateService.activeAccount = .fixture()
|
||||
stateService.usesKeyConnector["1"] = false
|
||||
@ -281,7 +281,7 @@ class KeyConnectorServiceTests: BitwardenTestCase { // swiftlint:disable:this ty
|
||||
/// `userNeedsMigration()` returns false if the user isn't an external user.
|
||||
func test_userNeedsMigration_false_notExternal() async throws {
|
||||
organizationService.fetchAllOrganizationsResult = .success([
|
||||
.fixture(useKeyConnector: true),
|
||||
.fixture(keyConnectorEnabled: true),
|
||||
])
|
||||
stateService.activeAccount = .fixture()
|
||||
stateService.usesKeyConnector["1"] = false
|
||||
@ -295,7 +295,7 @@ class KeyConnectorServiceTests: BitwardenTestCase { // swiftlint:disable:this ty
|
||||
/// `userNeedsMigration()` returns false if the user is an organization admin.
|
||||
func test_userNeedsMigration_false_organizationsAdmin() async throws {
|
||||
organizationService.fetchAllOrganizationsResult = .success([
|
||||
.fixture(type: .admin, useKeyConnector: true),
|
||||
.fixture(keyConnectorEnabled: true, type: .admin),
|
||||
])
|
||||
stateService.activeAccount = .fixture()
|
||||
stateService.usesKeyConnector["1"] = false
|
||||
@ -309,7 +309,7 @@ class KeyConnectorServiceTests: BitwardenTestCase { // swiftlint:disable:this ty
|
||||
/// `userNeedsMigration()` returns false if the user is an organization owner.
|
||||
func test_userNeedsMigration_false_organizationsOwner() async throws {
|
||||
organizationService.fetchAllOrganizationsResult = .success([
|
||||
.fixture(type: .owner, useKeyConnector: true),
|
||||
.fixture(keyConnectorEnabled: true, type: .owner),
|
||||
])
|
||||
stateService.activeAccount = .fixture()
|
||||
stateService.usesKeyConnector["1"] = false
|
||||
@ -323,7 +323,7 @@ class KeyConnectorServiceTests: BitwardenTestCase { // swiftlint:disable:this ty
|
||||
/// `userNeedsMigration()` returns false if the user already uses Key Connector.
|
||||
func test_userNeedsMigration_false_usesKeyConnector() async throws {
|
||||
organizationService.fetchAllOrganizationsResult = .success([
|
||||
.fixture(useKeyConnector: true),
|
||||
.fixture(keyConnectorEnabled: true),
|
||||
])
|
||||
stateService.activeAccount = .fixture()
|
||||
stateService.usesKeyConnector["1"] = true
|
||||
|
||||
@ -7,13 +7,13 @@ extension Organization {
|
||||
enabled: Bool = true,
|
||||
id: String = "organization-1",
|
||||
key: String? = nil,
|
||||
keyConnectorEnabled: Bool = false,
|
||||
keyConnectorUrl: String? = nil,
|
||||
name: String = "",
|
||||
permissions: Permissions = Permissions(),
|
||||
status: OrganizationUserStatusType = .confirmed,
|
||||
type: OrganizationUserType = .user,
|
||||
useEvents: Bool = false,
|
||||
useKeyConnector: Bool = false,
|
||||
usePolicies: Bool = true,
|
||||
usersGetPremium: Bool = false
|
||||
) -> Organization {
|
||||
@ -21,13 +21,13 @@ extension Organization {
|
||||
enabled: enabled,
|
||||
id: id,
|
||||
key: key,
|
||||
keyConnectorEnabled: keyConnectorEnabled,
|
||||
keyConnectorUrl: keyConnectorUrl,
|
||||
name: name,
|
||||
permissions: permissions,
|
||||
status: status,
|
||||
type: type,
|
||||
useEvents: useEvents,
|
||||
useKeyConnector: useKeyConnector,
|
||||
usePolicies: usePolicies,
|
||||
usersGetPremium: usersGetPremium
|
||||
)
|
||||
|
||||
@ -12,6 +12,9 @@ public struct Organization: Equatable, Hashable, Sendable {
|
||||
/// The profile organization's key.
|
||||
let key: String?
|
||||
|
||||
/// Whether key connector is enabled for the profile organization.
|
||||
let keyConnectorEnabled: Bool
|
||||
|
||||
/// The key connector URL for the profile organization.
|
||||
let keyConnectorUrl: String?
|
||||
|
||||
@ -30,9 +33,6 @@ public struct Organization: Equatable, Hashable, Sendable {
|
||||
/// Whether the profile's organization uses events.
|
||||
let useEvents: Bool
|
||||
|
||||
/// Whether the profile's organization uses key connector.
|
||||
let useKeyConnector: Bool
|
||||
|
||||
/// Whether the profile's organization uses policies.
|
||||
let usePolicies: Bool
|
||||
|
||||
@ -47,13 +47,13 @@ extension Organization {
|
||||
enabled: responseModel.enabled,
|
||||
id: responseModel.id,
|
||||
key: responseModel.key,
|
||||
keyConnectorEnabled: responseModel.keyConnectorEnabled,
|
||||
keyConnectorUrl: responseModel.keyConnectorUrl,
|
||||
name: name,
|
||||
permissions: responseModel.permissions ?? Permissions(),
|
||||
status: responseModel.status,
|
||||
type: responseModel.type,
|
||||
useEvents: responseModel.useEvents,
|
||||
useKeyConnector: responseModel.useKeyConnector,
|
||||
usePolicies: responseModel.usePolicies,
|
||||
usersGetPremium: responseModel.usersGetPremium
|
||||
)
|
||||
|
||||
@ -493,13 +493,13 @@ struct VaultListView_Previews: PreviewProvider {
|
||||
enabled: true,
|
||||
id: "",
|
||||
key: nil,
|
||||
keyConnectorEnabled: false,
|
||||
keyConnectorUrl: nil,
|
||||
name: "Org",
|
||||
permissions: Permissions(),
|
||||
status: .confirmed,
|
||||
type: .user,
|
||||
useEvents: false,
|
||||
useKeyConnector: false,
|
||||
usePolicies: true,
|
||||
usersGetPremium: false
|
||||
),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user