MCPcopy
hub / github.com/containerd/containerd / TestGetTokenScopes

Function TestGetTokenScopes

core/remotes/docker/scope_test.go:59–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestGetTokenScopes(t *testing.T) {
60 testCases := []struct {
61 scopesInCtx []string
62 commonScopes []string
63 expected []string
64 }{
65 {
66 scopesInCtx: []string{},
67 commonScopes: []string{},
68 expected: []string{},
69 },
70 {
71 scopesInCtx: []string{},
72 commonScopes: []string{"repository:foo/bar:pull"},
73 expected: []string{"repository:foo/bar:pull"},
74 },
75 {
76 scopesInCtx: []string{"repository:foo/bar:pull,push"},
77 commonScopes: []string{},
78 expected: []string{"repository:foo/bar:pull,push"},
79 },
80 {
81 scopesInCtx: []string{"repository:foo/bar:pull"},
82 commonScopes: []string{"repository:foo/bar:pull"},
83 expected: []string{"repository:foo/bar:pull"},
84 },
85 {
86 scopesInCtx: []string{"repository:foo/bar:pull"},
87 commonScopes: []string{"repository:foo/bar:pull,push"},
88 expected: []string{"repository:foo/bar:pull", "repository:foo/bar:pull,push"},
89 },
90 {
91 scopesInCtx: []string{"repository:foo/bar:pull"},
92 commonScopes: []string{"repository:foo/bar:pull,push", "repository:foo/bar:pull"},
93 expected: []string{"repository:foo/bar:pull", "repository:foo/bar:pull,push"},
94 },
95 }
96 for _, tc := range testCases {
97 ctx := context.WithValue(context.TODO(), tokenScopesKey{}, tc.scopesInCtx)
98 actual := GetTokenScopes(ctx, tc.commonScopes)
99 assert.Equal(t, tc.expected, actual)
100 }
101}
102
103func TestCustomScope(t *testing.T) {
104 scope := "whatever:foo/bar:pull"

Callers

nothing calls this directly

Calls 1

GetTokenScopesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…