28 lines
1.3 KiB
Swift
28 lines
1.3 KiB
Swift
|
|
import XCTest
|
||
|
|
@testable import UCVLZonghengjia
|
||
|
|
|
||
|
|
final class ConnectionAttemptPolicyTests: XCTestCase {
|
||
|
|
func testControlPlaneTimeoutDoesNotBlacklistUnassignedNode() {
|
||
|
|
XCTAssertEqual(ConnectionAttemptPolicy.decide(error: URLError(.timedOut), hasAssignedNode: false), .stop)
|
||
|
|
}
|
||
|
|
|
||
|
|
func testAuthorizationFailureDoesNotCycleNodes() {
|
||
|
|
for status in [401, 403] {
|
||
|
|
XCTAssertEqual(ConnectionAttemptPolicy.decide(
|
||
|
|
error: UCVLError.api(status: status, message: "fixture"), hasAssignedNode: true), .revokeAuthorization)
|
||
|
|
}
|
||
|
|
XCTAssertEqual(ConnectionAttemptPolicy.decide(
|
||
|
|
error: UCVLError.api(status: 503, message: "fixture"), hasAssignedNode: false), .stop)
|
||
|
|
}
|
||
|
|
|
||
|
|
func testPermissionAndConfigurationFailuresAreLocal() {
|
||
|
|
XCTAssertEqual(ConnectionAttemptPolicy.decide(error: UCVLError.vpnPermission("fixture"), hasAssignedNode: true), .stop)
|
||
|
|
XCTAssertEqual(ConnectionAttemptPolicy.decide(error: UCVLError.invalidConfiguration("fixture"), hasAssignedNode: true), .stop)
|
||
|
|
XCTAssertEqual(ConnectionAttemptPolicy.decide(error: CancellationError(), hasAssignedNode: true), .stop)
|
||
|
|
}
|
||
|
|
|
||
|
|
func testAssignedNodeTransportFailureCanFailOver() {
|
||
|
|
XCTAssertEqual(ConnectionAttemptPolicy.decide(error: UCVLError.connection("fixture"), hasAssignedNode: true), .retryNode)
|
||
|
|
}
|
||
|
|
}
|