(t *testing.T)
| 445 | } |
| 446 | |
| 447 | func TestIndexingPermanodeBadSignature(t *testing.T) { |
| 448 | s := sorted.NewMemoryKeyValue() |
| 449 | idx, err := index.New(s) |
| 450 | if err != nil { |
| 451 | t.Fatal(err) |
| 452 | } |
| 453 | |
| 454 | id := indextest.NewIndexDeps(idx) |
| 455 | id.Fataler = t |
| 456 | |
| 457 | // Create a new permanode and break the signature |
| 458 | goodPermanode := id.Sign(schema.NewPlannedPermanode("replaceme")) |
| 459 | badPermanode := &test.Blob{ |
| 460 | Contents: strings.ReplaceAll(goodPermanode.Contents, "replaceme", "replaced"), |
| 461 | } |
| 462 | |
| 463 | // We can upload it, but the indexing should fail. |
| 464 | if _, err := id.BlobSource.ReceiveBlob(ctxbg, badPermanode.BlobRef(), badPermanode.Reader()); err != nil { |
| 465 | t.Fatalf("public uploading signed blob to blob source, pre-indexing: %v, %v", badPermanode.BlobRef(), err) |
| 466 | } |
| 467 | if _, err = id.Index.ReceiveBlob(ctxbg, badPermanode.BlobRef(), badPermanode.Reader()); err == nil { |
| 468 | t.Fatalf("Successfully indexed a permanode with a bad signature") |
| 469 | } else if !strings.Contains(err.Error(), "signature verification failed") { |
| 470 | t.Fatalf("Expected signature error, got: %v", err) |
| 471 | } |
| 472 | |
| 473 | // Now upload the good one, everything is OK. |
| 474 | if _, err := id.BlobSource.ReceiveBlob(ctxbg, goodPermanode.BlobRef(), goodPermanode.Reader()); err != nil { |
| 475 | t.Fatalf("public uploading signed blob to blob source, pre-indexing: %v, %v", goodPermanode.BlobRef(), err) |
| 476 | } |
| 477 | if _, err = id.Index.ReceiveBlob(ctxbg, goodPermanode.BlobRef(), goodPermanode.Reader()); err != nil { |
| 478 | t.Fatalf("Failed to index the good permanode: %v", err) |
| 479 | } |
| 480 | |
| 481 | } |
| 482 | |
| 483 | func TestIndexingClaimMissingPubkey(t *testing.T) { |
| 484 | s := sorted.NewMemoryKeyValue() |
nothing calls this directly
no test coverage detected