MCPcopy Create free account
hub / github.com/cloudflare/cfssl / testInsertOCSPAndGetOCSP

Function testInsertOCSPAndGetOCSP

certdb/sql/sql_test.go:317–357  ·  view source on GitHub ↗
(ta TestAccessor, t *testing.T)

Source from the content-addressed store, hash-verified

315}
316
317func testInsertOCSPAndGetOCSP(ta TestAccessor, t *testing.T) {
318 ta.Truncate()
319
320 expiry := time.Date(2010, time.December, 25, 23, 0, 0, 0, time.UTC)
321 want := certdb.OCSPRecord{
322 Serial: "fake serial",
323 AKI: fakeAKI,
324 Body: "fake body",
325 Expiry: expiry,
326 }
327 setupGoodCert(ta, t, want)
328
329 if err := ta.Accessor.InsertOCSP(want); err != nil {
330 t.Fatal(err)
331 }
332
333 rets, err := ta.Accessor.GetOCSP(want.Serial, want.AKI)
334 if err != nil {
335 t.Fatal(err)
336 }
337 if len(rets) != 1 {
338 t.Fatal("should return exactly one record")
339 }
340
341 got := rets[0]
342
343 if want.Serial != got.Serial || want.Body != got.Body ||
344 !roughlySameTime(want.Expiry, got.Expiry) {
345 t.Errorf("want OCSP %+v, got %+v", want, got)
346 }
347
348 unexpired, err := ta.Accessor.GetUnexpiredOCSPs()
349
350 if err != nil {
351 t.Fatal(err)
352 }
353
354 if len(unexpired) != 0 {
355 t.Error("should not have unexpired certificate record")
356 }
357}
358
359func testInsertOCSPAndGetUnexpiredOCSP(ta TestAccessor, t *testing.T) {
360 ta.Truncate()

Callers 1

testEverythingFunction · 0.85

Calls 7

setupGoodCertFunction · 0.85
roughlySameTimeFunction · 0.85
TruncateMethod · 0.80
InsertOCSPMethod · 0.65
GetOCSPMethod · 0.65
GetUnexpiredOCSPsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…