@@ -20,81 +20,49 @@ public class AWSLambdaTest {
20
20
public Timeout rule = Timeout .seconds (2000 );
21
21
22
22
public static String EVENT_MSG = "{\n "
23
- + " \" resource\" : \" /hello \" ,\n "
24
- + " \" path\" : \" /hello \" ,\n "
25
- + " \" httpMethod\" : \" GET \" ,\n "
23
+ + " \" resource\" : \" /{proxy+} \" ,\n "
24
+ + " \" path\" : \" /v1/users \" ,\n "
25
+ + " \" httpMethod\" : \" POST \" ,\n "
26
26
+ " \" headers\" : {\n "
27
- + " \" Accept\" : \" text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\" ,\n "
28
- + " \" Accept-Encoding\" : \" gzip, deflate, br\" ,\n "
29
- + " \" Accept-Language\" : \" en-GB,en-US;q=0.9,en;q=0.8\" ,\n "
30
- + " \" cache-control\" : \" max-age=0\" ,\n "
31
- + " \" CloudFront-Forwarded-Proto\" : \" https\" ,\n "
32
- + " \" CloudFront-Is-Desktop-Viewer\" : \" true\" ,\n "
33
- + " \" CloudFront-Is-Mobile-Viewer\" : \" false\" ,\n "
34
- + " \" CloudFront-Is-SmartTV-Viewer\" : \" false\" ,\n "
35
- + " \" CloudFront-Is-Tablet-Viewer\" : \" false\" ,\n "
36
- + " \" CloudFront-Viewer-Country\" : \" GB\" ,\n "
37
- + " \" Host\" : \" bhpdtkdfek.execute-api.us-east-2.amazonaws.com\" ,\n "
38
- + " \" upgrade-insecure-requests\" : \" 1\" ,\n "
39
- + " \" User-Agent\" : \" Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36\" ,\n "
40
- + " \" Via\" : \" 2.0 cd068397b3367ed727e4988c0cabf85a.cloudfront.net (CloudFront)\" ,\n "
41
- + " \" X-Amz-Cf-Id\" : \" 6opg4d-x5Hptb8RAXkVBhgxlN-KZbU57CU2ew1AVns864MLepMpESA==\" ,\n "
42
- + " \" X-Amzn-Trace-Id\" : \" Root=1-5c22ae99-c8f508c5e9bdc966fbd01b03\" ,\n "
43
- + " \" X-Forwarded-For\" : \" 92.234.149.241, 70.132.20.88\" ,\n "
27
+ + " \" Accept\" : \" */*\" ,\n "
28
+ + " \" accept-encoding\" : \" gzip, deflate\" ,\n "
29
+ + " \" cache-control\" : \" no-cache\" ,\n "
30
+ + " \" Content-Type\" : \" application/json\" ,\n "
31
+ + " \" Host\" : \" jtsxwpy65j.execute-api.us-east-2.amazonaws.com\" ,\n "
32
+ + " \" Postman-Token\" : \" dbbdafc8-5cc7-451c-b767-9f19eeb19941\" ,\n "
33
+ + " \" User-Agent\" : \" PostmanRuntime/7.4.0\" ,\n "
34
+ + " \" X-Amzn-Trace-Id\" : \" Root=1-5c2e854c-db47d2066bcaa15629df52d5\" ,\n "
35
+ + " \" X-Forwarded-For\" : \" 49.36.130.148\" ,\n "
44
36
+ " \" X-Forwarded-Port\" : \" 443\" ,\n "
45
37
+ " \" X-Forwarded-Proto\" : \" https\" \n "
46
38
+ " },\n "
47
39
+ " \" multiValueHeaders\" : {\n "
48
40
+ " \" Accept\" : [\n "
49
- + " \" text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng, */*;q=0.8 \" \n "
41
+ + " \" */*\" \n "
50
42
+ " ],\n "
51
- + " \" Accept-Encoding\" : [\n "
52
- + " \" gzip, deflate, br\" \n "
53
- + " ],\n "
54
- + " \" Accept-Language\" : [\n "
55
- + " \" en-GB,en-US;q=0.9,en;q=0.8\" \n "
43
+ + " \" accept-encoding\" : [\n "
44
+ + " \" gzip, deflate\" \n "
56
45
+ " ],\n "
57
46
+ " \" cache-control\" : [\n "
58
- + " \" max-age=0\" \n "
59
- + " ],\n "
60
- + " \" CloudFront-Forwarded-Proto\" : [\n "
61
- + " \" https\" \n "
62
- + " ],\n "
63
- + " \" CloudFront-Is-Desktop-Viewer\" : [\n "
64
- + " \" true\" \n "
65
- + " ],\n "
66
- + " \" CloudFront-Is-Mobile-Viewer\" : [\n "
67
- + " \" false\" \n "
68
- + " ],\n "
69
- + " \" CloudFront-Is-SmartTV-Viewer\" : [\n "
70
- + " \" false\" \n "
47
+ + " \" no-cache\" \n "
71
48
+ " ],\n "
72
- + " \" CloudFront-Is-Tablet-Viewer\" : [\n "
73
- + " \" false\" \n "
74
- + " ],\n "
75
- + " \" CloudFront-Viewer-Country\" : [\n "
76
- + " \" GB\" \n "
49
+ + " \" Content-Type\" : [\n "
50
+ + " \" application/json\" \n "
77
51
+ " ],\n "
78
52
+ " \" Host\" : [\n "
79
- + " \" bhpdtkdfek .execute-api.us-east-2.amazonaws.com\" \n "
53
+ + " \" jtsxwpy65j .execute-api.us-east-2.amazonaws.com\" \n "
80
54
+ " ],\n "
81
- + " \" upgrade-insecure-requests \" : [\n "
82
- + " \" 1 \" \n "
55
+ + " \" Postman-Token \" : [\n "
56
+ + " \" dbbdafc8-5cc7-451c-b767-9f19eeb19941 \" \n "
83
57
+ " ],\n "
84
58
+ " \" User-Agent\" : [\n "
85
- + " \" Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36\" \n "
86
- + " ],\n "
87
- + " \" Via\" : [\n "
88
- + " \" 2.0 cd068397b3367ed727e4988c0cabf85a.cloudfront.net (CloudFront)\" \n "
89
- + " ],\n "
90
- + " \" X-Amz-Cf-Id\" : [\n "
91
- + " \" 6opg4d-x5Hptb8RAXkVBhgxlN-KZbU57CU2ew1AVns864MLepMpESA==\" \n "
59
+ + " \" PostmanRuntime/7.4.0\" \n "
92
60
+ " ],\n "
93
61
+ " \" X-Amzn-Trace-Id\" : [\n "
94
- + " \" Root=1-5c22ae99-c8f508c5e9bdc966fbd01b03 \" \n "
62
+ + " \" Root=1-5c2e854c-db47d2066bcaa15629df52d5 \" \n "
95
63
+ " ],\n "
96
64
+ " \" X-Forwarded-For\" : [\n "
97
- + " \" 92.234.149.241, 70.132.20.88 \" \n "
65
+ + " \" 49.36.130.148 \" \n "
98
66
+ " ],\n "
99
67
+ " \" X-Forwarded-Port\" : [\n "
100
68
+ " \" 443\" \n "
@@ -105,39 +73,43 @@ public class AWSLambdaTest {
105
73
+ " },\n "
106
74
+ " \" queryStringParameters\" : null,\n "
107
75
+ " \" multiValueQueryStringParameters\" : null,\n "
108
- + " \" pathParameters\" : null,\n "
109
- + " \" stageVariables\" : null,\n "
76
+ + " \" pathParameters\" : {\n "
77
+ + " \" proxy\" : \" v1/users\" \n "
78
+ + " },\n "
79
+ + " \" stageVariables\" : {\n "
80
+ + " \" lambdaAlias\" : \" test\" \n "
81
+ + " },\n "
110
82
+ " \" requestContext\" : {\n "
111
- + " \" resourceId\" : \" ikgn3l \" ,\n "
112
- + " \" resourcePath\" : \" /session \" ,\n "
113
- + " \" httpMethod\" : \" GET \" ,\n "
114
- + " \" extendedRequestId\" : \" SfA3_EY2CYcFowA =\" ,\n "
115
- + " \" requestTime\" : \" 25/Dec/2018:22:26:33 +0000\" ,\n "
116
- + " \" path\" : \" /tutorial/session \" ,\n "
117
- + " \" accountId\" : \" 762985365920 \" ,\n "
83
+ + " \" resourceId\" : \" tjdogf \" ,\n "
84
+ + " \" resourcePath\" : \" /{proxy+} \" ,\n "
85
+ + " \" httpMethod\" : \" POST \" ,\n "
86
+ + " \" extendedRequestId\" : \" S8nEBFgziYcFXrg =\" ,\n "
87
+ + " \" requestTime\" : \" 03/Jan/2019:21:57:32 +0000\" ,\n "
88
+ + " \" path\" : \" /test/v1/users \" ,\n "
89
+ + " \" accountId\" : \" 904774318525 \" ,\n "
118
90
+ " \" protocol\" : \" HTTP/1.1\" ,\n "
119
- + " \" stage\" : \" tutorial \" ,\n "
120
- + " \" domainPrefix\" : \" bhpdtkdfek \" ,\n "
121
- + " \" requestTimeEpoch\" : 1545776793579 ,\n "
122
- + " \" requestId\" : \" 22568c6e-0894 -11e9-90cf-f74da74d2315 \" ,\n "
91
+ + " \" stage\" : \" test \" ,\n "
92
+ + " \" domainPrefix\" : \" jtsxwpy65j \" ,\n "
93
+ + " \" requestTimeEpoch\" : 1546552652926 ,\n "
94
+ + " \" requestId\" : \" 928bba1b-0fa2 -11e9-ad27-8354b9dd01f4 \" ,\n "
123
95
+ " \" identity\" : {\n "
124
96
+ " \" cognitoIdentityPoolId\" : null,\n "
125
97
+ " \" accountId\" : null,\n "
126
98
+ " \" cognitoIdentityId\" : null,\n "
127
99
+ " \" caller\" : null,\n "
128
- + " \" sourceIp\" : \" 92.234.149.241 \" ,\n "
100
+ + " \" sourceIp\" : \" 49.36.130.148 \" ,\n "
129
101
+ " \" accessKey\" : null,\n "
130
102
+ " \" cognitoAuthenticationType\" : null,\n "
131
103
+ " \" cognitoAuthenticationProvider\" : null,\n "
132
104
+ " \" userArn\" : null,\n "
133
- + " \" userAgent\" : \" Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 \" ,\n "
105
+ + " \" userAgent\" : \" PostmanRuntime/7.4.0 \" ,\n "
134
106
+ " \" user\" : null\n "
135
107
+ " },\n "
136
- + " \" domainName\" : \" bhpdtkdfek .execute-api.us-east-2.amazonaws.com\" ,\n "
137
- + " \" apiId\" : \" bhpdtkdfek \" \n "
108
+ + " \" domainName\" : \" jtsxwpy65j .execute-api.us-east-2.amazonaws.com\" ,\n "
109
+ + " \" apiId\" : \" jtsxwpy65j \" \n "
138
110
+ " },\n "
139
- + " \" body\" : null ,\n "
140
- + " \" isBase64Encoded\" : false "
111
+ + " \" body\" : \" ewogICAgInR5cGUiOiAiQURNSU4iLAogICAgImZpcnN0TmFtZSI6ICJGaXJzdCBOYW1lIiwKICAgICJtaWRkbGVOYW1lIjogIk1pZGRsZSBOYW1lIiwKICAgICJsYXN0TmFtZSI6ICJMYXN0IE5hbWUiLAogICAgImFkZHJlc3MiOiAiVUI5OTIyIiwKICAgICJkb2IiOiAiMTk5Ni0xMC0xNSIsCiAgICAicGhvbmVMYW5kbGluZSI6ICI5ODc2NTU0NjYiLAogICAgInBob25lTW9iaWxlIjogIjQ0NDQ0NDQ0MzQzIiwKICAgICJwZXJtaXNzaW9ucyI6IFsKICAgICAgICAiYWxsIgogICAgXSwKICAgICJ1c2VybmFtZSI6ICJ1c2VyIG5hbWUiLAogICAgInBhc3N3b3JkIjogInVzZXIgcGFzc3dvcmQiCn0= \" ,\n "
112
+ + " \" isBase64Encoded\" : true \n "
141
113
+ "}" ;
142
114
143
115
@ Test
@@ -154,6 +126,7 @@ public void testProcess() {
154
126
assertTrue (jsonResp .containsKey ("multiValueHeaders" ));
155
127
assertTrue (jsonResp .containsKey ("body" ));
156
128
assertEquals (jsonResp .fieldNames ().size (), 5 );
129
+ assertEquals (System .getProperty ("stage" ), "test" );
157
130
}
158
131
159
132
}
0 commit comments