(ta TestAccessor, t *testing.T)
| 398 | } |
| 399 | |
| 400 | func 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 | |
| 443 | func testUpsertOCSPAndGetOCSP(ta TestAccessor, t *testing.T) { |
| 444 | ta.Truncate() |
no test coverage detected
searching dependent graphs…