aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/ssl/tests
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-01-11 22:32:43 -0800
committerSteven Fackler <[email protected]>2016-01-11 22:36:58 -0800
commitfd6454f625bb7efde3772ae106180cc6ac7c02dd (patch)
tree1978bc0a58b1e4e01de56ae30e1bf8ce43f62695 /openssl/src/ssl/tests
parentMerge pull request #328 from Cyberunner23/PemRSA (diff)
downloadrust-openssl-fd6454f625bb7efde3772ae106180cc6ac7c02dd.tar.xz
rust-openssl-fd6454f625bb7efde3772ae106180cc6ac7c02dd.zip
Add stream panic propagation behind a nightly feature gate
Diffstat (limited to 'openssl/src/ssl/tests')
-rw-r--r--openssl/src/ssl/tests/mod.rs88
1 files changed, 88 insertions, 0 deletions
diff --git a/openssl/src/ssl/tests/mod.rs b/openssl/src/ssl/tests/mod.rs
index af3c005e..7bd39170 100644
--- a/openssl/src/ssl/tests/mod.rs
+++ b/openssl/src/ssl/tests/mod.rs
@@ -957,3 +957,91 @@ fn broken_try_clone_doesnt_crash() {
let stream1 = SslStream::connect(&context, inner).unwrap();
let _stream2 = stream1.try_clone().unwrap();
}
+
+#[test]
+#[should_panic(message = "blammo")]
+#[cfg(feature = "nightly")]
+fn write_panic() {
+ struct ExplodingStream(TcpStream);
+
+ impl Read for ExplodingStream {
+ fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
+ self.0.read(buf)
+ }
+ }
+
+ impl Write for ExplodingStream {
+ fn write(&mut self, _: &[u8]) -> io::Result<usize> {
+ panic!("blammo");
+ }
+
+ fn flush(&mut self) -> io::Result<()> {
+ self.0.flush()
+ }
+ }
+
+ let (_s, stream) = Server::new();
+ let stream = ExplodingStream(stream);
+
+ let ctx = SslContext::new(SslMethod::Sslv23).unwrap();
+ let _ = SslStream::connect(&ctx, stream);
+}
+
+#[test]
+#[should_panic(message = "blammo")]
+#[cfg(feature = "nightly")]
+fn read_panic() {
+ struct ExplodingStream(TcpStream);
+
+ impl Read for ExplodingStream {
+ fn read(&mut self, _: &mut [u8]) -> io::Result<usize> {
+ panic!("blammo");
+ }
+ }
+
+ impl Write for ExplodingStream {
+ fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+ self.0.write(buf)
+ }
+
+ fn flush(&mut self) -> io::Result<()> {
+ self.0.flush()
+ }
+ }
+
+ let (_s, stream) = Server::new();
+ let stream = ExplodingStream(stream);
+
+ let ctx = SslContext::new(SslMethod::Sslv23).unwrap();
+ let _ = SslStream::connect(&ctx, stream);
+}
+
+#[test]
+#[should_panic(message = "blammo")]
+#[cfg(feature = "nightly")]
+fn flush_panic() {
+ struct ExplodingStream(TcpStream);
+
+ impl Read for ExplodingStream {
+ fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
+ self.0.read(buf)
+ }
+ }
+
+ impl Write for ExplodingStream {
+ fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+ self.0.write(buf)
+ }
+
+ fn flush(&mut self) -> io::Result<()> {
+ panic!("blammo");
+ }
+ }
+
+ let (_s, stream) = Server::new();
+ let stream = ExplodingStream(stream);
+
+ let ctx = SslContext::new(SslMethod::Sslv23).unwrap();
+ let mut stream = SslStream::connect(&ctx, stream).unwrap();
+ let _ = stream.flush();
+}