Skip to content

Commit ca3076a

Browse files
authored
[Tests] NFC: Remove overload of GeneralizedTime.init(_:) (#7986)
### Motivation: `swift-certificates` now implements initializer that accepts `Date` and doesn't throw which means this method is redundant but also incorrect because overloading only on `throws` is ambiguous in most cases due to throws checking not being part of the expression checking. Uses of this overload type-checked only because it was always preferred before due to old type-checker hacks that we are trying to remove. ### Modifications: - Removes `GeneralizedTime.init(_:) throws` that was added before `swift-certificates` introduced their own non-throwing version. ### Result: No more duplicate code that is less safe than what `swift-certificates` vends.
1 parent fc49d53 commit ca3076a

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

Tests/PackageSigningTests/SigningTests.swift

+4-19
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,14 @@ final class SigningTests: XCTestCase {
511511
throw StringError("Missing OCSP request")
512512
}
513513

514-
let ocspResponse = OCSPResponse.successful(try .signed(
514+
let ocspResponse = try OCSPResponse.successful(.signed(
515515
responderID: ResponderID.byName(intermediateName),
516-
producedAt: try GeneralizedTime(validationTime),
516+
producedAt: GeneralizedTime(validationTime),
517517
responses: [OCSPSingleResponse(
518518
certID: singleRequest.certID,
519519
certStatus: .unknown,
520-
thisUpdate: try GeneralizedTime(validationTime - .days(1)),
521-
nextUpdate: try GeneralizedTime(validationTime + .days(1))
520+
thisUpdate: GeneralizedTime(validationTime - .days(1)),
521+
nextUpdate: GeneralizedTime(validationTime + .days(1))
522522
)],
523523
privateKey: intermediatePrivateKey,
524524
responseExtensions: { nonce }
@@ -1174,21 +1174,6 @@ extension TimeInterval {
11741174
private let gregorianCalendar = Calendar(identifier: .gregorian)
11751175
private let utcTimeZone = TimeZone(identifier: "UTC")!
11761176

1177-
extension GeneralizedTime {
1178-
init(_ date: Date) throws {
1179-
let components = gregorianCalendar.dateComponents(in: utcTimeZone, from: date)
1180-
try self.init(
1181-
year: components.year!,
1182-
month: components.month!,
1183-
day: components.day!,
1184-
hours: components.hour!,
1185-
minutes: components.minute!,
1186-
seconds: components.second!,
1187-
fractionalSeconds: 0.0
1188-
)
1189-
}
1190-
}
1191-
11921177
extension BasicOCSPResponse {
11931178
static func signed(
11941179
responseData: OCSPResponseData,

0 commit comments

Comments
 (0)