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

Side by Side Diff: tests/standalone/io/web_socket_test.dart

Issue 1319703002: Breaking Change: merge BoringSSL branch into master (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
OLDNEW
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 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "dart:async"; 10 import "dart:async";
11 import "dart:convert"; 11 import "dart:convert";
12 import "dart:io"; 12 import "dart:io";
13 import "dart:typed_data"; 13 import "dart:typed_data";
14 14
15 import "package:async_helper/async_helper.dart"; 15 import "package:async_helper/async_helper.dart";
16 import "package:crypto/crypto.dart"; 16 import "package:crypto/crypto.dart";
17 import "package:expect/expect.dart"; 17 import "package:expect/expect.dart";
18 import "package:path/path.dart"; 18 import "package:path/path.dart";
19 19
20 const WEB_SOCKET_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; 20 const WEB_SOCKET_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
21 21
22 const String CERT_NAME = 'localhost_cert';
23 const String HOST_NAME = 'localhost'; 22 const String HOST_NAME = 'localhost';
24 23
24 String localFile(path) => Platform.script.resolve(path).toFilePath();
25
26 SecurityContext serverContext = new SecurityContext()
27 ..useCertificateChain(localFile('certificates/server_chain.pem'))
28 ..usePrivateKey(localFile('certificates/server_key.pem'),
29 password: 'dartdart');
30
31 SecurityContext clientContext = new SecurityContext()
32 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem'));
33
25 /** 34 /**
26 * A SecurityConfiguration lets us run the tests over HTTP or HTTPS. 35 * A SecurityConfiguration lets us run the tests over HTTP or HTTPS.
27 */ 36 */
28 class SecurityConfiguration { 37 class SecurityConfiguration {
29 final bool secure; 38 final bool secure;
30 39
31 SecurityConfiguration({bool this.secure}); 40 SecurityConfiguration({bool this.secure});
32 41
33 Future<HttpServer> createServer({int backlog: 0}) => 42 Future<HttpServer> createServer({int backlog: 0}) =>
34 secure ? HttpServer.bindSecure(HOST_NAME, 43 secure ? HttpServer.bindSecure(HOST_NAME,
35 0, 44 0,
36 backlog: backlog, 45 serverContext,
37 certificateName: CERT_NAME) 46 backlog: backlog)
38 : HttpServer.bind(HOST_NAME, 47 : HttpServer.bind(HOST_NAME,
39 0, 48 0,
40 backlog: backlog); 49 backlog: backlog);
41 50
42 Future<WebSocket> createClient(int port) => 51 Future<WebSocket> createClient(int port) =>
52 // TODO(whesse): Add client context argument to WebSocket.connect
43 WebSocket.connect('${secure ? "wss" : "ws"}://$HOST_NAME:$port/'); 53 WebSocket.connect('${secure ? "wss" : "ws"}://$HOST_NAME:$port/');
44 54
45 checkCloseStatus(webSocket, closeStatus, closeReason) { 55 checkCloseStatus(webSocket, closeStatus, closeReason) {
46 Expect.equals(closeStatus == null ? WebSocketStatus.NO_STATUS_RECEIVED 56 Expect.equals(closeStatus == null ? WebSocketStatus.NO_STATUS_RECEIVED
47 : closeStatus, webSocket.closeCode); 57 : closeStatus, webSocket.closeCode);
48 Expect.equals(closeReason == null ? "" 58 Expect.equals(closeReason == null ? ""
49 : closeReason, webSocket.closeReason); 59 : closeReason, webSocket.closeReason);
50 } 60 }
51 61
52 void testRequestResponseClientCloses(int totalConnections, 62 void testRequestResponseClientCloses(int totalConnections,
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 testUsePOST(); 584 testUsePOST();
575 testConnections(10, 3002, "Got tired"); 585 testConnections(10, 3002, "Got tired");
576 testIndividualUpgrade(5); 586 testIndividualUpgrade(5);
577 testFromUpgradedSocket(); 587 testFromUpgradedSocket();
578 testAdditionalHeaders(); 588 testAdditionalHeaders();
579 testBasicAuthentication(); 589 testBasicAuthentication();
580 } 590 }
581 } 591 }
582 592
583 593
584 void initializeSSL() {
585 var testPkcertDatabase = Platform.script.resolve('pkcert').toFilePath();
586 SecureSocket.initialize(database: testPkcertDatabase,
587 password: "dartdart");
588 }
589
590
591 main() { 594 main() {
592 new SecurityConfiguration(secure: false).runTests(); 595 new SecurityConfiguration(secure: false).runTests();
593 initializeSSL(); 596 // TODO(whesse): Make WebSocket.connect() take an optional context: parameter.
594 new SecurityConfiguration(secure: true).runTests(); 597 // new SecurityConfiguration(secure: true).runTests();
595 } 598 }
OLDNEW
« no previous file with comments | « tests/standalone/io/web_socket_protocol_processor_test.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698