Skip to content

Commit 1f7fdd6

Browse files
committed
Merge branch 'ky/x509-implement-eq'
* ky/x509-implement-eq: test/test_x509crl: fix random failure test/test_x509cert: fix flaky test
2 parents cfd0a44 + 8e79900 commit 1f7fdd6

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

test/test_x509cert.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,17 @@ def test_read_from_file
170170
end
171171

172172
def test_eq
173-
cacert = issue_cert(@ca, @rsa1024, 1, [], nil, nil)
174-
cert1 = issue_cert(@ee1, @rsa2048, 2, [], cacert, @rsa1024)
175-
cert2 = issue_cert(@ee1, @rsa2048, 2, [], cacert, @rsa1024)
176-
cert3 = issue_cert(@ee1, @rsa2048, 3, [], cacert, @rsa1024)
177-
cert4 = issue_cert(@ee1, @rsa2048, 2, [], cacert, @rsa1024, digest: "sha512")
173+
now = Time.now
174+
cacert = issue_cert(@ca, @rsa1024, 1, [], nil, nil,
175+
not_before: now, not_after: now + 3600)
176+
cert1 = issue_cert(@ee1, @rsa2048, 2, [], cacert, @rsa1024,
177+
not_before: now, not_after: now + 3600)
178+
cert2 = issue_cert(@ee1, @rsa2048, 2, [], cacert, @rsa1024,
179+
not_before: now, not_after: now + 3600)
180+
cert3 = issue_cert(@ee1, @rsa2048, 3, [], cacert, @rsa1024,
181+
not_before: now, not_after: now + 3600)
182+
cert4 = issue_cert(@ee1, @rsa2048, 2, [], cacert, @rsa1024,
183+
digest: "sha512", not_before: now, not_after: now + 3600)
178184

179185
assert_equal false, cert1 == 12345
180186
assert_equal true, cert1 == cert2

test/test_x509crl.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,13 @@ def test_revoked_to_der
221221
end
222222

223223
def test_eq
224+
now = Time.now
225+
224226
cacert = issue_cert(@ca, @rsa1024, 1, [], nil, nil)
225-
crl1 = issue_crl([], 1, Time.now, Time.now + 3600, [], cacert, @rsa1024, "sha256")
227+
crl1 = issue_crl([], 1, now, now + 3600, [], cacert, @rsa1024, "sha256")
226228
rev1 = OpenSSL::X509::Revoked.new.tap { |rev|
227229
rev.serial = 1
228-
rev.time = Time.now
230+
rev.time = now
229231
}
230232
crl1.add_revoked(rev1)
231233
crl2 = OpenSSL::X509::CRL.new(crl1.to_der)
@@ -235,7 +237,7 @@ def test_eq
235237
assert_equal true, crl1 == crl2
236238
rev2 = OpenSSL::X509::Revoked.new.tap { |rev|
237239
rev.serial = 2
238-
rev.time = Time.now
240+
rev.time = now
239241
}
240242
crl2.add_revoked(rev2)
241243
assert_equal false, crl1 == crl2

0 commit comments

Comments
 (0)