25 lines
1017 B
Swift
25 lines
1017 B
Swift
import Foundation
|
|
import Darwin
|
|
|
|
/// Run only inside a temporary signed app with the built host's entitlements.
|
|
/// This opt-in integration check contacts the same HTTPS endpoint as the app.
|
|
@main struct SandboxNetworkChecks {
|
|
static func main() async {
|
|
var request = URLRequest(url: URL(string: "https://api.ipify.org")!)
|
|
request.timeoutInterval = 5
|
|
do {
|
|
let (_, response) = try await URLSession.shared.data(for: request)
|
|
guard (response as? HTTPURLResponse)?.statusCode == 200 else {
|
|
print("FAIL: public-address endpoint did not return HTTP 200")
|
|
exit(1)
|
|
}
|
|
print("PASS: signed sandbox public-address HTTPS request returned HTTP 200")
|
|
} catch {
|
|
// Keep the public address and potentially identifying error URLs out of logs.
|
|
let error = error as NSError
|
|
print("FAIL: sandbox HTTPS request: \(error.domain) code \(error.code)")
|
|
exit(1)
|
|
}
|
|
}
|
|
}
|