1package daemon23import (4 "context"5 "encoding/json"6 "net/http"7 "net/http/httptest"8 "reflect"9 "testing"10)1112func TestPrivateNIP11MatchesRuntimeGRASPCapabilities(t *testing.T) {13 _, tenant := testTenant(t)14 p := tenant.Policy()15 p.Features.Grasp = true16 p.Features.Grasp02 = true17 p.Features.Grasp03 = true18 p.Features.Grasp06 = true19 p.Features.Grasp08 = true20 p.Reads = "members"21 if err := tenant.applyPolicy(context.Background(), p); err != nil {22 t.Fatal(err)23 }24 req := httptest.NewRequest(http.MethodGet, "http://relay.test/", nil)25 req.Header.Set("Accept", "application/nostr+json")26 res := httptest.NewRecorder()27 tenant.ServeHTTP(res, req)28 var info struct {29 Profiles []string `json:"supported_grasps"`30 }31 if err := json.Unmarshal(res.Body.Bytes(), &info); err != nil {32 t.Fatal(err)33 }34 want := []string{"GRASP-01", "GRASP-02", "GRASP-03", "GRASP-06", "GRASP-08"}35 if !reflect.DeepEqual(info.Profiles, want) {36 t.Fatalf("NIP-11 profiles = %v", info.Profiles)37 }38 for _, capability := range tenant.Capabilities(nil) {39 if capability.ID == "GRASP" && !reflect.DeepEqual(capability.Profiles, info.Profiles) {40 t.Fatalf("runtime profiles = %v; NIP-11 = %v", capability.Profiles, info.Profiles)41 }42 }43}