()
| 23 | } |
| 24 | |
| 25 | func (s *PathTestSuite) TestParsePath() { |
| 26 | testCases := []struct { |
| 27 | name string |
| 28 | pathPrefix string |
| 29 | requestPath string |
| 30 | expectedPath string |
| 31 | expectedSig string |
| 32 | expectedError bool |
| 33 | }{ |
| 34 | { |
| 35 | name: "BasicPath", |
| 36 | requestPath: "/dummy_signature/rs:fill:300:200/plain/http://example.com/image.jpg", |
| 37 | expectedPath: "rs:fill:300:200/plain/http://example.com/image.jpg", |
| 38 | expectedSig: "dummy_signature", |
| 39 | expectedError: false, |
| 40 | }, |
| 41 | { |
| 42 | name: "PathWithQueryParams", |
| 43 | requestPath: "/dummy_signature/rs:fill:300:200/plain/http://example.com/image.jpg?param1=value1¶m2=value2", |
| 44 | expectedPath: "rs:fill:300:200/plain/http://example.com/image.jpg", |
| 45 | expectedSig: "dummy_signature", |
| 46 | expectedError: false, |
| 47 | }, |
| 48 | { |
| 49 | name: "PathWithPrefix", |
| 50 | pathPrefix: "/imgproxy", |
| 51 | requestPath: "/imgproxy/dummy_signature/rs:fill:300:200/plain/http://example.com/image.jpg", |
| 52 | expectedPath: "rs:fill:300:200/plain/http://example.com/image.jpg", |
| 53 | expectedSig: "dummy_signature", |
| 54 | expectedError: false, |
| 55 | }, |
| 56 | { |
| 57 | name: "PathWithPlainUrlRedenormalization", |
| 58 | requestPath: "/dummy_signature/rs:fill:300:200/plain/https:/example.com/path/to/image.jpg", |
| 59 | expectedPath: "rs:fill:300:200/plain/https://example.com/path/to/image.jpg", |
| 60 | expectedSig: "dummy_signature", |
| 61 | expectedError: false, |
| 62 | }, |
| 63 | { |
| 64 | name: "PathWithOptionsSeparatorUnescapingPLain", |
| 65 | requestPath: "/dummy_signature/rs%3Afill%3A300%3A200/plain/https://example.com/path/to/image.jpg", |
| 66 | expectedPath: "rs:fill:300:200/plain/https://example.com/path/to/image.jpg", |
| 67 | expectedSig: "dummy_signature", |
| 68 | expectedError: false, |
| 69 | }, |
| 70 | { |
| 71 | name: "PathWithOptionsSeparatorUnescapingBas64", |
| 72 | requestPath: "/dummy_signature/rs%3Afill%3A300%3A200/abc/abc", |
| 73 | expectedPath: "rs:fill:300:200/abc/abc", |
| 74 | expectedSig: "dummy_signature", |
| 75 | expectedError: false, |
| 76 | }, |
| 77 | { |
| 78 | name: "NoSignatureSeparator", |
| 79 | requestPath: "/invalid_path_without_slash", |
| 80 | expectedPath: "", |
| 81 | expectedSig: "", |
| 82 | expectedError: true, |
nothing calls this directly
no test coverage detected