Skip to content

Commit 157cdb0

Browse files
authored
[Collections] Adjust cert verify date in tests (#3402)
Motivation: Tests in `PackageCollectionsSigningTests` that involve `Test_ec.cer` are failing. See #3393. I think this is a timezone-related issue. `Test_ec.cer` is valid from November 15, 2020 10:45:20am PST for a year. In the tests we manipulate the timestamp at which the cert validation is done so we don't have to regenerate new test certs and so we can test for different scenarios. That timestamp is set to November 16, 2020 midnight, and depending on where the tests are run, it might potentially mean a time before `Test_ec.cer` is valid and that's why we see "certificate is not yet valid" error. Note that this doesn't happen with tests that use `Test_rsa.cer` since the certificate is valid from November 8, 2020. Modification: Change verify date to November 18, 2020, which should give us more than enough buffer for various timezones.
1 parent ab43e0b commit 157cdb0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Tests/PackageCollectionsSigningTests/Utilities.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ let diagnosticsEngine = DiagnosticsEngine()
2525

2626
struct TestCertificatePolicy: CertificatePolicy {
2727
static let testCertValidDate: Date = {
28+
// This is the datetime that the tests use to validate test certs (Test_rsa.cer, Test_ec.cer).
29+
// Make sure it falls within the certs' validity period, across timezones.
30+
// For example, suppose the current date is April 12, 2021, the cert validation runs as if
31+
// the date were November 18, 2020.
2832
var dateComponents = DateComponents()
2933
dateComponents.year = 2020
3034
dateComponents.month = 11
31-
dateComponents.day = 16
35+
dateComponents.day = 18
3236
return Calendar.current.date(from: dateComponents)!
3337
}()
3438

0 commit comments

Comments
 (0)