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

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

Issue 1384533002: Add check for password length in SecurityContext. Check return values from BoringSSL functions, thr… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Improve code 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 side-by-side diff with in-line comments
Download patch
« runtime/bin/secure_socket.cc ('K') | « runtime/bin/secure_socket.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/security_context_argument_test.dart
diff --git a/tests/standalone/io/security_context_argument_test.dart b/tests/standalone/io/security_context_argument_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4309fb20974f94586aee688c450ca02efc481f74
--- /dev/null
+++ b/tests/standalone/io/security_context_argument_test.dart
@@ -0,0 +1,40 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+import "dart:io";
+
+String localFile(path) => Platform.script.resolve(path).toFilePath();
+
+bool printException(e) { print(e); return true; }
+bool argumentError(e) => e is ArgumentError;
+bool tlsException(e) => e is TlsException;
+
+void testUsePrivateKeyArguments() {
+ var c = new SecurityContext();
+ c.useCertificateChain(localFile('certificates/server_chain.pem'));
+ Expect.throws(() => c.usePrivateKey(
+ localFile('certificates/server_key.pem'), password: "dart" * 1000),
+ argumentError);
+ Expect.throws(() => c.usePrivateKey(
+ localFile('certificates/server_key.pem')),
+ tlsException);
+ Expect.throws(() => c.usePrivateKey(
+ localFile('certificates/server_key.pem'), password: "iHackSites"),
+ tlsException);
+ Expect.throws(() => c.usePrivateKey(
+ localFile('certificates/server_key_oops.pem'), password: "dartdart"),
+ tlsException);
+ Expect.throws(() => c.usePrivateKey(1), argumentError);
+ Expect.throws(() => c.usePrivateKey(null), argumentError);
+ Expect.throws(() => c.usePrivateKey(
+ localFile('certificates/server_key_oops.pem'), password: 3),
+ argumentError);
+ c.usePrivateKey(
+ localFile('certificates/server_key.pem'), password: "dartdart");
+}
+
+void main() {
+ testUsePrivateKeyArguments();
+}
« runtime/bin/secure_socket.cc ('K') | « runtime/bin/secure_socket.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698