You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Use Case:
As a developer, I need to configure the Firebase Auth module to utilize in-memory storage exclusively within the UI Tests target. Since UI Tests cannot access the Keychain, this adjustment is critical for validating UI state changes triggered by Firestore snapshot listeners. Specifically, I require the ability to programmatically authenticate users during UI tests to bypass security rules and verify correct UI behavior when interacting with Firestore data protected by authenticated user permissions.
2. Current Firebase SDK Behavior:
The Firebase Auth SDK defaults to secure Keychain storage for sensitive user data (tokens, credentials) on iOS/macOS. While this ensures production-grade security, it renders Auth unusable in UI Testing environments due to Keychain access restrictions. This limitation blocks testing of auth-dependent flows, such as Firestore write operations guarded by security rules.
3. Proposed Enhancement for Firebase SDK:
Introduce an explicit in-memory storage mode for Firebase Auth, configurable at runtime. This mode would:
Disable Keychain Persistence: Prevent any Keychain read/write operations when activated. Retain Auth State In-Memory: Maintain user credentials, tokens, and auth state within the active app session. Reset State on App Termination: Clear all auth data upon app exit to mimic ephemeral test environments.
Implementation Recommendations:
Add a storageType Property to AuthSettings:
public enum AuthStorageType {
case keychain // Default production behavior (persists to Keychain)
case inMemory // Ephemeral storage for tests (no Keychain access)
}
let auth = Auth.auth()
auth.settings.storageType = .inMemory // Set before auth APIs are used
Documentation & Safety Measures:
Clearly label .inMemory as unsuitable for production in API docs.
Throw a runtime warning/assertion if .inMemory is used outside of debug/UI test builds.
Benefits:
Unblock UI Testing: Enables end-to-end validation of auth-gated workflows (e.g., Firestore writes) without Keychain. Explicit Control: Developers opt into in-memory behavior only where needed, preserving secure defaults. Platform Consistency: Aligns with existing patterns like Firestore’s settings.isPersistenceEnabled.
func testAuthProtectedFlow() {
// Configure Auth for in-memory (no Keychain)
let app = XCUIApplication()
app.launch()
// Programmatically sign in (no UI interaction)
Auth.auth().signIn(withEmail: "[email protected]", password: "password")
// Perform Firestore write & validate UI update
let db = Firestore.firestore()
db.collection("protectedData").document("testDoc").setData(["value": 42])
XCTAssert(app.staticTexts["Data Updated"].exists)
}
This approach balances security with testing flexibility, empowering developers to validate auth-integrated experiences fully.
API Proposal
No response
Firebase Product(s)
Authentication
The text was updated successfully, but these errors were encountered:
Description
1. Use Case:
As a developer, I need to configure the Firebase Auth module to utilize in-memory storage exclusively within the UI Tests target. Since UI Tests cannot access the Keychain, this adjustment is critical for validating UI state changes triggered by Firestore snapshot listeners. Specifically, I require the ability to programmatically authenticate users during UI tests to bypass security rules and verify correct UI behavior when interacting with Firestore data protected by authenticated user permissions.
2. Current Firebase SDK Behavior:
The Firebase Auth SDK defaults to secure Keychain storage for sensitive user data (tokens, credentials) on iOS/macOS. While this ensures production-grade security, it renders Auth unusable in UI Testing environments due to Keychain access restrictions. This limitation blocks testing of auth-dependent flows, such as Firestore write operations guarded by security rules.
3. Proposed Enhancement for Firebase SDK:
Introduce an explicit in-memory storage mode for Firebase Auth, configurable at runtime. This mode would:
Disable Keychain Persistence: Prevent any Keychain read/write operations when activated.
Retain Auth State In-Memory: Maintain user credentials, tokens, and auth state within the active app session.
Reset State on App Termination: Clear all auth data upon app exit to mimic ephemeral test environments.
Implementation Recommendations:
Add a
storageType
Property toAuthSettings
:Documentation & Safety Measures:
Clearly label
.inMemory
as unsuitable for production in API docs.Throw a runtime warning/assertion if .inMemory is used outside of debug/UI test builds.
Unblock UI Testing: Enables end-to-end validation of auth-gated workflows (e.g., Firestore writes) without Keychain.
Explicit Control: Developers opt into in-memory behavior only where needed, preserving secure defaults.
Platform Consistency: Aligns with existing patterns like Firestore’s settings.isPersistenceEnabled.
This approach balances security with testing flexibility, empowering developers to validate auth-integrated experiences fully.
API Proposal
No response
Firebase Product(s)
Authentication
The text was updated successfully, but these errors were encountered: