|
6 | 6 | "io/ioutil" |
7 | 7 | "math/rand" |
8 | 8 | "os" |
| 9 | + "strings" |
9 | 10 |
|
10 | 11 | "github.com/aws/aws-lambda-go/events" |
11 | 12 | "github.com/aws/aws-lambda-go/lambdacontext" |
@@ -117,6 +118,44 @@ var _ = Describe("RequestAccessor tests", func() { |
117 | 118 | Expect("2").To(Equal(query["world"][0])) |
118 | 119 | }) |
119 | 120 |
|
| 121 | + mvhRequest := getProxyRequest("/hello", "GET") |
| 122 | + mvhRequest.MultiValueHeaders = map[string][]string{ |
| 123 | + "hello": {"1"}, |
| 124 | + "world": {"2", "3"}, |
| 125 | + } |
| 126 | + It("Populates multiple value headers correctly", func() { |
| 127 | + httpReq, err := accessor.EventToRequestWithContext(context.Background(), mvhRequest) |
| 128 | + Expect(err).To(BeNil()) |
| 129 | + Expect("/hello").To(Equal(httpReq.URL.Path)) |
| 130 | + Expect("GET").To(Equal(httpReq.Method)) |
| 131 | + |
| 132 | + headers := httpReq.Header |
| 133 | + Expect(2).To(Equal(len(headers))) |
| 134 | + |
| 135 | + for k, value := range headers { |
| 136 | + Expect(value).To(Equal(mvhRequest.MultiValueHeaders[strings.ToLower(k)])) |
| 137 | + } |
| 138 | + }) |
| 139 | + |
| 140 | + svhRequest := getProxyRequest("/hello", "GET") |
| 141 | + svhRequest.Headers = map[string]string{ |
| 142 | + "hello": "1", |
| 143 | + "world": "2", |
| 144 | + } |
| 145 | + It("Populates single value headers correctly", func() { |
| 146 | + httpReq, err := accessor.EventToRequestWithContext(context.Background(), svhRequest) |
| 147 | + Expect(err).To(BeNil()) |
| 148 | + Expect("/hello").To(Equal(httpReq.URL.Path)) |
| 149 | + Expect("GET").To(Equal(httpReq.Method)) |
| 150 | + |
| 151 | + headers := httpReq.Header |
| 152 | + Expect(2).To(Equal(len(headers))) |
| 153 | + |
| 154 | + for k, value := range headers { |
| 155 | + Expect(value[0]).To(Equal(svhRequest.Headers[strings.ToLower(k)])) |
| 156 | + } |
| 157 | + }) |
| 158 | + |
120 | 159 | basePathRequest := getProxyRequest("/app1/orders", "GET") |
121 | 160 |
|
122 | 161 | It("Stips the base path correct", func() { |
|
0 commit comments