@@ -28,14 +28,13 @@ async function app(event) {
28
28
29
29
const routes = new Map ( ) ;
30
30
routes . set ( '/' , ( ) => {
31
- routes . delete ( '/' ) ;
32
31
let test_routes = Array . from ( routes . keys ( ) )
33
32
return new Response ( JSON . stringify ( test_routes ) , { 'headers' : { 'content-type' : 'application/json' } } ) ;
34
33
} ) ;
35
34
36
35
routes . set ( "/fastly/getgeolocationforipaddress/interface" , async function ( ) {
37
36
let actual = Reflect . getOwnPropertyDescriptor ( fastly , 'getGeolocationForIpAddress' )
38
- expected = {
37
+ let expected = {
39
38
writable : true ,
40
39
enumerable : true ,
41
40
configurable : true ,
@@ -118,93 +117,62 @@ routes.set("/fastly/getgeolocationforipaddress/parameter-empty-string", async ()
118
117
return pass ( )
119
118
} ) ;
120
119
121
- let ipv4Expected = {
122
- as_name : "sky uk limited ",
123
- as_number : 5607 ,
124
- area_code : 0 ,
125
- city : "bircotes ",
126
- conn_speed : "broadband ",
127
- conn_type : "wifi ",
128
- continent : "EU ",
129
- country_code : "GB ",
130
- country_code3 : "GBR ",
131
- country_name : "united kingdom ",
132
- latitude : 53.42 ,
133
- longitude : - 1.05 ,
134
- metro_code : 826039 ,
135
- postal_code : "dn11 8af ",
136
- proxy_description : "? ",
137
- proxy_type : "? ",
138
- region : "NTT ",
139
- }
120
+ let geoFields = [ "as_name" ,
121
+ "as_number ",
122
+ "area_code" ,
123
+ "city" ,
124
+ "conn_speed ",
125
+ "conn_type ",
126
+ "continent ",
127
+ "country_code ",
128
+ "country_code3 ",
129
+ "country_name ",
130
+ "gmt_offset ",
131
+ " latitude" ,
132
+ " longitude" ,
133
+ " metro_code" ,
134
+ "postal_code ",
135
+ "proxy_description ",
136
+ "proxy_type ",
137
+ "region ",
138
+ "utc_offset" ]
140
139
141
140
routes . set ( "/fastly/getgeolocationforipaddress/parameter-ipv4-string" , async ( ) => {
142
141
let geo = fastly . getGeolocationForIpAddress ( '2.216.196.179' )
143
- delete geo . utc_offset ;
144
- delete geo . gmt_offset ;
145
- let error = assert ( geo , ipv4Expected , `fastly.getGeolocationForIpAddress('2.216.196.179') == ipv4Expected` )
142
+ let error = assert ( Object . keys ( geo ) , geoFields , `Object.keys(fastly.getGeolocationForIpAddress('2.216.196.179')) == geoFields` )
146
143
if ( error ) { return error }
147
144
return pass ( )
148
145
} ) ;
149
146
150
- let expected = {
151
- as_name : "softlayer technologies inc." ,
152
- as_number : 36351 ,
153
- area_code : 214 ,
154
- city : "dallas" ,
155
- conn_speed : "broadband" ,
156
- conn_type : "wired" ,
157
- continent : "NA" ,
158
- country_code : "US" ,
159
- country_code3 : "USA" ,
160
- country_name : "united states" ,
161
- latitude : 32.94 ,
162
- longitude : - 96.84 ,
163
- metro_code : 623 ,
164
- postal_code : "75244" ,
165
- proxy_description : "?" ,
166
- proxy_type : "hosting" ,
167
- region : "TX" ,
168
- }
169
147
routes . set ( "/fastly/getgeolocationforipaddress/parameter-compressed-ipv6-string" , async ( ) => {
170
148
let geo = fastly . getGeolocationForIpAddress ( '2607:f0d0:1002:51::4' )
171
- delete geo . utc_offset ;
172
- delete geo . gmt_offset ;
173
- let error = assert ( geo , expected , `fastly.getGeolocationForIpAddress('2607:f0d0:1002:51::4') == expected` )
149
+ let error = assert ( Object . keys ( geo ) , geoFields , `Object.keys(fastly.getGeolocationForIpAddress('2607:f0d0:1002:51::4')) == geoFields` )
174
150
if ( error ) { return error }
175
151
return pass ( )
176
152
} ) ;
177
153
routes . set ( "/fastly/getgeolocationforipaddress/parameter-shortened-ipv6-string" , async ( ) => {
178
154
let geo = fastly . getGeolocationForIpAddress ( '2607:f0d0:1002:0051:0:0:0:0004' )
179
- delete geo . utc_offset ;
180
- delete geo . gmt_offset ;
181
- let error = assert ( geo , expected , `fastly.getGeolocationForIpAddress('2607:f0d0:1002:0051:0:0:0:0004') == expected` )
155
+ let error = assert ( Object . keys ( geo ) , geoFields , `Object.keys(fastly.getGeolocationForIpAddress('2607:f0d0:1002:0051:0:0:0:0004')) == geoFields` )
182
156
if ( error ) { return error }
183
157
return pass ( )
184
158
} ) ;
185
159
routes . set ( "/fastly/getgeolocationforipaddress/parameter-expanded-ipv6-string" , async ( ) => {
186
160
let geo = fastly . getGeolocationForIpAddress ( '2607:f0d0:1002:0051:0000:0000:0000:0004' )
187
- delete geo . utc_offset ;
188
- delete geo . gmt_offset ;
189
- let error = assert ( geo , expected , `fastly.getGeolocationForIpAddress('2607:f0d0:1002:0051:0000:0000:0000:0004') == expected` )
161
+ let error = assert ( Object . keys ( geo ) , geoFields , `Object.keys(fastly.getGeolocationForIpAddress('2607:f0d0:1002:0051:0000:0000:0000:0004')) == geoFields` )
190
162
if ( error ) { return error }
191
163
return pass ( )
192
164
} ) ;
193
165
// TODO: Uncomment these tests once IPv4-in-6 is working in ipll
194
166
// routes.set("/fastly/getgeolocationforipaddress/parameter-dual-ipv4-ipv6-string", async () => {
195
167
// let geo = fastly.getGeolocationForIpAddress('::FFFF:2.216.196.179')
196
- // delete geo.utc_offset;
197
- // delete geo.gmt_offset;
198
- // let error = assert(geo, expected, `fastly.getGeolocationForIpAddress('::2.216.196.179') == expected`)
168
+ // let error = assert(Object.keys(geo), geoFields, `Object.keys(fastly.getGeolocationForIpAddress('::FFFF:2.216.196.179')) == geoFields`)
199
169
// if (error) { return error }
200
170
// return pass()
201
171
// });
202
172
203
173
routes . set ( "/fastly/getgeolocationforipaddress/called-unbound" , async ( ) => {
204
174
let geo = fastly . getGeolocationForIpAddress . call ( undefined , '2607:f0d0:1002:0051:0000:0000:0000:0004' )
205
- delete geo . utc_offset ;
206
- delete geo . gmt_offset ;
207
- let error = assert ( geo , expected , `fastly.getGeolocationForIpAddress.call(undefined, '2607:f0d0:1002:0051:0000:0000:0000:0004') == expected` )
175
+ let error = assert ( Object . keys ( geo ) , geoFields , `Object.keys(fastly.getGeolocationForIpAddress('2607:f0d0:1002:0051:0000:0000:0000:0004')) == geoFields` )
208
176
if ( error ) { return error }
209
177
return pass ( )
210
178
} ) ;
0 commit comments