(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestWorkspaceAppCors(t *testing.T) { |
| 15 | t.Parallel() |
| 16 | |
| 17 | regex, err := appurl.CompileHostnamePattern("*--apps.dev.coder.com") |
| 18 | require.NoError(t, err) |
| 19 | |
| 20 | methods := []string{ |
| 21 | http.MethodOptions, |
| 22 | http.MethodHead, |
| 23 | http.MethodGet, |
| 24 | http.MethodPost, |
| 25 | http.MethodPut, |
| 26 | http.MethodPatch, |
| 27 | http.MethodDelete, |
| 28 | } |
| 29 | |
| 30 | tests := []struct { |
| 31 | name string |
| 32 | origin string |
| 33 | app appurl.ApplicationURL |
| 34 | allowed bool |
| 35 | }{ |
| 36 | { |
| 37 | name: "Self", |
| 38 | origin: "https://3000--agent--ws--user--apps.dev.coder.com", |
| 39 | app: appurl.ApplicationURL{ |
| 40 | AppSlugOrPort: "3000", |
| 41 | AgentName: "agent", |
| 42 | WorkspaceName: "ws", |
| 43 | Username: "user", |
| 44 | }, |
| 45 | allowed: true, |
| 46 | }, |
| 47 | { |
| 48 | name: "SameWorkspace", |
| 49 | origin: "https://8000--agent--ws--user--apps.dev.coder.com", |
| 50 | app: appurl.ApplicationURL{ |
| 51 | AppSlugOrPort: "3000", |
| 52 | AgentName: "agent", |
| 53 | WorkspaceName: "ws", |
| 54 | Username: "user", |
| 55 | }, |
| 56 | allowed: true, |
| 57 | }, |
| 58 | { |
| 59 | name: "SameUser", |
| 60 | origin: "https://8000--agent2--ws2--user--apps.dev.coder.com", |
| 61 | app: appurl.ApplicationURL{ |
| 62 | AppSlugOrPort: "3000", |
| 63 | AgentName: "agent", |
| 64 | WorkspaceName: "ws", |
| 65 | Username: "user", |
| 66 | }, |
| 67 | allowed: true, |
| 68 | }, |
| 69 | { |
| 70 | name: "DifferentOriginOwner", |
| 71 | origin: "https://3000--agent--ws--user2--apps.dev.coder.com", |
nothing calls this directly
no test coverage detected