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

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

Issue 1665433002: Adds SecurityContext.setTrustedCertificatesBytes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Adds MemBIOScope Created 4 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 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:io"; 11 import "dart:io";
12 12
13 import "package:async_helper/async_helper.dart"; 13 import "package:async_helper/async_helper.dart";
14 import "package:expect/expect.dart"; 14 import "package:expect/expect.dart";
15 15
16 InternetAddress HOST; 16 InternetAddress HOST;
17 String localFile(path) => Platform.script.resolve(path).toFilePath(); 17 String localFile(path) => Platform.script.resolve(path).toFilePath();
18 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); 18 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync();
19 19
20 SecurityContext serverContext = new SecurityContext() 20 SecurityContext serverContext = new SecurityContext()
21 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem')) 21 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem'))
22 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'), 22 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'),
23 password: 'dartdart'); 23 password: 'dartdart');
24 24
25 SecurityContext clientContext = new SecurityContext() 25 SecurityContext clientContext = new SecurityContext()
26 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); 26 ..setTrustedCertificatesBytes(
27 readLocalFile('certificates/trusted_certs.pem'));
27 28
28 void testSimpleBind() { 29 void testSimpleBind() {
29 asyncStart(); 30 asyncStart();
30 RawSecureServerSocket.bind(HOST, 0, serverContext).then((s) { 31 RawSecureServerSocket.bind(HOST, 0, serverContext).then((s) {
31 Expect.isTrue(s.port > 0); 32 Expect.isTrue(s.port > 0);
32 s.close(); 33 s.close();
33 asyncEnd(); 34 asyncEnd();
34 }); 35 });
35 } 36 }
36 37
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 runTests() { 569 runTests() {
569 testSimpleBind(); 570 testSimpleBind();
570 testInvalidBind(); 571 testInvalidBind();
571 testSimpleConnect(); 572 testSimpleConnect();
572 SecurityContext context = new SecurityContext(); 573 SecurityContext context = new SecurityContext();
573 testSimpleConnectFail(context, false); 574 testSimpleConnectFail(context, false);
574 testSimpleConnectFail(context, true); 575 testSimpleConnectFail(context, true);
575 var chain = 576 var chain =
576 Platform.script.resolve('certificates/untrusted_server_chain.pem') 577 Platform.script.resolve('certificates/untrusted_server_chain.pem')
577 .toFilePath(); 578 .toFilePath();
578 context.useCertificateChain(chain); 579 context.useCertificateChainSync(chain);
579 testSimpleConnectFail(context, false); 580 testSimpleConnectFail(context, false);
580 testSimpleConnectFail(context, true); 581 testSimpleConnectFail(context, true);
581 var key = 582 var key =
582 Platform.script.resolve('certificates/untrusted_server_key.pem') 583 Platform.script.resolve('certificates/untrusted_server_key.pem')
583 .toFilePath(); 584 .toFilePath();
584 context.usePrivateKey(key, password: 'dartdart'); 585 context.usePrivateKeySync(key, password: 'dartdart');
585 testSimpleConnectFail(context, false); 586 testSimpleConnectFail(context, false);
586 testSimpleConnectFail(context, true); 587 testSimpleConnectFail(context, true);
587 testServerListenAfterConnect(); 588 testServerListenAfterConnect();
588 589
589 testSimpleReadWrite(listenSecure: true, 590 testSimpleReadWrite(listenSecure: true,
590 connectSecure: true, 591 connectSecure: true,
591 handshakeBeforeSecure: false, 592 handshakeBeforeSecure: false,
592 postponeSecure: false, 593 postponeSecure: false,
593 dropReads: false); 594 dropReads: false);
594 testSimpleReadWrite(listenSecure: true, 595 testSimpleReadWrite(listenSecure: true,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 testSimpleReadWrite(listenSecure: false, 627 testSimpleReadWrite(listenSecure: false,
627 connectSecure: false, 628 connectSecure: false,
628 handshakeBeforeSecure: true, 629 handshakeBeforeSecure: true,
629 postponeSecure: true, 630 postponeSecure: true,
630 dropReads: true); 631 dropReads: true);
631 testPausedSecuringSubscription(false, false); 632 testPausedSecuringSubscription(false, false);
632 testPausedSecuringSubscription(true, false); 633 testPausedSecuringSubscription(true, false);
633 testPausedSecuringSubscription(false, true); 634 testPausedSecuringSubscription(false, true);
634 testPausedSecuringSubscription(true, true); 635 testPausedSecuringSubscription(true, true);
635 } 636 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698