aboutsummaryrefslogtreecommitdiff
path: root/internal/api/plc_compatibility_test.go
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-28 04:15:23 -0800
committerFuwn <[email protected]>2026-02-28 04:15:23 -0800
commitc7fa9bd5887666e12b555396b5ce64b8af2b3c5f (patch)
tree925ab01f9f0e1772c572ba41d7ccdf8586616234 /internal/api/plc_compatibility_test.go
parentfix(thin): retry DID fetches on 429 and align DID doc shape (diff)
downloadplutia-test-c7fa9bd5887666e12b555396b5ce64b8af2b3c5f.tar.xz
plutia-test-c7fa9bd5887666e12b555396b5ce64b8af2b3c5f.zip
fix(api): align tombstoned DID compatibility with plc.directory
Diffstat (limited to 'internal/api/plc_compatibility_test.go')
-rw-r--r--internal/api/plc_compatibility_test.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/internal/api/plc_compatibility_test.go b/internal/api/plc_compatibility_test.go
index 45428d8..a669f0c 100644
--- a/internal/api/plc_compatibility_test.go
+++ b/internal/api/plc_compatibility_test.go
@@ -302,6 +302,56 @@ func TestPLCCompatibilityNotFoundUsesPLCErrorShape(t *testing.T) {
}
}
+func TestPLCCompatibilityTombstonedDIDReturnsNotAvailable404(t *testing.T) {
+ ts, store, _, cleanup := newCompatibilityServer(t)
+ defer cleanup()
+
+ const tombDID = "did:plc:tombstone-test"
+
+ if err := store.PutState(types.StateV1{
+ DID: tombDID,
+ ChainTipHash: "bafy-tomb-tip",
+ DIDDocument: []byte(`{"id":"did:plc:tombstone-test","deactivated":true}`),
+ }); err != nil {
+ t.Fatalf("put tombstoned state: %v", err)
+ }
+
+ check := func(path string) {
+ t.Helper()
+
+ resp, err := http.Get(ts.URL + path)
+ if err != nil {
+ t.Fatalf("get %s: %v", path, err)
+ }
+ defer resp.Body.Close()
+
+ if resp.StatusCode != http.StatusNotFound {
+ t.Fatalf("%s status: got %d want 404", path, resp.StatusCode)
+ }
+
+ if got := resp.Header.Get("Content-Type"); got != "application/json; charset=utf-8" {
+ t.Fatalf("%s content-type mismatch: got %q want %q", path, got, "application/json; charset=utf-8")
+ }
+
+ var body map[string]any
+ if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
+ t.Fatalf("%s decode body: %v", path, err)
+ }
+
+ if len(body) != 1 {
+ t.Fatalf("%s expected single message field, got: %v", path, body)
+ }
+
+ want := "DID not available: " + tombDID
+ if got, _ := body["message"].(string); got != want {
+ t.Fatalf("%s message mismatch: got %q want %q", path, got, want)
+ }
+ }
+
+ check("/" + tombDID)
+ check("/" + tombDID + "/data")
+}
+
func newCompatibilityServer(t *testing.T) (*httptest.Server, *storage.PebbleStore, []types.ExportRecord, func()) {
t.Helper()