(t *testing.T)
| 535 | } |
| 536 | |
| 537 | func TestIndexingPermanodeMissingPubkey(t *testing.T) { |
| 538 | s := sorted.NewMemoryKeyValue() |
| 539 | idx, err := index.New(s) |
| 540 | if err != nil { |
| 541 | t.Fatal(err) |
| 542 | } |
| 543 | |
| 544 | id := indextest.NewIndexDeps(idx) |
| 545 | id.Fataler = t |
| 546 | |
| 547 | goodKeyFetcher := id.Index.KeyFetcher |
| 548 | emptyFetcher := new(test.Fetcher) |
| 549 | |
| 550 | // Prevent the index from being able to find the public key: |
| 551 | idx.KeyFetcher = emptyFetcher |
| 552 | |
| 553 | pn := id.NewPermanode() |
| 554 | |
| 555 | // Verify that populateClaim noted the missing public key blob: |
| 556 | { |
| 557 | key := fmt.Sprintf("missing|%s|%s", pn, id.SignerBlobRef) |
| 558 | if got, err := s.Get(key); got == "" || err != nil { |
| 559 | t.Errorf("key %q missing (err: %v); want 1", key, err) |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | // Now make it available again: |
| 564 | idx.KeyFetcher = idx.Exp_BlobSource() |
| 565 | |
| 566 | if err := copyBlob(id.SignerBlobRef, idx.Exp_BlobSource().(*test.Fetcher), goodKeyFetcher); err != nil { |
| 567 | t.Errorf("Error copying public key to BlobSource: %v", err) |
| 568 | } |
| 569 | if err := copyBlob(id.SignerBlobRef, idx, goodKeyFetcher); err != nil { |
| 570 | t.Errorf("Error uploading public key to indexer: %v", err) |
| 571 | } |
| 572 | |
| 573 | idx.Exp_AwaitAsyncIndexing(t) |
| 574 | |
| 575 | // Verify that populateClaim noted the now present public key blob: |
| 576 | { |
| 577 | key := fmt.Sprintf("missing|%s|%s", pn, id.SignerBlobRef) |
| 578 | if got, err := s.Get(key); got != "" || err == nil { |
| 579 | t.Errorf("row %q still exists", key) |
| 580 | } |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | func copyBlob(br blob.Ref, dst blobserver.BlobReceiver, src blob.Fetcher) error { |
| 585 | rc, _, err := src.Fetch(ctxbg, br) |
nothing calls this directly
no test coverage detected