(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestServerHandlerModeRestrictions(t *testing.T) { |
| 14 | testCases := []struct { |
| 15 | name string |
| 16 | mode string |
| 17 | method string |
| 18 | target string |
| 19 | wantStatus int |
| 20 | }{ |
| 21 | { |
| 22 | name: "StreamOneAcceptsStreamOne", |
| 23 | mode: "stream-one", |
| 24 | method: http.MethodPost, |
| 25 | target: "https://example.com/xhttp/", |
| 26 | wantStatus: http.StatusOK, |
| 27 | }, |
| 28 | { |
| 29 | name: "StreamOneRejectsSessionDownload", |
| 30 | mode: "stream-one", |
| 31 | method: http.MethodGet, |
| 32 | target: "https://example.com/xhttp/session", |
| 33 | wantStatus: http.StatusNotFound, |
| 34 | }, |
| 35 | { |
| 36 | name: "StreamUpAcceptsStreamOne", |
| 37 | mode: "stream-up", |
| 38 | method: http.MethodPost, |
| 39 | target: "https://example.com/xhttp/", |
| 40 | wantStatus: http.StatusOK, |
| 41 | }, |
| 42 | { |
| 43 | name: "StreamUpAllowsDownloadEndpoint", |
| 44 | mode: "stream-up", |
| 45 | method: http.MethodGet, |
| 46 | target: "https://example.com/xhttp/session", |
| 47 | wantStatus: http.StatusOK, |
| 48 | }, |
| 49 | { |
| 50 | name: "StreamUpRejectsPacketUpload", |
| 51 | mode: "stream-up", |
| 52 | method: http.MethodPost, |
| 53 | target: "https://example.com/xhttp/session/0", |
| 54 | wantStatus: http.StatusNotFound, |
| 55 | }, |
| 56 | { |
| 57 | name: "PacketUpAllowsDownloadEndpoint", |
| 58 | mode: "packet-up", |
| 59 | method: http.MethodGet, |
| 60 | target: "https://example.com/xhttp/session", |
| 61 | wantStatus: http.StatusOK, |
| 62 | }, |
| 63 | { |
| 64 | name: "PacketUpRejectsStreamOne", |
| 65 | mode: "packet-up", |
| 66 | method: http.MethodPost, |
| 67 | target: "https://example.com/xhttp/", |
| 68 | wantStatus: http.StatusNotFound, |
| 69 | }, |
| 70 | { |
nothing calls this directly
no test coverage detected