MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestValidTenantIDs

Function TestValidTenantIDs

pkg/util/users/tenant_test.go:10–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestValidTenantIDs(t *testing.T) {
11 for _, tc := range []struct {
12 name string
13 err *string
14 }{
15 {
16 name: "tenant-a",
17 },
18 {
19 name: "ABCDEFGHIJKLMNOPQRSTUVWXYZ-abcdefghijklmnopqrstuvwxyz_0987654321!.*'()",
20 },
21 {
22 name: "invalid|",
23 err: strptr("tenant ID 'invalid|' contains unsupported character '|'"),
24 },
25 {
26 name: strings.Repeat("a", 150),
27 },
28 {
29 name: strings.Repeat("a", 151),
30 err: strptr("tenant ID is too long: max 150 characters"),
31 },
32 {
33 name: ".",
34 err: strptr("tenant ID is '.' or '..'"),
35 },
36 {
37 name: "..",
38 err: strptr("tenant ID is '.' or '..'"),
39 },
40 {
41 name: "__markers__",
42 err: strptr("tenant ID '__markers__' is not allowed"),
43 },
44 {
45 name: "user-index.json.gz",
46 err: strptr("tenant ID 'user-index.json.gz' is not allowed"),
47 },
48 } {
49 t.Run(tc.name, func(t *testing.T) {
50 err := ValidTenantID(tc.name)
51 if tc.err == nil {
52 assert.Nil(t, err)
53 } else {
54 assert.EqualError(t, err, *tc.err)
55 }
56 })
57 }
58}

Callers

nothing calls this directly

Calls 3

strptrFunction · 0.85
ValidTenantIDFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected