Update hyper, rustls and yup-oauth2

I've switched to a new M1 laptop which couldn't build the old dependencies because the old ring library version doesn't compile on mac arm (but new version do). There's no way to update ring in isolation, so I've got to update the whole tree at once.
This commit is contained in:
Daniel Rodgers-Pryor
2021-02-01 23:29:25 +11:00
parent b88e1633ed
commit b8a66bc666
10 changed files with 477 additions and 520 deletions

View File

@@ -1,4 +1,10 @@
#![allow(dead_code, deprecated, unused_features, unused_variables, unused_imports)]
#![allow(
dead_code,
deprecated,
unused_features,
unused_variables,
unused_imports
)]
#[macro_use]
extern crate clap;
@@ -7,9 +13,9 @@ extern crate clap;
extern crate hyper;
extern crate mime;
extern crate rustc_serialize;
extern crate yup_oauth2 as oauth2;
extern crate serde;
extern crate serde_json;
extern crate yup_oauth2 as oauth2;
#[macro_use]
extern crate serde_derive;
extern crate strsim;
@@ -22,17 +28,16 @@ mod cli;
#[cfg(test)]
mod test_api {
extern crate yup_hyper_mock as hyper_mock;
use super::api::client::*;
use self::hyper_mock::*;
use std::io::Read;
use std::default::Default;
use super::api::client::*;
use hyper;
use std::default::Default;
use std::io::Read;
use std::str::FromStr;
use serde_json as json;
const EXPECTED: &'static str =
"\r\n--MDuXWGyeE33QFXGchb2VFWc4Z7945d\r\n\
const EXPECTED: &'static str = "\r\n--MDuXWGyeE33QFXGchb2VFWc4Z7945d\r\n\
Content-Length: 50\r\n\
Content-Type: application/json\r\n\
\r\n\
@@ -44,7 +49,7 @@ Content-Type: application/plain\r\n\
bar\r\n\
--MDuXWGyeE33QFXGchb2VFWc4Z7945d--";
const EXPECTED_LEN: usize= 223;
const EXPECTED_LEN: usize = 223;
#[test]
fn multi_part_reader() {
@@ -53,15 +58,15 @@ bar\r\n\
let mut mpr: MultiPartReader = Default::default();
mpr.add_part(&mut r1, 50, "application/json".parse().unwrap())
.add_part(&mut r2, 25, "application/plain".parse().unwrap());
.add_part(&mut r2, 25, "application/plain".parse().unwrap());
let mut res = String::new();
let r = mpr.read_to_string(&mut res).unwrap();
assert_eq!(res.len(), r);
// NOTE: This CAN fail, as the underlying header hashmap is not sorted
// As the test is just for dev, and doesn't run on travis, we are fine,
// for now. Possible solution would be to omit the size field (make it
// As the test is just for dev, and doesn't run on travis, we are fine,
// for now. Possible solution would be to omit the size field (make it
// optional)
assert_eq!(r, EXPECTED_LEN);
// assert_eq!(res, EXPECTED);
@@ -74,7 +79,7 @@ bar\r\n\
let mut mpr: MultiPartReader = Default::default();
mpr.add_part(&mut r1, 50, "application/json".parse().unwrap())
.add_part(&mut r2, 25, "application/plain".parse().unwrap());
.add_part(&mut r2, 25, "application/plain".parse().unwrap());
let buf = &mut [0u8];
let mut v = Vec::<u8>::new();
@@ -111,12 +116,11 @@ bar\r\n\
#[derive(Default, Serialize, Deserialize)]
struct Bar {
#[serde(rename="snooSnoo")]
snoo_snoo: String
#[serde(rename = "snooSnoo")]
snoo_snoo: String,
}
json::to_string(&<Bar as Default>::default()).unwrap();
let j = "{\"snooSnoo\":\"foo\"}";
let b: Bar = json::from_str(&j).unwrap();
assert_eq!(b.snoo_snoo, "foo");
@@ -133,10 +137,25 @@ bar\r\n\
#[test]
fn content_range() {
for &(ref c, ref expected) in
&[(ContentRange {range: None, total_length: 50 }, "Content-Range: bytes */50\r\n"),
(ContentRange {range: Some(Chunk { first: 23, last: 40 }), total_length: 45},
"Content-Range: bytes 23-40/45\r\n")] {
for &(ref c, ref expected) in &[
(
ContentRange {
range: None,
total_length: 50,
},
"Content-Range: bytes */50\r\n",
),
(
ContentRange {
range: Some(Chunk {
first: 23,
last: 40,
}),
total_length: 45,
},
"Content-Range: bytes 23-40/45\r\n",
),
] {
let mut headers = hyper::header::Headers::new();
headers.set(c.clone());
assert_eq!(headers.to_string(), expected.to_string());
@@ -145,13 +164,16 @@ bar\r\n\
#[test]
fn byte_range_from_str() {
assert_eq!(<Chunk as FromStr>::from_str("2-42"),
Ok(Chunk { first: 2, last: 42 }))
assert_eq!(
<Chunk as FromStr>::from_str("2-42"),
Ok(Chunk { first: 2, last: 42 })
)
}
#[test]
fn parse_range_response() {
let r: RangeResponseHeader = hyper::header::Header::parse_header(&[b"bytes 2-42".to_vec()]).unwrap();
let r: RangeResponseHeader =
hyper::header::Header::parse_header(&[b"bytes 2-42".to_vec()]).unwrap();
assert_eq!(r.0.first, 2);
assert_eq!(r.0.last, 42);
}