A container registry that uses the AT Protocol for manifest storage and S3 for blob storage. atcr.io
docker container atproto go
81
fork

Configure Feed

Select the types of activity you want to include in your feed.

remove unused function

-128
-8
pkg/appview/storage/manifest_store.go
··· 271 271 return dgst.Encoded() 272 272 } 273 273 274 - // GetLastFetchedHoldDID returns the hold DID from the most recently fetched manifest 275 - // This is used by the routing repository to cache the hold for blob requests 276 - func (s *ManifestStore) GetLastFetchedHoldDID() string { 277 - s.mu.RLock() 278 - defer s.mu.RUnlock() 279 - return s.lastFetchedHoldDID 280 - } 281 - 282 274 // rawManifest is a simple implementation of distribution.Manifest 283 275 type rawManifest struct { 284 276 mediaType string
-120
pkg/appview/storage/manifest_store_test.go
··· 136 136 } 137 137 } 138 138 139 - // TestManifestStore_GetLastFetchedHoldDID tests tracking last fetched hold DID 140 - func TestManifestStore_GetLastFetchedHoldDID(t *testing.T) { 141 - tests := []struct { 142 - name string 143 - manifestHoldDID string 144 - manifestHoldURL string 145 - expectedLastFetched string 146 - }{ 147 - { 148 - name: "prefers HoldDID", 149 - manifestHoldDID: "did:web:hold01.atcr.io", 150 - manifestHoldURL: "https://hold01.atcr.io", 151 - expectedLastFetched: "did:web:hold01.atcr.io", 152 - }, 153 - { 154 - name: "falls back to HoldEndpoint URL conversion", 155 - manifestHoldDID: "", 156 - manifestHoldURL: "https://hold02.atcr.io", 157 - expectedLastFetched: "did:web:hold02.atcr.io", 158 - }, 159 - { 160 - name: "empty hold references", 161 - manifestHoldDID: "", 162 - manifestHoldURL: "", 163 - expectedLastFetched: "", 164 - }, 165 - } 166 - 167 - for _, tt := range tests { 168 - t.Run(tt.name, func(t *testing.T) { 169 - client := atproto.NewClient("https://pds.example.com", "did:plc:test123", "token") 170 - ctx := mockRegistryContext(client, "myapp", "", "did:plc:test123", "test.handle", nil) 171 - store := NewManifestStore(ctx, nil) 172 - 173 - // Simulate what happens in Get() when parsing a manifest record 174 - var manifestRecord atproto.ManifestRecord 175 - manifestRecord.HoldDID = tt.manifestHoldDID 176 - manifestRecord.HoldEndpoint = tt.manifestHoldURL 177 - 178 - // Mimic the hold DID extraction logic from Get() 179 - if manifestRecord.HoldDID != "" { 180 - store.lastFetchedHoldDID = manifestRecord.HoldDID 181 - } else if manifestRecord.HoldEndpoint != "" { 182 - store.lastFetchedHoldDID = atproto.ResolveHoldDIDFromURL(manifestRecord.HoldEndpoint) 183 - } 184 - 185 - got := store.GetLastFetchedHoldDID() 186 - if got != tt.expectedLastFetched { 187 - t.Errorf("GetLastFetchedHoldDID() = %v, want %v", got, tt.expectedLastFetched) 188 - } 189 - }) 190 - } 191 - } 192 - 193 139 // TestRawManifest tests the rawManifest implementation 194 140 func TestRawManifest(t *testing.T) { 195 141 mediaType := "application/vnd.oci.image.manifest.v1+json" ··· 536 482 if tt.checkFunc != nil { 537 483 tt.checkFunc(t, manifest) 538 484 } 539 - } 540 - }) 541 - } 542 - } 543 - 544 - // TestManifestStore_Get_HoldDIDTracking tests that Get() stores the holdDID 545 - func TestManifestStore_Get_HoldDIDTracking(t *testing.T) { 546 - ociManifest := []byte(`{"schemaVersion":2}`) 547 - 548 - tests := []struct { 549 - name string 550 - manifestResp string 551 - expectedHoldDID string 552 - }{ 553 - { 554 - name: "tracks HoldDID from new format", 555 - manifestResp: `{ 556 - "uri":"at://did:plc:test123/io.atcr.manifest/abc123", 557 - "value":{ 558 - "$type":"io.atcr.manifest", 559 - "holdDid":"did:web:hold01.atcr.io", 560 - "holdEndpoint":"https://hold01.atcr.io", 561 - "mediaType":"application/vnd.oci.image.manifest.v1+json", 562 - "manifestBlob":{"ref":{"$link":"bafytest"},"size":100} 563 - } 564 - }`, 565 - expectedHoldDID: "did:web:hold01.atcr.io", 566 - }, 567 - { 568 - name: "tracks HoldDID from legacy HoldEndpoint", 569 - manifestResp: `{ 570 - "uri":"at://did:plc:test123/io.atcr.manifest/abc123", 571 - "value":{ 572 - "$type":"io.atcr.manifest", 573 - "holdEndpoint":"https://hold02.atcr.io", 574 - "mediaType":"application/vnd.oci.image.manifest.v1+json", 575 - "manifestBlob":{"ref":{"$link":"bafytest"},"size":100} 576 - } 577 - }`, 578 - expectedHoldDID: "did:web:hold02.atcr.io", 579 - }, 580 - } 581 - 582 - for _, tt := range tests { 583 - t.Run(tt.name, func(t *testing.T) { 584 - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 585 - if r.URL.Path == atproto.SyncGetBlob { 586 - w.Write(ociManifest) 587 - return 588 - } 589 - w.Write([]byte(tt.manifestResp)) 590 - })) 591 - defer server.Close() 592 - 593 - client := atproto.NewClient(server.URL, "did:plc:test123", "token") 594 - ctx := mockRegistryContext(client, "myapp", "", "did:plc:test123", "test.handle", nil) 595 - store := NewManifestStore(ctx, nil) 596 - 597 - _, err := store.Get(context.Background(), "sha256:abc123") 598 - if err != nil { 599 - t.Fatalf("Get() error = %v", err) 600 - } 601 - 602 - gotHoldDID := store.GetLastFetchedHoldDID() 603 - if gotHoldDID != tt.expectedHoldDID { 604 - t.Errorf("GetLastFetchedHoldDID() = %v, want %v", gotHoldDID, tt.expectedHoldDID) 605 485 } 606 486 }) 607 487 }