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

Unified Diff: tests/standalone/io/regress_21160_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, 4 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
Index: tests/standalone/io/regress_21160_test.dart
diff --git a/tests/standalone/io/regress_21160_test.dart b/tests/standalone/io/regress_21160_test.dart
index 69cbcf19df9853af9186cdbd9343f51d42274ffc..95ccfcaf112a8fc32c07b433ed78c33b1d93a5b7 100644
--- a/tests/standalone/io/regress_21160_test.dart
+++ b/tests/standalone/io/regress_21160_test.dart
@@ -10,6 +10,16 @@ import "dart:async";
import "dart:io";
import "dart:typed_data";
+String localFile(path) => Platform.script.resolve(path).toFilePath();
+
+SecurityContext serverContext = new SecurityContext()
+ ..useCertificateChain(localFile('certificates/server_chain.pem'))
+ ..usePrivateKey(localFile('certificates/server_key.pem'),
+ password: 'dartdart');
+
+SecurityContext clientContext = new SecurityContext()
+ ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem'));
+
// 10 KiB of i%256 data.
Uint8List DATA = new Uint8List.fromList(
new List.generate(10 * 1024, (i) => i % 256));
@@ -17,63 +27,54 @@ Uint8List DATA = new Uint8List.fromList(
Future<SecureServerSocket> startServer() {
return SecureServerSocket.bind("localhost",
0,
- 'localhost_cert').then((server) {
- server.listen((SecureSocket request) {
- request.drain().then((_) {
- request
- ..add(DATA)
- ..close();
- });
+ serverContext).then((server) {
+ server.listen((SecureSocket request) async {
+ await request.drain();
+ request..add(DATA)..close();
});
return server;
});
}
-void InitializeSSL() {
- var testPkcertDatabase = Platform.script.resolve('pkcert').toFilePath();
- SecureSocket.initialize(database: testPkcertDatabase,
- password: 'dartdart');
-}
-
-void main() {
- InitializeSSL();
-
+main() async {
asyncStart();
- startServer().then((SecureServerSocket server) {
- RawSecureSocket.connect("localhost", server.port).then((socket) {
- List<int> body = <int>[];
+ var server = await SecureServerSocket.bind("localhost", 0, serverContext);
+ server.listen((SecureSocket request) async {
+ await request.drain();
+ request..add(DATA)..close();
+ });
- // Close our end, since we're not sending data.
- socket.shutdown(SocketDirection.SEND);
+ var socket = await RawSecureSocket.connect("localhost",
+ server.port,
+ context: clientContext);
+ List<int> body = <int>[];
+ // Close our end, since we're not sending data.
+ socket.shutdown(SocketDirection.SEND);
- socket.listen((RawSocketEvent event) {
- switch (event) {
- case RawSocketEvent.READ:
- // NOTE: We have a very low prime number here. The internal
- // ring buffers will not have a size of 3. This means that
- // we'll reach the point where we would like to read 1/2 bytes
- // at the end and then wrap around and read the next 2/1 bytes.
- // [This will ensure we trigger the bug.]
- body.addAll(socket.read(3));
- break;
- case RawSocketEvent.WRITE:
- break;
- case RawSocketEvent.READ_CLOSED:
- break;
- default: throw "Unexpected event $event";
- }
- },
- onError: (e, _) {
- Expect.fail('Unexpected error: $e');
- },
- onDone: () {
- Expect.equals(body.length, DATA.length);
- for (int i = 0; i < body.length; i++) {
- Expect.equals(body[i], DATA[i]);
- }
- server.close();
- asyncEnd();
- });
- });
+ socket.listen((RawSocketEvent event) {
+ switch (event) {
+ case RawSocketEvent.READ:
+ // NOTE: We have a very low prime number here. The internal
+ // ring buffers will not have a size of 3. This means that
+ // we'll reach the point where we would like to read 1/2 bytes
+ // at the end and then wrap around and read the next 2/1 bytes.
+ // [This will ensure we trigger the bug.]
+ body.addAll(socket.read(3));
+ break;
+ case RawSocketEvent.WRITE:
+ break;
+ case RawSocketEvent.READ_CLOSED:
+ break;
+ default: throw "Unexpected event $event";
+ }
+ }, onError: (e, _) {
+ Expect.fail('Unexpected error: $e');
+ }, onDone: () {
+ Expect.equals(body.length, DATA.length);
+ for (int i = 0; i < body.length; i++) {
+ Expect.equals(body[i], DATA[i]);
+ }
+ server.close();
+ asyncEnd();
});
}
« no previous file with comments | « tests/standalone/io/raw_secure_socket_test.dart ('k') | tests/standalone/io/secure_bad_certificate_client.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698