Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Xintao <[email protected]>
  • Loading branch information
hunterlxt committed Jun 10, 2020
1 parent ef4dcc6 commit b9639c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
2 changes: 2 additions & 0 deletions grpc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ exclude = [
"grpc/third_party/benchmark/*",
"grpc/third_party/bloaty/*",
"grpc/third_party/libuv/*",
"grpc/third_party/gflags/*",
"grpc/third_party/googletest/*",
"grpc/third_party/objective_c/*",
"grpc/third_party/protobuf/*",
"grpc/third_party/toolchans/*",
Expand Down
22 changes: 7 additions & 15 deletions tests-and-examples/tests/cases/auth_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tests_and_examples::util::{read_cert_pair, read_single_crt};

#[derive(Clone)]
struct GreeterService {
tx: Sender<std::result::Result<Option<HashMap<String, String>>, ()>>,
tx: Sender<Option<HashMap<String, String>>>,
}

impl Greeter for GreeterService {
Expand All @@ -26,9 +26,9 @@ impl Greeter for GreeterService {
let auth_context = ctx.auth_context();

if auth_context.is_some() {
self.tx.send(Ok(None)).unwrap();
self.tx.send(Some(HashMap::default())).unwrap();
} else {
self.tx.send(Err(())).unwrap();
self.tx.send(None).unwrap();
}

if let Some(auth_context) = auth_context {
Expand All @@ -39,7 +39,7 @@ impl Greeter for GreeterService {
{
ctx_map.insert(key.to_owned(), value.to_owned());
}
self.tx.send(Ok(Some(ctx_map))).unwrap();
self.tx.send(Some(ctx_map)).unwrap();
}

let mut resp = HelloReply::default();
Expand Down Expand Up @@ -88,17 +88,9 @@ fn test_auth_context() {

assert_eq!(resp.get_message(), "hello world");

assert!(rx
.recv_timeout(Duration::from_secs(1))
.unwrap()
.unwrap()
.is_none());
assert!(rx.recv_timeout(Duration::from_secs(1)).unwrap().is_some());
// Test auth_context keys
let ctx_map = rx
.recv_timeout(Duration::from_secs(1))
.unwrap()
.unwrap()
.unwrap();
let ctx_map = rx.recv_timeout(Duration::from_secs(1)).unwrap().unwrap();

assert_eq!(ctx_map.get("transport_security_type").unwrap(), "ssl");
assert_eq!(ctx_map.get("x509_common_name").unwrap(), "grpc-client-1");
Expand Down Expand Up @@ -137,7 +129,7 @@ fn test_no_crash_on_insecure() {
assert_eq!(resp.get_message(), "hello world");

// Test auth_context keys
assert!(rx.recv_timeout(Duration::from_secs(1)).unwrap().is_err());
assert!(rx.recv_timeout(Duration::from_secs(1)).unwrap().is_none());
let _empty_keys: mpsc::RecvTimeoutError = rx
.recv_timeout(Duration::from_millis(100))
.expect_err("Received auth context even though not authenticated");
Expand Down

0 comments on commit b9639c8

Please sign in to comment.