OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:crypto'; | 7 import 'dart:crypto'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 import 'dart:uri'; | 10 import 'dart:uri'; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 | 61 |
62 var response = request.response; | 62 var response = request.response; |
63 if (request.headers[HttpHeaders.AUTHORIZATION] != null) { | 63 if (request.headers[HttpHeaders.AUTHORIZATION] != null) { |
64 Expect.equals(1, request.headers[HttpHeaders.AUTHORIZATION].length); | 64 Expect.equals(1, request.headers[HttpHeaders.AUTHORIZATION].length); |
65 String authorization = | 65 String authorization = |
66 request.headers[HttpHeaders.AUTHORIZATION][0]; | 66 request.headers[HttpHeaders.AUTHORIZATION][0]; |
67 HeaderValue header = | 67 HeaderValue header = |
68 HeaderValue.parse( | 68 HeaderValue.parse( |
69 authorization, parameterSeparator: ","); | 69 authorization, parameterSeparator: ","); |
70 if (header.value == "basic") { | 70 if (header.value.toLowerCase() == "basic") { |
71 sendUnauthorizedResponse(response); | 71 sendUnauthorizedResponse(response); |
72 } else if (!useNextNonce && nonceCount == nonceStaleAfter) { | 72 } else if (!useNextNonce && nonceCount == nonceStaleAfter) { |
73 nonce = "87654321"; | 73 nonce = "87654321"; |
74 nonceCount = 0; | 74 nonceCount = 0; |
75 sendUnauthorizedResponse(response, stale: true); | 75 sendUnauthorizedResponse(response, stale: true); |
76 } else { | 76 } else { |
77 var uri = header.parameters["uri"]; | 77 var uri = header.parameters["uri"]; |
78 var qop = header.parameters["qop"]; | 78 var qop = header.parameters["qop"]; |
79 var cnonce = header.parameters["cnonce"]; | 79 var cnonce = header.parameters["cnonce"]; |
80 var nc = header.parameters["nc"]; | 80 var nc = header.parameters["nc"]; |
81 Expect.equals("digest", header.value); | 81 Expect.equals("digest", header.value.toLowerCase()); |
82 Expect.equals("dart", header.parameters["username"]); | 82 Expect.equals("dart", header.parameters["username"]); |
83 Expect.equals(realm, header.parameters["realm"]); | 83 Expect.equals(realm, header.parameters["realm"]); |
84 Expect.equals("MD5", header.parameters["algorithm"]); | 84 Expect.equals("MD5", header.parameters["algorithm"]); |
85 Expect.equals(nonce, header.parameters["nonce"]); | 85 Expect.equals(nonce, header.parameters["nonce"]); |
86 Expect.equals(request.uri.path, uri); | 86 Expect.equals(request.uri.path, uri); |
87 if (qop != null) { | 87 if (qop != null) { |
88 // A server qop of auth-int is downgraded to none by the client. | 88 // A server qop of auth-int is downgraded to none by the client. |
89 Expect.equals("auth", serverQop); | 89 Expect.equals("auth", serverQop); |
90 Expect.equals("auth", header.parameters["qop"]); | 90 Expect.equals("auth", header.parameters["qop"]); |
91 Expect.isNotNull(cnonce); | 91 Expect.isNotNull(cnonce); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 testAuthenticateCallback(null, null); | 384 testAuthenticateCallback(null, null); |
385 testAuthenticateCallback("MD5", null); | 385 testAuthenticateCallback("MD5", null); |
386 testAuthenticateCallback("MD5", "auth"); | 386 testAuthenticateCallback("MD5", "auth"); |
387 testAuthenticateCallback("MD5", "auth-int"); | 387 testAuthenticateCallback("MD5", "auth-int"); |
388 testStaleNonce(); | 388 testStaleNonce(); |
389 testNextNonce(); | 389 testNextNonce(); |
390 // These teste are not normally run. They can be used for locally | 390 // These teste are not normally run. They can be used for locally |
391 // testing with another web server (e.g. Apache). | 391 // testing with another web server (e.g. Apache). |
392 //testLocalServerDigest(); | 392 //testLocalServerDigest(); |
393 } | 393 } |
OLD | NEW |