Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BIT-2072: Enables enableCipherKeyEncryption feature flag #530

Merged
merged 10 commits into from
Mar 19, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import BitwardenSdk
class MockClientPlatform: ClientPlatformProtocol {
var fingerprintMaterialString: String?
var fingerprintResult: Result<String, Error> = .success("a-fingerprint-phrase-string-placeholder")
var featureFlags: [String: Bool] = ["": false]
var userFingerprintCalled = false

func fingerprint(req: BitwardenSdk.FingerprintRequest) async throws -> String {
try fingerprintResult.get()
}

func loadFlags(flags: [String: Bool]) async throws {
// Nothing yet.
throw BitwardenTestError.example
featureFlags = flags
}

func userFingerprint(fingerprintMaterial: String) async throws -> String {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation

// MARK: - FeatureFlagsConstants

/// An enumeration of feature flags.
///
enum FeatureFlagsConstants {
// MARK: Properties

/// A flag that enables individual cipher encryption.
static let enableCipherKeyEncryption = "enableCipherKeyEncryption"
}
17 changes: 16 additions & 1 deletion BitwardenShared/UI/Platform/Application/AppProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ public class AppProcessor {
}
}

await loadFlags()
await services.migrationService.performMigrations()

await services.environmentService.loadURLsForActiveAccount()

services.application?.registerForRemoteNotifications()

if let initialRoute {
Expand Down Expand Up @@ -199,3 +200,17 @@ extension AppProcessor: SyncServiceDelegate {
await coordinator?.handleEvent(.didLogout(userId: userId, userInitiated: false))
}
}

// MARK: - Feature flags

extension AppProcessor {
/// Loads feature flags.
///
func loadFlags() async {
do {
try await services.clientPlatform.loadFlags(flags: [FeatureFlagsConstants.enableCipherKeyEncryption: true])
} catch {
services.errorReporter.log(error: error)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class AppProcessorTests: BitwardenTestCase {

var appModule: MockAppModule!
var authRepository: MockAuthRepository!
var clientPlatform: MockClientPlatform!
var coordinator: MockCoordinator<AppRoute, AppEvent>!
var errorReporter: MockErrorReporter!
var migrationService: MockMigrationService!
Expand All @@ -28,6 +29,7 @@ class AppProcessorTests: BitwardenTestCase {
router = MockRouter(routeForEvent: { _ in .landing })
appModule = MockAppModule()
authRepository = MockAuthRepository()
clientPlatform = MockClientPlatform()
coordinator = MockCoordinator()
appModule.authRouter = router
appModule.appCoordinator = coordinator
Expand All @@ -44,6 +46,7 @@ class AppProcessorTests: BitwardenTestCase {
appModule: appModule,
services: ServiceContainer.withMocks(
authRepository: authRepository,
clientService: MockClientService(clientPlatform: clientPlatform),
errorReporter: errorReporter,
migrationService: migrationService,
notificationService: notificationService,
Expand Down Expand Up @@ -114,6 +117,12 @@ class AppProcessorTests: BitwardenTestCase {
XCTAssertIdentical(syncService.delegate, subject)
}

/// `.loadFlags()` loads the feature flags.
func test_loadFlags() async {
await subject.loadFlags()
XCTAssertEqual(clientPlatform.featureFlags, ["enableCipherKeyEncryption": true])
}

/// `messageReceived(_:notificationDismissed:notificationTapped)` passes the data to the notification service.
func test_messageReceived() async {
let message: [AnyHashable: Any] = ["knock knock": "who's there?"]
Expand Down
2 changes: 1 addition & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ options:
indentWidth: 4
tabWidth: 4
settings:
MARKETING_VERSION: 1.0.0 # Bump this for a new version update.
MARKETING_VERSION: 2024.03.0 # Bump this for a new version update.
CURRENT_PROJECT_VERSION: 1
packages:
BitwardenSdk:
Expand Down
Loading