MCPcopy Index your code
hub / github.com/coder/coder / Test_TokenMatchesRequest

Function Test_TokenMatchesRequest

coderd/workspaceapps/token_test.go:20–280  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func Test_TokenMatchesRequest(t *testing.T) {
21 t.Parallel()
22
23 cases := []struct {
24 name string
25 req workspaceapps.Request
26 token workspaceapps.SignedToken
27 want bool
28 }{
29 {
30 name: "OK",
31 req: workspaceapps.Request{
32 AccessMethod: workspaceapps.AccessMethodPath,
33 BasePath: "/app",
34 UsernameOrID: "foo",
35 WorkspaceNameOrID: "bar",
36 AgentNameOrID: "baz",
37 AppSlugOrPort: "qux",
38 },
39 token: workspaceapps.SignedToken{
40 Request: workspaceapps.Request{
41 AccessMethod: workspaceapps.AccessMethodPath,
42 BasePath: "/app",
43 UsernameOrID: "foo",
44 WorkspaceNameOrID: "bar",
45 AgentNameOrID: "baz",
46 AppSlugOrPort: "qux",
47 },
48 },
49 want: true,
50 },
51 {
52 name: "NormalizePath",
53 req: workspaceapps.Request{
54 AccessMethod: workspaceapps.AccessMethodPath,
55 BasePath: "/app",
56 UsernameOrID: "foo",
57 WorkspaceNameOrID: "bar",
58 AgentNameOrID: "baz",
59 AppSlugOrPort: "qux",
60 },
61 token: workspaceapps.SignedToken{
62 Request: workspaceapps.Request{
63 AccessMethod: workspaceapps.AccessMethodPath,
64 // With trailing slash
65 BasePath: "/app/",
66 UsernameOrID: "foo",
67 WorkspaceNameOrID: "bar",
68 AgentNameOrID: "baz",
69 AppSlugOrPort: "qux",
70 },
71 },
72 want: true,
73 },
74 {
75 name: "DifferentAccessMethod",
76 req: workspaceapps.Request{
77 AccessMethod: workspaceapps.AccessMethodPath,

Callers

nothing calls this directly

Calls 3

MatchesRequestMethod · 0.80
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected