Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: pkg/oauth2/test/utils_test.dart

Issue 11316325: Make the oauth2 lib handle OAuth2 401 errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/oauth2/test/client_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library utils_test;
6
7 import '../../unittest/lib/unittest.dart';
8 import '../lib/src/utils.dart';
9
10
11 void main() {
12 group('AuthenticateHeader', () {
13 test("parses a scheme", () {
14 var header = new AuthenticateHeader.parse('bearer');
15 expect(header.scheme, equals('bearer'));
16 expect(header.parameters, equals({}));
17 });
18
19 test("lower-cases the scheme", () {
20 var header = new AuthenticateHeader.parse('BeaRer');
21 expect(header.scheme, equals('bearer'));
22 expect(header.parameters, equals({}));
23 });
24
25 test("parses a scheme with trailing whitespace", () {
26 var header = new AuthenticateHeader.parse('bearer ');
27 expect(header.scheme, equals('bearer'));
28 expect(header.parameters, equals({}));
29 });
30
31 test("parses a scheme with one param", () {
32 var header = new AuthenticateHeader.parse('bearer foo="bar"');
33 expect(header.scheme, equals('bearer'));
34 expect(header.parameters, equals({'foo': 'bar'}));
35 });
36
37 test("parses a scheme with several params", () {
38 var header = new AuthenticateHeader.parse(
39 'bearer foo="bar", bar="baz" ,baz="qux"');
40 expect(header.scheme, equals('bearer'));
41 expect(header.parameters, equals({
42 'foo': 'bar',
43 'bar': 'baz',
44 'baz': 'qux'
45 }));
46 });
47
48 test("lower-cases parameter names but not values", () {
49 var header = new AuthenticateHeader.parse('bearer FoO="bAr"');
50 expect(header.scheme, equals('bearer'));
51 expect(header.parameters, equals({'foo': 'bAr'}));
52 });
53
54 test("allows empty values", () {
55 var header = new AuthenticateHeader.parse('bearer foo=""');
56 expect(header.scheme, equals('bearer'));
57 expect(header.parameters, equals({'foo': ''}));
58 });
59
60 test("won't parse an empty string", () {
61 expect(() => new AuthenticateHeader.parse(''),
62 throwsFormatException);
63 });
64
65 test("won't parse a token without a value", () {
66 expect(() => new AuthenticateHeader.parse('bearer foo'),
67 throwsFormatException);
68
69 expect(() => new AuthenticateHeader.parse('bearer foo='),
70 throwsFormatException);
71 });
72
73 test("won't parse a token without a value", () {
74 expect(() => new AuthenticateHeader.parse('bearer foo'),
75 throwsFormatException);
76
77 expect(() => new AuthenticateHeader.parse('bearer foo='),
78 throwsFormatException);
79 });
80
81 test("won't parse a trailing comma", () {
82 expect(() => new AuthenticateHeader.parse('bearer foo="bar",'),
83 throwsFormatException);
84 });
85
86 test("won't parse a multiple params without a comma", () {
87 expect(() => new AuthenticateHeader.parse('bearer foo="bar" bar="baz"'),
88 throwsFormatException);
89 });
90 });
91 }
OLDNEW
« no previous file with comments | « pkg/oauth2/test/client_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698