forked from mtusi2026/mtusi2026lab6
Реализована лабораторная 6 на оценку 4
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package telemetry
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRouteLabelsNeverContainResourceIDs(t *testing.T) {
|
||||
ids := []string{"11111111-1111-4111-8111-111111111111", "22222222-2222-4222-8222-222222222222"}
|
||||
for _, id := range ids {
|
||||
cases := map[string]string{
|
||||
"/api/v1/chats/" + id: "/api/v1/chats/{chat_id}",
|
||||
"/api/v1/chats/" + id + "/messages": "/api/v1/chats/{chat_id}/messages",
|
||||
"/api/v1/chats/" + id + "/attachments": "/api/v1/chats/{chat_id}/attachments",
|
||||
"/api/v1/attachments/" + id + "/content": "/api/v1/attachments/{attachment_id}/content",
|
||||
"/arbitrary/" + id: "/unmatched",
|
||||
}
|
||||
for input, want := range cases {
|
||||
got := Route(input)
|
||||
if got != want || strings.Contains(got, id) {
|
||||
t.Fatalf("unsafe route label %q for %q", got, input)
|
||||
}
|
||||
}
|
||||
}
|
||||
if Method("CUSTOM-USER-METHOD") != "OTHER" {
|
||||
t.Fatal("unbounded method label")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user