blob: 62f31c5b9400048a1a5988c74579d194fc527b6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
//
// MockProxyFactory.swift
// MullvadMockData
//
// Created by Mojgan on 2024-05-03.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import Foundation
import MullvadREST
import MullvadRustRuntime
import MullvadTypes
import WireGuardKitTypes
public struct MockProxyFactory: ProxyFactoryProtocol {
public var configuration: REST.AuthProxyConfiguration
public func createAPIProxy() -> any APIQuerying {
REST.APIProxy(configuration: configuration)
}
public func createAccountsProxy() -> any RESTAccountHandling {
AccountsProxyStub(createAccountResult: .success(.mockValue()))
}
public func createDevicesProxy() -> any DeviceHandling {
DevicesProxyStub(deviceResult: .success(Device.mock(publicKey: PrivateKey().publicKey)))
}
public static func makeProxyFactory(
transportProvider: any RESTTransportProvider,
apiTransportProvider: any APITransportProviderProtocol,
addressCache: REST.AddressCache
) -> any ProxyFactoryProtocol {
let basicConfiguration = REST.ProxyConfiguration(
transportProvider: transportProvider,
apiTransportProvider: apiTransportProvider,
addressCacheStore: addressCache
)
let authenticationProxy = REST.AuthenticationProxy(
configuration: basicConfiguration
)
let accessTokenManager = REST.AccessTokenManager(
authenticationProxy: authenticationProxy
)
let authConfiguration = REST.AuthProxyConfiguration(
proxyConfiguration: basicConfiguration,
accessTokenManager: accessTokenManager
)
return MockProxyFactory(configuration: authConfiguration)
}
}
|