eleven / ocho Public

Clone
git clone https://amadan.net/eleven/ocho

Plain git — no account needed to clone.

Download

Download this file

1import XCTest
2@testable import LChatCore
3
4// Drift gate for the notification extension's decrypt path: a push payload's
5// blob (produced by the web crypto) must open with GroupKey exactly as the NSE
6// does it. A failure means the NSE would fall back to the generic banner for
7// every push — the wire format drifted from crypto.js.
8final class PushBlobDecryptTests: XCTestCase {
9 struct Vector: Decodable {
10 let keyB64: String
11 let blob: String
12 let expectName: String
13 let expectText: String
14 }
15 struct Payload: Decodable {
16 let name: String?
17 let text: String?
18 }
19
20 func testPushBlobDecryptsLikeTheNSE() throws {
21 let v = try fixture(Vector.self, "push-blob-vector")
22 let raw = try XCTUnwrap(Data(base64urlEncoded: v.keyB64), "fixture key is not valid base64url")
23 let key = try GroupKey(rawKey: raw)
24 let payload = try key.decryptJSON(Payload.self, blob: v.blob)
25 XCTAssertEqual(payload.name, v.expectName)
26 XCTAssertEqual(payload.text, v.expectText)
27 }
28}
29