Buckets:
localhost1978/localhost / LOCALHOST1978 /Modules /SSK_Providers /Tests /SSK_ProvidersTests /RemoteVaultManagerTests.swift
| import XCTest | |
| import SSK_Abstractions | |
| @testable import SSK_Providers | |
| final class RemoteVaultManagerTests: XCTestCase { | |
| var manager: RemoteVaultManager! | |
| override func setUp() async throws { | |
| manager = RemoteVaultManager() | |
| } | |
| override func tearDown() async throws { | |
| try? await manager.unmount() | |
| manager = nil | |
| } | |
| func testRemoteVaultRejectsUnauthenticated() async throws { | |
| let endpoint = URL(string: "https://10.0.0.1:1978")! | |
| // Passing nil configuration | |
| do { | |
| try await manager.connectToRemoteVault(endpoint: endpoint, configuration: nil) | |
| XCTFail("Should reject unauthenticated/missing configuration") | |
| } catch let error as RemoteVaultError { | |
| XCTAssertEqual(error, .invalidConfiguration) | |
| } catch { | |
| XCTFail("Unexpected error: \(error)") | |
| } | |
| // Passing invalid JSON configuration | |
| let badConfig = "invalid_json".data(using: .utf8)! | |
| do { | |
| try await manager.connectToRemoteVault(endpoint: endpoint, configuration: badConfig) | |
| XCTFail("Should reject invalid configuration") | |
| } catch let error as RemoteVaultError { | |
| XCTAssertEqual(error, .invalidConfiguration) | |
| } catch { | |
| XCTFail("Unexpected error: \(error)") | |
| } | |
| } | |
| func testRemoteVaultFallback() async throws { | |
| let endpoint = URL(string: "https://10.0.0.1:1978")! | |
| // Create a valid dummy configuration for PeerInfo | |
| let peerJSON = """ | |
| { | |
| "id": "123e4567-e89b-12d3-a456-426614174000", | |
| "publicKey": "dummy_pub_key", | |
| "endpoint": "10.0.0.1:1978", | |
| "allowedIPs": ["10.0.0.2/32"] | |
| } | |
| """ | |
| let validConfig = peerJSON.data(using: .utf8)! | |
| do { | |
| // The establishTunnel might fail since WireGuard tunnel manager needs real keys/network, | |
| // but we expect either success setting mountPath or a specific networking error, not invalidConfiguration. | |
| try await manager.connectToRemoteVault(endpoint: endpoint, configuration: validConfig) | |
| XCTAssertTrue(manager.isMounted) | |
| XCTAssertEqual(manager.currentMountPath?.scheme, "https") | |
| } catch { | |
| // If the tunnel manager throws because it's not a real environment, that's fine. | |
| // We just ensure we got past the configuration check. | |
| XCTAssertNotEqual(error as? RemoteVaultError, .invalidConfiguration) | |
| } | |
| } | |
| } | |
Xet Storage Details
- Size:
- 2.6 kB
- Xet hash:
- cc933415efab371ccfdc6b62d7edfbebe87a4dce3587168471b49a7bb31bc80d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.