summaryrefslogtreecommitdiffstats
path: root/internal/auth/auth_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/auth/auth_test.go')
-rw-r--r--internal/auth/auth_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go
index 1f0efee..7a0da19 100644
--- a/internal/auth/auth_test.go
+++ b/internal/auth/auth_test.go
@@ -304,3 +304,41 @@ func TestHashPayload(t *testing.T) {
304 t.Error("different payloads produced same hash") 304 t.Error("different payloads produced same hash")
305 } 305 }
306} 306}
307
308func TestIsWriteMethod(t *testing.T) {
309 tests := []struct {
310 method string
311 want bool
312 }{
313 // Write methods
314 {"/nostr.v1.NostrRelay/PublishEvent", true},
315 {"/nostr.v1.NostrRelay/DeleteEvent", true},
316 {"/admin.v1.Admin/CreateUser", true},
317 {"/admin.v1.Admin/UpdateSettings", true},
318 {"/data.v1.Data/InsertRecord", true},
319 {"/data.v1.Data/RemoveItem", true},
320 {"/storage.v1.Storage/SetValue", true},
321 {"/storage.v1.Storage/PutObject", true},
322
323 // Read methods
324 {"/nostr.v1.NostrRelay/QueryEvents", false},
325 {"/nostr.v1.NostrRelay/Subscribe", false},
326 {"/nostr.v1.NostrRelay/GetEvent", false},
327 {"/admin.v1.Admin/ListUsers", false},
328 {"/health.v1.Health/Check", false},
329 {"/info.v1.Info/GetRelayInfo", false},
330
331 // Edge cases
332 {"", false},
333 {"/", false},
334 }
335
336 for _, tt := range tests {
337 t.Run(tt.method, func(t *testing.T) {
338 got := isWriteMethod(tt.method)
339 if got != tt.want {
340 t.Errorf("isWriteMethod(%q) = %v, want %v", tt.method, got, tt.want)
341 }
342 })
343 }
344}