Skip to content

Commit 5339f2c

Browse files
committed
test(licensing): cover customer object without email
1 parent 310589b commit 5339f2c

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎Tests/AmoreLicensingTests/LicensePayloadDecodeTests.swift‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,26 @@ struct LicensePayloadDecodeTests {
126126
let license = License(from: payload)
127127
#expect(license.customer == nil)
128128
}
129+
130+
// A `customer` object may be present without an `email` (partial or
131+
// forward-compatible token). It must decode with a nil email rather than
132+
// throw and reject the entire license.
133+
@Test func customerDecodesWithNilEmailWhenObjectHasNoEmail() throws {
134+
let json = """
135+
{
136+
"exp": 1800000000,
137+
"iat": 1779000000,
138+
"hardware_id": "hw-1",
139+
"license_id": "C7B53B0E-2C18-4F1D-8C9B-2B7B6A8B6A7E",
140+
"nonce": "n-1",
141+
"product": { "name": "Pro", "identifier": "pro" },
142+
"entitlements": [],
143+
"customer": {}
144+
}
145+
"""
146+
let payload = try decodePayload(json)
147+
let license = License(from: payload)
148+
#expect(license.customer != nil)
149+
#expect(license.customer?.email == nil)
150+
}
129151
}

0 commit comments

Comments
 (0)