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

Unified Diff: tests/standalone/io/web_socket_test.dart

Issue 897323002: Add support for user info on ws: and wss: URLs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 5 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/web_socket_test.dart
diff --git a/tests/standalone/io/web_socket_test.dart b/tests/standalone/io/web_socket_test.dart
index d9229b6e74f7893973b46248cd9e53abd06da164..97059042e1d5db5aa0b862adfd055ad70b0f6249 100644
--- a/tests/standalone/io/web_socket_test.dart
+++ b/tests/standalone/io/web_socket_test.dart
@@ -8,6 +8,7 @@
// VMOptions=--short_socket_read --short_socket_write
import "dart:async";
+import "dart:convert";
import "dart:io";
import "dart:typed_data";
@@ -452,9 +453,6 @@ class SecurityConfiguration {
var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/';
var headers = {'My-Header': 'my-value',
'My-Header-Multiple': ['my-value-1', 'my-value-2']};
- print(headers);
- print(headers['My-Header-Multiple'] is Iterable);
- print(headers['My-Header-Multiple'].length);
WebSocket.connect(url, headers: headers).then((websocket) {
return websocket.listen((message) {
Expect.equals("Hello", message);
@@ -468,6 +466,40 @@ class SecurityConfiguration {
}
+ void testBasicAuthentication() {
+ var userInfo = 'user:password';
+
+ asyncStart();
+ asyncStart();
+ createServer().then((server) {
+ server.listen((request) {
+ Expect.isTrue(WebSocketTransformer.isUpgradeRequest(request));
+ String auth =
+ CryptoUtils.bytesToBase64(UTF8.encode(userInfo));
+ Expect.equals('Basic $auth', request.headers['Authorization'][0]);
+ Expect.equals(1, request.headers['Authorization'].length);
+ WebSocketTransformer.upgrade(request).then((webSocket) {
+ webSocket.listen((_) { throw 'Unexpected'; },
+ onDone: () { asyncEnd(); });
+ webSocket.add("Hello");
+ });
+ });
+
+ var url =
+ '${secure ? "wss" : "ws"}://$userInfo@$HOST_NAME:${server.port}/';
+ WebSocket.connect(url).then((websocket) {
+ return websocket.listen((message) {
+ Expect.equals("Hello", message);
+ return websocket.close();
+ }).asFuture();
+ }).then((_) {
+ return server.close();
+ }).whenComplete(() {
+ asyncEnd();
+ });
+ });
+ }
+
void runTests() {
testRequestResponseClientCloses(2, null, null, 1);
testRequestResponseClientCloses(2, 3001, null, 2);
@@ -490,6 +522,7 @@ class SecurityConfiguration {
testIndividualUpgrade(5);
testFromUpgradedSocket();
testAdditionalHeaders();
+ testBasicAuthentication();
}
}
« no previous file with comments | « sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698