Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Sources/AmoreLicensing/AmoreLicensing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,13 @@ public final class AmoreLicensing: Licensing {
status = .invalid
}
}

/// The license a still-within-grace expired payload represents, with its
/// expiry extended to the grace deadline, or `nil` once grace has elapsed.
/// The license a still-within-grace expired payload represents, or `nil` once
/// the grace period has elapsed.
private func graceLicense(for payload: LicensePayload) -> License? {
let graceEnd = payload.exp.addingTimeInterval(configuration.gracePeriod.timeInterval)
guard graceEnd >= .now else { return nil }
var license = License(from: payload)
license.expiresAt = graceEnd
return license
return License(from: payload)
}

private func mapClientErrors<T>(
Expand Down
6 changes: 2 additions & 4 deletions Tests/AmoreLicensingTests/AmoreClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ import Testing
Issue.record("Expected gracePeriod, got \(result)")
return
}
let expectedEnd = expDate.addingTimeInterval(7 * 86_400)
#expect(abs(license.expiresAt!.timeIntervalSince(expectedEnd)) < 1)
#expect(abs(license.expiresAt!.timeIntervalSince(expDate)) < 1)
}

@Test func validateExpiredTokenValidates() async throws {
Expand Down Expand Up @@ -358,8 +357,7 @@ import Testing
Issue.record("Expected gracePeriod on first synchronous read, got \(client.status)")
return
}
let expectedEnd = expDate.addingTimeInterval(7 * 86_400)
#expect(abs(license.expiresAt!.timeIntervalSince(expectedEnd)) < 1)
#expect(abs(license.expiresAt!.timeIntervalSince(expDate)) < 1)
}

/// An expired token whose grace has already elapsed must stay `.unknown` at
Expand Down
Loading