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

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

Issue 812253002: Delete a bunch of packages that are now on GitHub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Un-delete http Created 6 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/utils.dart ('k') | pkg/path/CHANGELOG.md » ('j') | 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 'package:oauth2/src/utils.dart';
8 import 'package:unittest/unittest.dart';
9
10 void main() {
11 group('AuthenticateHeader', () {
12 test("parses a scheme", () {
13 var header = new AuthenticateHeader.parse('bearer');
14 expect(header.scheme, equals('bearer'));
15 expect(header.parameters, equals({}));
16 });
17
18 test("lower-cases the scheme", () {
19 var header = new AuthenticateHeader.parse('BeaRer');
20 expect(header.scheme, equals('bearer'));
21 expect(header.parameters, equals({}));
22 });
23
24 test("parses a scheme with trailing whitespace", () {
25 var header = new AuthenticateHeader.parse('bearer ');
26 expect(header.scheme, equals('bearer'));
27 expect(header.parameters, equals({}));
28 });
29
30 test("parses a scheme with one param", () {
31 var header = new AuthenticateHeader.parse('bearer foo="bar"');
32 expect(header.scheme, equals('bearer'));
33 expect(header.parameters, equals({'foo': 'bar'}));
34 });
35
36 test("parses a scheme with several params", () {
37 var header = new AuthenticateHeader.parse(
38 'bearer foo="bar", bar="baz" ,baz="qux"');
39 expect(header.scheme, equals('bearer'));
40 expect(header.parameters, equals({
41 'foo': 'bar',
42 'bar': 'baz',
43 'baz': 'qux'
44 }));
45 });
46
47 test("lower-cases parameter names but not values", () {
48 var header = new AuthenticateHeader.parse('bearer FoO="bAr"');
49 expect(header.scheme, equals('bearer'));
50 expect(header.parameters, equals({'foo': 'bAr'}));
51 });
52
53 test("allows empty values", () {
54 var header = new AuthenticateHeader.parse('bearer foo=""');
55 expect(header.scheme, equals('bearer'));
56 expect(header.parameters, equals({'foo': ''}));
57 });
58
59 test("won't parse an empty string", () {
60 expect(() => new AuthenticateHeader.parse(''),
61 throwsFormatException);
62 });
63
64 test("won't parse a token without a value", () {
65 expect(() => new AuthenticateHeader.parse('bearer foo'),
66 throwsFormatException);
67
68 expect(() => new AuthenticateHeader.parse('bearer foo='),
69 throwsFormatException);
70 });
71
72 test("won't parse a token without a value", () {
73 expect(() => new AuthenticateHeader.parse('bearer foo'),
74 throwsFormatException);
75
76 expect(() => new AuthenticateHeader.parse('bearer foo='),
77 throwsFormatException);
78 });
79
80 test("won't parse a trailing comma", () {
81 expect(() => new AuthenticateHeader.parse('bearer foo="bar",'),
82 throwsFormatException);
83 });
84
85 test("won't parse a multiple params without a comma", () {
86 expect(() => new AuthenticateHeader.parse('bearer foo="bar" bar="baz"'),
87 throwsFormatException);
88 });
89 });
90 }
OLDNEW
« no previous file with comments | « pkg/oauth2/test/utils.dart ('k') | pkg/path/CHANGELOG.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698