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

Function testInsertOCSPAndGetUnexpiredOCSP

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

Source from the content-addressed store, hash-verified

357}
358
359func testInsertOCSPAndGetUnexpiredOCSP(ta TestAccessor, t *testing.T) {
360 ta.Truncate()
361
362 want := certdb.OCSPRecord{
363 Serial: "fake serial 2",
364 AKI: fakeAKI,
365 Body: "fake body",
366 Expiry: time.Now().Add(time.Minute),
367 }
368 setupGoodCert(ta, t, want)
369
370 if err := ta.Accessor.InsertOCSP(want); err != nil {
371 t.Fatal(err)
372 }
373
374 rets, err := ta.Accessor.GetOCSP(want.Serial, want.AKI)
375 if err != nil {
376 t.Fatal(err)
377 }
378 if len(rets) != 1 {
379 t.Fatal("should return exactly one record")
380 }
381
382 got := rets[0]
383
384 if want.Serial != got.Serial || want.Body != got.Body ||
385 !roughlySameTime(want.Expiry, got.Expiry) {
386 t.Errorf("want OCSP %+v, got %+v", want, got)
387 }
388
389 unexpired, err := ta.Accessor.GetUnexpiredOCSPs()
390
391 if err != nil {
392 t.Fatal(err)
393 }
394
395 if len(unexpired) != 1 {
396 t.Error("should not have other than 1 unexpired certificate record:", len(unexpired))
397 }
398}
399
400func testUpdateOCSPAndGetOCSP(ta TestAccessor, t *testing.T) {
401 ta.Truncate()

Callers 1

testEverythingFunction · 0.85

Calls 8

setupGoodCertFunction · 0.85
roughlySameTimeFunction · 0.85
TruncateMethod · 0.80
AddMethod · 0.65
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…