Skip to content

Commit

Permalink
split test case in a negative and positive case
Browse files Browse the repository at this point in the history
  • Loading branch information
squell committed Nov 16, 2023
1 parent e9980c4 commit 642bfc1
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion ntp-proto/src/nts_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,7 @@ mod test {
}

#[test]
fn test_keyexchange_roundtrip_fixed() {
fn test_keyexchange_roundtrip_fixed_not_authorized() {
let (mut client, server) = client_server_pair();

let c2s: Vec<_> = (0..).take(64).collect();
Expand All @@ -2441,6 +2441,28 @@ mod test {
}
client.tls_connection.writer().write_all(&buffer).unwrap();

let result = keyexchange_loop(client, server);

matches!(
result.unwrap_err(),
KeyExchangeError::UnrecognizedCriticalRecord
);
}

#[test]
fn test_keyexchange_roundtrip_fixed_authorized() {
let (mut client, mut server) = client_server_pair();
server.privileged_connection = true;

let c2s: Vec<_> = (0..).take(64).collect();
let s2c: Vec<_> = (0..).skip(64).take(64).collect();

let mut buffer = Vec::with_capacity(1024);
for record in NtsRecord::client_key_exchange_records_fixed(c2s.clone(), s2c.clone()) {
record.write(&mut buffer).unwrap();
}
client.tls_connection.writer().write_all(&buffer).unwrap();

let keyset = server.keyset.clone();
let mut result = keyexchange_loop(client, server).unwrap();

Expand Down

0 comments on commit 642bfc1

Please sign in to comment.