Skip to content

Commit

Permalink
Apply clippy suggestions in test code
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Oct 9, 2021
1 parent 31ea0f3 commit fc11ca2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
5 changes: 1 addition & 4 deletions examples/google.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ use std::sync::Arc;
use std::io::{stdout, Read, Write};
use std::net::TcpStream;

use rustls;
use rustls_native_certs;

fn main() {
let mut roots = rustls::RootCertStore::empty();
for cert in rustls_native_certs::load_native_certs().expect("could not load platform certs") {
Expand All @@ -22,7 +19,7 @@ fn main() {
rustls::ClientConnection::new(Arc::new(config), "google.com".try_into().unwrap()).unwrap();
let mut sock = TcpStream::connect("google.com:443").expect("cannot connect");
let mut tls = rustls::Stream::new(&mut conn, &mut sock);
tls.write(
tls.write_all(
concat!(
"GET / HTTP/1.1\r\n",
"Host: google.com\r\n",
Expand Down
31 changes: 15 additions & 16 deletions tests/compare_mozilla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use std::collections::HashMap;

use ring::io::der;
use untrusted;
use webpki::TrustAnchor;

fn stringify_x500name(subject: &[u8]) -> String {
Expand All @@ -19,30 +18,30 @@ fn stringify_x500name(subject: &[u8]) -> String {
.unwrap();
assert!(tag == 0x31); // sequence, constructed, context=1

let mut inner = untrusted::Reader::new(contents.into());
let mut inner = untrusted::Reader::new(contents);
let pair = der::expect_tag_and_get_value(&mut inner, der::Tag::Sequence)
.unwrap();

let mut pair = untrusted::Reader::new(pair.into());
let mut pair = untrusted::Reader::new(pair);
let oid = der::expect_tag_and_get_value(&mut pair, der::Tag::OID)
.unwrap();
let (valuety, value) = der::read_tag_and_get_value(&mut pair)
.unwrap();

let name = match oid.as_slice_less_safe() {
&[0x55, 0x04, 0x03] => "CN",
&[0x55, 0x04, 0x05] => "serialNumber",
&[0x55, 0x04, 0x06] => "C",
&[0x55, 0x04, 0x07] => "L",
&[0x55, 0x04, 0x08] => "ST",
&[0x55, 0x04, 0x09] => "STREET",
&[0x55, 0x04, 0x0a] => "O",
&[0x55, 0x04, 0x0b] => "OU",
&[0x55, 0x04, 0x11] => "postalCode",
&[0x55, 0x04, 0x61] => "organizationIdentifier",
&[0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x01, 0x19] => "domainComponent",
&[0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01] => "emailAddress",
_ => panic!("unhandled x500 attr {:?}", oid)
[0x55, 0x04, 0x03] => "CN",
[0x55, 0x04, 0x05] => "serialNumber",
[0x55, 0x04, 0x06] => "C",
[0x55, 0x04, 0x07] => "L",
[0x55, 0x04, 0x08] => "ST",
[0x55, 0x04, 0x09] => "STREET",
[0x55, 0x04, 0x0a] => "O",
[0x55, 0x04, 0x0b] => "OU",
[0x55, 0x04, 0x11] => "postalCode",
[0x55, 0x04, 0x61] => "organizationIdentifier",
[0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x01, 0x19] => "domainComponent",
[0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01] => "emailAddress",
_ => panic!("unhandled x500 attr {:?}", oid),
};

let str_value = match valuety {
Expand Down
5 changes: 1 addition & 4 deletions tests/smoketests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ use std::sync::Arc;
use std::io::{Read, Write};
use std::net::TcpStream;

use rustls;
use rustls_native_certs;

fn check_site(domain: &str) {
let mut roots = rustls::RootCertStore::empty();
for cert in rustls_native_certs::load_native_certs().unwrap() {
Expand All @@ -22,7 +19,7 @@ fn check_site(domain: &str) {
rustls::ClientConnection::new(Arc::new(config), domain.try_into().unwrap()).unwrap();
let mut sock = TcpStream::connect(format!("{}:443", domain)).unwrap();
let mut tls = rustls::Stream::new(&mut conn, &mut sock);
tls.write(
tls.write_all(
format!(
"GET / HTTP/1.1\r\n\
Host: {}\r\n\
Expand Down

0 comments on commit fc11ca2

Please sign in to comment.