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

Function testUpdateOCSPAndGetOCSP

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

Source from the content-addressed store, hash-verified

398}
399
400func testUpdateOCSPAndGetOCSP(ta TestAccessor, t *testing.T) {
401 ta.Truncate()
402
403 want := certdb.OCSPRecord{
404 Serial: "fake serial 3",
405 AKI: fakeAKI,
406 Body: "fake body",
407 Expiry: time.Date(2010, time.December, 25, 23, 0, 0, 0, time.UTC),
408 }
409 setupGoodCert(ta, t, want)
410
411 // Make sure the update fails
412 if err := ta.Accessor.UpdateOCSP(want.Serial, want.AKI, want.Body, want.Expiry); err == nil {
413 t.Fatal("Expected error")
414 }
415
416 if err := ta.Accessor.InsertOCSP(want); err != nil {
417 t.Fatal(err)
418 }
419
420 want.Body = "fake body revoked"
421 newExpiry := time.Now().Add(time.Hour)
422 if err := ta.Accessor.UpdateOCSP(want.Serial, want.AKI, want.Body, newExpiry); err != nil {
423 t.Fatal(err)
424 }
425
426 rets, err := ta.Accessor.GetOCSP(want.Serial, want.AKI)
427 if err != nil {
428 t.Fatal(err)
429 }
430 if len(rets) != 1 {
431 t.Fatal("should return exactly one record")
432 }
433
434 got := rets[0]
435
436 want.Expiry = newExpiry
437 if want.Serial != got.Serial || got.Body != "fake body revoked" ||
438 !roughlySameTime(newExpiry, got.Expiry) {
439 t.Errorf("want OCSP %+v, got %+v", want, got)
440 }
441}
442
443func testUpsertOCSPAndGetOCSP(ta TestAccessor, t *testing.T) {
444 ta.Truncate()

Callers 1

testEverythingFunction · 0.85

Calls 7

setupGoodCertFunction · 0.85
roughlySameTimeFunction · 0.85
TruncateMethod · 0.80
UpdateOCSPMethod · 0.65
InsertOCSPMethod · 0.65
AddMethod · 0.65
GetOCSPMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…