OLD | NEW |
1 library googleapis.oauth2.v2.test; | 1 library googleapis.oauth2.v2.test; |
2 | 2 |
3 import "dart:core" as core; | 3 import "dart:core" as core; |
4 import "dart:collection" as collection; | |
5 import "dart:async" as async; | 4 import "dart:async" as async; |
6 import "dart:convert" as convert; | 5 import "dart:convert" as convert; |
7 | 6 |
8 import 'package:http/http.dart' as http; | 7 import 'package:http/http.dart' as http; |
9 import 'package:http/testing.dart' as http_testing; | |
10 import 'package:test/test.dart' as unittest; | 8 import 'package:test/test.dart' as unittest; |
11 | 9 |
12 import 'package:googleapis/oauth2/v2.dart' as api; | 10 import 'package:googleapis/oauth2/v2.dart' as api; |
13 | 11 |
14 class HttpServerMock extends http.BaseClient { | 12 class HttpServerMock extends http.BaseClient { |
15 core.Function _callback; | 13 core.Function _callback; |
16 core.bool _expectJson; | 14 core.bool _expectJson; |
17 | 15 |
18 void register(core.Function callback, core.bool expectJson) { | 16 void register(core.Function callback, core.bool expectJson) { |
19 _callback = callback; | 17 _callback = callback; |
20 _expectJson = expectJson; | 18 _expectJson = expectJson; |
21 } | 19 } |
22 | 20 |
23 async.Future<http.StreamedResponse> send(http.BaseRequest request) { | 21 async.Future<http.StreamedResponse> send(http.BaseRequest request) { |
24 if (_expectJson) { | 22 if (_expectJson) { |
25 return request.finalize() | 23 return request |
| 24 .finalize() |
26 .transform(convert.UTF8.decoder) | 25 .transform(convert.UTF8.decoder) |
27 .join('') | 26 .join('') |
28 .then((core.String jsonString) { | 27 .then((core.String jsonString) { |
29 if (jsonString.isEmpty) { | 28 if (jsonString.isEmpty) { |
30 return _callback(request, null); | 29 return _callback(request, null); |
31 } else { | 30 } else { |
32 return _callback(request, convert.JSON.decode(jsonString)); | 31 return _callback(request, convert.JSON.decode(jsonString)); |
33 } | 32 } |
34 }); | 33 }); |
35 } else { | 34 } else { |
36 var stream = request.finalize(); | 35 var stream = request.finalize(); |
37 if (stream == null) { | 36 if (stream == null) { |
38 return _callback(request, []); | 37 return _callback(request, []); |
39 } else { | 38 } else { |
40 return stream.toBytes().then((data) { | 39 return stream.toBytes().then((data) { |
41 return _callback(request, data); | 40 return _callback(request, data); |
42 }); | 41 }); |
43 } | 42 } |
44 } | 43 } |
45 } | 44 } |
46 } | 45 } |
47 | 46 |
48 http.StreamedResponse stringResponse( | 47 http.StreamedResponse stringResponse(core.int status, |
49 core.int status, core.Map<core.String, core.String> headers, core.String bod
y) { | 48 core.Map<core.String, core.String> headers, core.String body) { |
50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); | 49 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); |
51 return new http.StreamedResponse(stream, status, headers: headers); | 50 return new http.StreamedResponse(stream, status, headers: headers); |
52 } | 51 } |
53 | 52 |
54 core.int buildCounterJwkKeys = 0; | 53 core.int buildCounterJwkKeys = 0; |
55 buildJwkKeys() { | 54 buildJwkKeys() { |
56 var o = new api.JwkKeys(); | 55 var o = new api.JwkKeys(); |
57 buildCounterJwkKeys++; | 56 buildCounterJwkKeys++; |
58 if (buildCounterJwkKeys < 3) { | 57 if (buildCounterJwkKeys < 3) { |
59 o.alg = "foo"; | 58 o.alg = "foo"; |
(...skipping 13 matching lines...) Expand all Loading... |
73 unittest.expect(o.alg, unittest.equals('foo')); | 72 unittest.expect(o.alg, unittest.equals('foo')); |
74 unittest.expect(o.e, unittest.equals('foo')); | 73 unittest.expect(o.e, unittest.equals('foo')); |
75 unittest.expect(o.kid, unittest.equals('foo')); | 74 unittest.expect(o.kid, unittest.equals('foo')); |
76 unittest.expect(o.kty, unittest.equals('foo')); | 75 unittest.expect(o.kty, unittest.equals('foo')); |
77 unittest.expect(o.n, unittest.equals('foo')); | 76 unittest.expect(o.n, unittest.equals('foo')); |
78 unittest.expect(o.use, unittest.equals('foo')); | 77 unittest.expect(o.use, unittest.equals('foo')); |
79 } | 78 } |
80 buildCounterJwkKeys--; | 79 buildCounterJwkKeys--; |
81 } | 80 } |
82 | 81 |
83 buildUnnamed2516() { | 82 buildUnnamed2503() { |
84 var o = new core.List<api.JwkKeys>(); | 83 var o = new core.List<api.JwkKeys>(); |
85 o.add(buildJwkKeys()); | 84 o.add(buildJwkKeys()); |
86 o.add(buildJwkKeys()); | 85 o.add(buildJwkKeys()); |
87 return o; | 86 return o; |
88 } | 87 } |
89 | 88 |
90 checkUnnamed2516(core.List<api.JwkKeys> o) { | 89 checkUnnamed2503(core.List<api.JwkKeys> o) { |
91 unittest.expect(o, unittest.hasLength(2)); | 90 unittest.expect(o, unittest.hasLength(2)); |
92 checkJwkKeys(o[0]); | 91 checkJwkKeys(o[0]); |
93 checkJwkKeys(o[1]); | 92 checkJwkKeys(o[1]); |
94 } | 93 } |
95 | 94 |
96 core.int buildCounterJwk = 0; | 95 core.int buildCounterJwk = 0; |
97 buildJwk() { | 96 buildJwk() { |
98 var o = new api.Jwk(); | 97 var o = new api.Jwk(); |
99 buildCounterJwk++; | 98 buildCounterJwk++; |
100 if (buildCounterJwk < 3) { | 99 if (buildCounterJwk < 3) { |
101 o.keys = buildUnnamed2516(); | 100 o.keys = buildUnnamed2503(); |
102 } | 101 } |
103 buildCounterJwk--; | 102 buildCounterJwk--; |
104 return o; | 103 return o; |
105 } | 104 } |
106 | 105 |
107 checkJwk(api.Jwk o) { | 106 checkJwk(api.Jwk o) { |
108 buildCounterJwk++; | 107 buildCounterJwk++; |
109 if (buildCounterJwk < 3) { | 108 if (buildCounterJwk < 3) { |
110 checkUnnamed2516(o.keys); | 109 checkUnnamed2503(o.keys); |
111 } | 110 } |
112 buildCounterJwk--; | 111 buildCounterJwk--; |
113 } | 112 } |
114 | 113 |
115 core.int buildCounterTokeninfo = 0; | 114 core.int buildCounterTokeninfo = 0; |
116 buildTokeninfo() { | 115 buildTokeninfo() { |
117 var o = new api.Tokeninfo(); | 116 var o = new api.Tokeninfo(); |
118 buildCounterTokeninfo++; | 117 buildCounterTokeninfo++; |
119 if (buildCounterTokeninfo < 3) { | 118 if (buildCounterTokeninfo < 3) { |
120 o.accessType = "foo"; | 119 o.accessType = "foo"; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 unittest.expect(o.id, unittest.equals('foo')); | 178 unittest.expect(o.id, unittest.equals('foo')); |
180 unittest.expect(o.link, unittest.equals('foo')); | 179 unittest.expect(o.link, unittest.equals('foo')); |
181 unittest.expect(o.locale, unittest.equals('foo')); | 180 unittest.expect(o.locale, unittest.equals('foo')); |
182 unittest.expect(o.name, unittest.equals('foo')); | 181 unittest.expect(o.name, unittest.equals('foo')); |
183 unittest.expect(o.picture, unittest.equals('foo')); | 182 unittest.expect(o.picture, unittest.equals('foo')); |
184 unittest.expect(o.verifiedEmail, unittest.isTrue); | 183 unittest.expect(o.verifiedEmail, unittest.isTrue); |
185 } | 184 } |
186 buildCounterUserinfoplus--; | 185 buildCounterUserinfoplus--; |
187 } | 186 } |
188 | 187 |
189 | |
190 main() { | 188 main() { |
191 unittest.group("obj-schema-JwkKeys", () { | 189 unittest.group("obj-schema-JwkKeys", () { |
192 unittest.test("to-json--from-json", () { | 190 unittest.test("to-json--from-json", () { |
193 var o = buildJwkKeys(); | 191 var o = buildJwkKeys(); |
194 var od = new api.JwkKeys.fromJson(o.toJson()); | 192 var od = new api.JwkKeys.fromJson(o.toJson()); |
195 checkJwkKeys(od); | 193 checkJwkKeys(od); |
196 }); | 194 }); |
197 }); | 195 }); |
198 | 196 |
199 | |
200 unittest.group("obj-schema-Jwk", () { | 197 unittest.group("obj-schema-Jwk", () { |
201 unittest.test("to-json--from-json", () { | 198 unittest.test("to-json--from-json", () { |
202 var o = buildJwk(); | 199 var o = buildJwk(); |
203 var od = new api.Jwk.fromJson(o.toJson()); | 200 var od = new api.Jwk.fromJson(o.toJson()); |
204 checkJwk(od); | 201 checkJwk(od); |
205 }); | 202 }); |
206 }); | 203 }); |
207 | 204 |
208 | |
209 unittest.group("obj-schema-Tokeninfo", () { | 205 unittest.group("obj-schema-Tokeninfo", () { |
210 unittest.test("to-json--from-json", () { | 206 unittest.test("to-json--from-json", () { |
211 var o = buildTokeninfo(); | 207 var o = buildTokeninfo(); |
212 var od = new api.Tokeninfo.fromJson(o.toJson()); | 208 var od = new api.Tokeninfo.fromJson(o.toJson()); |
213 checkTokeninfo(od); | 209 checkTokeninfo(od); |
214 }); | 210 }); |
215 }); | 211 }); |
216 | 212 |
217 | |
218 unittest.group("obj-schema-Userinfoplus", () { | 213 unittest.group("obj-schema-Userinfoplus", () { |
219 unittest.test("to-json--from-json", () { | 214 unittest.test("to-json--from-json", () { |
220 var o = buildUserinfoplus(); | 215 var o = buildUserinfoplus(); |
221 var od = new api.Userinfoplus.fromJson(o.toJson()); | 216 var od = new api.Userinfoplus.fromJson(o.toJson()); |
222 checkUserinfoplus(od); | 217 checkUserinfoplus(od); |
223 }); | 218 }); |
224 }); | 219 }); |
225 | 220 |
226 | |
227 unittest.group("resource-Oauth2Api", () { | 221 unittest.group("resource-Oauth2Api", () { |
228 unittest.test("method--getCertForOpenIdConnect", () { | 222 unittest.test("method--getCertForOpenIdConnect", () { |
229 | |
230 var mock = new HttpServerMock(); | 223 var mock = new HttpServerMock(); |
231 api.Oauth2Api res = new api.Oauth2Api(mock); | 224 api.Oauth2Api res = new api.Oauth2Api(mock); |
232 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 225 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
233 var path = (req.url).path; | 226 var path = (req.url).path; |
234 var pathOffset = 0; | 227 var pathOffset = 0; |
235 var index; | 228 var index; |
236 var subPart; | 229 var subPart; |
237 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 230 unittest.expect( |
| 231 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
238 pathOffset += 1; | 232 pathOffset += 1; |
239 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq
uals("oauth2/v2/certs")); | 233 unittest.expect(path.substring(pathOffset, pathOffset + 15), |
| 234 unittest.equals("oauth2/v2/certs")); |
240 pathOffset += 15; | 235 pathOffset += 15; |
241 | 236 |
242 var query = (req.url).query; | 237 var query = (req.url).query; |
243 var queryOffset = 0; | 238 var queryOffset = 0; |
244 var queryMap = {}; | 239 var queryMap = {}; |
245 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 240 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
246 parseBool(n) { | 241 parseBool(n) { |
247 if (n == "true") return true; | 242 if (n == "true") return true; |
248 if (n == "false") return false; | 243 if (n == "false") return false; |
249 if (n == null) return null; | 244 if (n == null) return null; |
250 throw new core.ArgumentError("Invalid boolean: $n"); | 245 throw new core.ArgumentError("Invalid boolean: $n"); |
251 } | 246 } |
| 247 |
252 if (query.length > 0) { | 248 if (query.length > 0) { |
253 for (var part in query.split("&")) { | 249 for (var part in query.split("&")) { |
254 var keyvalue = part.split("="); | 250 var keyvalue = part.split("="); |
255 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 251 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 252 core.Uri.decodeQueryComponent(keyvalue[1])); |
256 } | 253 } |
257 } | 254 } |
258 | 255 |
259 | |
260 var h = { | 256 var h = { |
261 "content-type" : "application/json; charset=utf-8", | 257 "content-type": "application/json; charset=utf-8", |
262 }; | 258 }; |
263 var resp = convert.JSON.encode(buildJwk()); | 259 var resp = convert.JSON.encode(buildJwk()); |
264 return new async.Future.value(stringResponse(200, h, resp)); | 260 return new async.Future.value(stringResponse(200, h, resp)); |
265 }), true); | 261 }), true); |
266 res.getCertForOpenIdConnect().then(unittest.expectAsync1(((api.Jwk respons
e) { | 262 res |
| 263 .getCertForOpenIdConnect() |
| 264 .then(unittest.expectAsync1(((api.Jwk response) { |
267 checkJwk(response); | 265 checkJwk(response); |
268 }))); | 266 }))); |
269 }); | 267 }); |
270 | 268 |
271 unittest.test("method--tokeninfo", () { | 269 unittest.test("method--tokeninfo", () { |
272 | |
273 var mock = new HttpServerMock(); | 270 var mock = new HttpServerMock(); |
274 api.Oauth2Api res = new api.Oauth2Api(mock); | 271 api.Oauth2Api res = new api.Oauth2Api(mock); |
275 var arg_accessToken = "foo"; | 272 var arg_accessToken = "foo"; |
276 var arg_idToken = "foo"; | 273 var arg_idToken = "foo"; |
277 var arg_tokenHandle = "foo"; | 274 var arg_tokenHandle = "foo"; |
278 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 275 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
279 var path = (req.url).path; | 276 var path = (req.url).path; |
280 var pathOffset = 0; | 277 var pathOffset = 0; |
281 var index; | 278 var index; |
282 var subPart; | 279 var subPart; |
283 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 280 unittest.expect( |
| 281 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
284 pathOffset += 1; | 282 pathOffset += 1; |
285 unittest.expect(path.substring(pathOffset, pathOffset + 19), unittest.eq
uals("oauth2/v2/tokeninfo")); | 283 unittest.expect(path.substring(pathOffset, pathOffset + 19), |
| 284 unittest.equals("oauth2/v2/tokeninfo")); |
286 pathOffset += 19; | 285 pathOffset += 19; |
287 | 286 |
288 var query = (req.url).query; | 287 var query = (req.url).query; |
289 var queryOffset = 0; | 288 var queryOffset = 0; |
290 var queryMap = {}; | 289 var queryMap = {}; |
291 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 290 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
292 parseBool(n) { | 291 parseBool(n) { |
293 if (n == "true") return true; | 292 if (n == "true") return true; |
294 if (n == "false") return false; | 293 if (n == "false") return false; |
295 if (n == null) return null; | 294 if (n == null) return null; |
296 throw new core.ArgumentError("Invalid boolean: $n"); | 295 throw new core.ArgumentError("Invalid boolean: $n"); |
297 } | 296 } |
| 297 |
298 if (query.length > 0) { | 298 if (query.length > 0) { |
299 for (var part in query.split("&")) { | 299 for (var part in query.split("&")) { |
300 var keyvalue = part.split("="); | 300 var keyvalue = part.split("="); |
301 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 301 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 302 core.Uri.decodeQueryComponent(keyvalue[1])); |
302 } | 303 } |
303 } | 304 } |
304 unittest.expect(queryMap["access_token"].first, unittest.equals(arg_acce
ssToken)); | 305 unittest.expect( |
305 unittest.expect(queryMap["id_token"].first, unittest.equals(arg_idToken)
); | 306 queryMap["access_token"].first, unittest.equals(arg_accessToken)); |
306 unittest.expect(queryMap["token_handle"].first, unittest.equals(arg_toke
nHandle)); | 307 unittest.expect( |
307 | 308 queryMap["id_token"].first, unittest.equals(arg_idToken)); |
| 309 unittest.expect( |
| 310 queryMap["token_handle"].first, unittest.equals(arg_tokenHandle)); |
308 | 311 |
309 var h = { | 312 var h = { |
310 "content-type" : "application/json; charset=utf-8", | 313 "content-type": "application/json; charset=utf-8", |
311 }; | 314 }; |
312 var resp = convert.JSON.encode(buildTokeninfo()); | 315 var resp = convert.JSON.encode(buildTokeninfo()); |
313 return new async.Future.value(stringResponse(200, h, resp)); | 316 return new async.Future.value(stringResponse(200, h, resp)); |
314 }), true); | 317 }), true); |
315 res.tokeninfo(accessToken: arg_accessToken, idToken: arg_idToken, tokenHan
dle: arg_tokenHandle).then(unittest.expectAsync1(((api.Tokeninfo response) { | 318 res |
| 319 .tokeninfo( |
| 320 accessToken: arg_accessToken, |
| 321 idToken: arg_idToken, |
| 322 tokenHandle: arg_tokenHandle) |
| 323 .then(unittest.expectAsync1(((api.Tokeninfo response) { |
316 checkTokeninfo(response); | 324 checkTokeninfo(response); |
317 }))); | 325 }))); |
318 }); | 326 }); |
319 | |
320 }); | 327 }); |
321 | 328 |
322 | |
323 unittest.group("resource-UserinfoResourceApi", () { | 329 unittest.group("resource-UserinfoResourceApi", () { |
324 unittest.test("method--get", () { | 330 unittest.test("method--get", () { |
325 | |
326 var mock = new HttpServerMock(); | 331 var mock = new HttpServerMock(); |
327 api.UserinfoResourceApi res = new api.Oauth2Api(mock).userinfo; | 332 api.UserinfoResourceApi res = new api.Oauth2Api(mock).userinfo; |
328 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 333 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
329 var path = (req.url).path; | 334 var path = (req.url).path; |
330 var pathOffset = 0; | 335 var pathOffset = 0; |
331 var index; | 336 var index; |
332 var subPart; | 337 var subPart; |
333 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 338 unittest.expect( |
| 339 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
334 pathOffset += 1; | 340 pathOffset += 1; |
335 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq
uals("oauth2/v2/userinfo")); | 341 unittest.expect(path.substring(pathOffset, pathOffset + 18), |
| 342 unittest.equals("oauth2/v2/userinfo")); |
336 pathOffset += 18; | 343 pathOffset += 18; |
337 | 344 |
338 var query = (req.url).query; | 345 var query = (req.url).query; |
339 var queryOffset = 0; | 346 var queryOffset = 0; |
340 var queryMap = {}; | 347 var queryMap = {}; |
341 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 348 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
342 parseBool(n) { | 349 parseBool(n) { |
343 if (n == "true") return true; | 350 if (n == "true") return true; |
344 if (n == "false") return false; | 351 if (n == "false") return false; |
345 if (n == null) return null; | 352 if (n == null) return null; |
346 throw new core.ArgumentError("Invalid boolean: $n"); | 353 throw new core.ArgumentError("Invalid boolean: $n"); |
347 } | 354 } |
| 355 |
348 if (query.length > 0) { | 356 if (query.length > 0) { |
349 for (var part in query.split("&")) { | 357 for (var part in query.split("&")) { |
350 var keyvalue = part.split("="); | 358 var keyvalue = part.split("="); |
351 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 359 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 360 core.Uri.decodeQueryComponent(keyvalue[1])); |
352 } | 361 } |
353 } | 362 } |
354 | 363 |
355 | |
356 var h = { | 364 var h = { |
357 "content-type" : "application/json; charset=utf-8", | 365 "content-type": "application/json; charset=utf-8", |
358 }; | 366 }; |
359 var resp = convert.JSON.encode(buildUserinfoplus()); | 367 var resp = convert.JSON.encode(buildUserinfoplus()); |
360 return new async.Future.value(stringResponse(200, h, resp)); | 368 return new async.Future.value(stringResponse(200, h, resp)); |
361 }), true); | 369 }), true); |
362 res.get().then(unittest.expectAsync1(((api.Userinfoplus response) { | 370 res.get().then(unittest.expectAsync1(((api.Userinfoplus response) { |
363 checkUserinfoplus(response); | 371 checkUserinfoplus(response); |
364 }))); | 372 }))); |
365 }); | 373 }); |
366 | |
367 }); | 374 }); |
368 | 375 |
369 | |
370 unittest.group("resource-UserinfoV2MeResourceApi", () { | 376 unittest.group("resource-UserinfoV2MeResourceApi", () { |
371 unittest.test("method--get", () { | 377 unittest.test("method--get", () { |
372 | |
373 var mock = new HttpServerMock(); | 378 var mock = new HttpServerMock(); |
374 api.UserinfoV2MeResourceApi res = new api.Oauth2Api(mock).userinfo.v2.me; | 379 api.UserinfoV2MeResourceApi res = new api.Oauth2Api(mock).userinfo.v2.me; |
375 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 380 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
376 var path = (req.url).path; | 381 var path = (req.url).path; |
377 var pathOffset = 0; | 382 var pathOffset = 0; |
378 var index; | 383 var index; |
379 var subPart; | 384 var subPart; |
380 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 385 unittest.expect( |
| 386 path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
381 pathOffset += 1; | 387 pathOffset += 1; |
382 unittest.expect(path.substring(pathOffset, pathOffset + 14), unittest.eq
uals("userinfo/v2/me")); | 388 unittest.expect(path.substring(pathOffset, pathOffset + 14), |
| 389 unittest.equals("userinfo/v2/me")); |
383 pathOffset += 14; | 390 pathOffset += 14; |
384 | 391 |
385 var query = (req.url).query; | 392 var query = (req.url).query; |
386 var queryOffset = 0; | 393 var queryOffset = 0; |
387 var queryMap = {}; | 394 var queryMap = {}; |
388 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 395 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
389 parseBool(n) { | 396 parseBool(n) { |
390 if (n == "true") return true; | 397 if (n == "true") return true; |
391 if (n == "false") return false; | 398 if (n == "false") return false; |
392 if (n == null) return null; | 399 if (n == null) return null; |
393 throw new core.ArgumentError("Invalid boolean: $n"); | 400 throw new core.ArgumentError("Invalid boolean: $n"); |
394 } | 401 } |
| 402 |
395 if (query.length > 0) { | 403 if (query.length > 0) { |
396 for (var part in query.split("&")) { | 404 for (var part in query.split("&")) { |
397 var keyvalue = part.split("="); | 405 var keyvalue = part.split("="); |
398 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 406 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| 407 core.Uri.decodeQueryComponent(keyvalue[1])); |
399 } | 408 } |
400 } | 409 } |
401 | 410 |
402 | |
403 var h = { | 411 var h = { |
404 "content-type" : "application/json; charset=utf-8", | 412 "content-type": "application/json; charset=utf-8", |
405 }; | 413 }; |
406 var resp = convert.JSON.encode(buildUserinfoplus()); | 414 var resp = convert.JSON.encode(buildUserinfoplus()); |
407 return new async.Future.value(stringResponse(200, h, resp)); | 415 return new async.Future.value(stringResponse(200, h, resp)); |
408 }), true); | 416 }), true); |
409 res.get().then(unittest.expectAsync1(((api.Userinfoplus response) { | 417 res.get().then(unittest.expectAsync1(((api.Userinfoplus response) { |
410 checkUserinfoplus(response); | 418 checkUserinfoplus(response); |
411 }))); | 419 }))); |
412 }); | 420 }); |
413 | |
414 }); | 421 }); |
415 | |
416 | |
417 } | 422 } |
418 | |
OLD | NEW |