mirror of
https://github.com/sudosylabs/vnidrop.git
synced 2026-08-05 02:29:55 +02:00
feat(network): support custom relay servers
Add strict custom Iroh relay profiles with safe restart and rollback across the Rust core, Compose apps, and Apple apps. Preserve multi-relay invitations and fail closed on configuration or recovery mismatches.
This commit is contained in:
@@ -15,11 +15,12 @@ final class AppPreferencesRepositoryTests: XCTestCase {
|
||||
)
|
||||
}
|
||||
|
||||
func testFallbacksWhenEmpty() {
|
||||
func testMissingRelayProfileDefaultsToAutomatic() {
|
||||
let repo = AppPreferencesRepository(defaults: defaults(), fallback: fallback())
|
||||
XCTAssertEqual(repo.preferences.username, "Default")
|
||||
XCTAssertEqual(repo.preferences.themeMode, .system)
|
||||
XCTAssertFalse(repo.preferences.notificationsEnabled)
|
||||
XCTAssertEqual(repo.preferences.relayConfiguration, .automatic)
|
||||
}
|
||||
|
||||
func testValuesPersistAndReload() {
|
||||
@@ -30,6 +31,10 @@ final class AppPreferencesRepositoryTests: XCTestCase {
|
||||
repo.setThemeMode(.dark)
|
||||
repo.setNotificationsEnabled(true)
|
||||
repo.setReceiveFolder(ReceiveFolder(kind: .iosSecurityScopedUrl, value: "file:///x", displayName: "Custom"))
|
||||
repo.setRelayConfiguration(RelayConfiguration(
|
||||
mode: .custom,
|
||||
relayURLs: ["https://relay-one.example", "https://relay-two.example:443"]
|
||||
))
|
||||
|
||||
// A fresh repository over the same store reflects the persisted values.
|
||||
let reloaded = AppPreferencesRepository(defaults: store, fallback: fb)
|
||||
@@ -38,6 +43,40 @@ final class AppPreferencesRepositoryTests: XCTestCase {
|
||||
XCTAssertTrue(reloaded.preferences.notificationsEnabled)
|
||||
XCTAssertEqual(reloaded.preferences.receiveFolder.displayName, "Custom")
|
||||
XCTAssertEqual(reloaded.preferences.receiveFolder.kind, .iosSecurityScopedUrl)
|
||||
XCTAssertEqual(reloaded.preferences.relayConfiguration, RelayConfiguration(
|
||||
mode: .custom,
|
||||
relayURLs: ["https://relay-one.example", "https://relay-two.example:443"]
|
||||
))
|
||||
XCTAssertNotNil(store.data(forKey: "relay_configuration"))
|
||||
XCTAssertNil(store.object(forKey: "relay_mode"))
|
||||
XCTAssertNil(store.object(forKey: "relay_urls"))
|
||||
}
|
||||
|
||||
func testCorruptedRelayProfileFailsClosed() {
|
||||
let store = defaults()
|
||||
store.set(Data("{".utf8), forKey: "relay_configuration")
|
||||
|
||||
let repo = AppPreferencesRepository(defaults: store, fallback: fallback())
|
||||
|
||||
XCTAssertEqual(
|
||||
repo.preferences.relayConfiguration,
|
||||
RelayConfiguration(mode: .custom, relayURLs: [])
|
||||
)
|
||||
}
|
||||
|
||||
func testUnknownRelayModeFailsClosed() {
|
||||
let store = defaults()
|
||||
store.set(
|
||||
Data(#"{"mode":"future-mode","relayURLs":["https://relay.example"]}"#.utf8),
|
||||
forKey: "relay_configuration"
|
||||
)
|
||||
|
||||
let repo = AppPreferencesRepository(defaults: store, fallback: fallback())
|
||||
|
||||
XCTAssertEqual(
|
||||
repo.preferences.relayConfiguration,
|
||||
RelayConfiguration(mode: .custom, relayURLs: [])
|
||||
)
|
||||
}
|
||||
|
||||
func testResetReceiveFolderRestoresFallback() {
|
||||
|
||||
Reference in New Issue
Block a user