Modern Apps git

xtool.git

Public
git clone https://git.maproj.org/xtool.git
main ▾

xtool.git / Tests / XToolTests / DistTests.swift

DistTests.swift23 lines · 1.1 KiBRaw
1import Foundation
2import Testing
3@testable import XToolSupport
4
5@Test func ascJSONParsesNestedAppleResponses() throws {
6 let json = try ASCJSON(parsing: Data(#"{"data":[{"id":"app1","attributes":{"bundleId":"com.example.app","rank":2,"beta":true}}]}"#.utf8))
7 let first = json["data"]?.arrayValue?.first
8 #expect(first?["id"]?.stringValue == "app1")
9 #expect(first?["attributes"]?["bundleId"]?.stringValue == "com.example.app")
10 #expect(first?["attributes"]?["beta"]?.boolValue == true)
11 let roundTrip = try ASCJSON(parsing: json.serialize())
12 #expect(roundTrip["data"]?.arrayValue?.first?["id"]?.stringValue == "app1")
13}
14
15@Test func ascChecksumsMatchKnownVectors() throws {
16 let file = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
17 try Data("abc".utf8).write(to: file)
18 defer { try? FileManager.default.removeItem(at: file) }
19 let sums = try AppStoreConnectClient.checksums(of: file)
20 // RFC 1321 / FIPS 180-2 test vectors for "abc".
21 #expect(sums.md5 == "900150983cd24fb0d6963f7d28e17f72")
22 #expect(sums.sha256 == "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad")
23}