fix tests
This commit is contained in:
parent
d14ce407fa
commit
8a68df9e54
2 changed files with 16 additions and 18 deletions
|
|
@ -162,15 +162,15 @@ async fn test_config_serialization_format() {
|
||||||
|
|
||||||
let encoded_config = manager.get_encoded_config().await.unwrap();
|
let encoded_config = manager.get_encoded_config().await.unwrap();
|
||||||
|
|
||||||
// Verify basic structure: length prefix + config data
|
// Verify we have config data (no length prefix anymore)
|
||||||
assert!(encoded_config.len() >= 2);
|
assert!(!encoded_config.is_empty());
|
||||||
|
assert!(encoded_config.len() > 10);
|
||||||
|
|
||||||
let length = u16::from_be_bytes([encoded_config[0], encoded_config[1]]);
|
// Verify it contains reasonable OHTTP key configuration data
|
||||||
assert_eq!(length as usize, encoded_config.len());
|
assert!(encoded_config.len() < 1000); // Reasonable upper bound
|
||||||
|
|
||||||
// Verify it contains expected OHTTP key configuration elements
|
// The config should be the raw encoded configuration
|
||||||
// The exact format would depend on your implementation
|
let config_data = &encoded_config;
|
||||||
let config_data = &encoded_config[..];
|
|
||||||
assert!(!config_data.is_empty());
|
assert!(!config_data.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
use bhttp::Message;
|
use bhttp::Message;
|
||||||
use ohttp_gateway::GatewayError;
|
use ohttp_gateway::key_manager::{CipherSuiteConfig, KeyManager, KeyManagerConfig};
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio;
|
use tokio;
|
||||||
use tracing::debug;
|
|
||||||
// Your key manager module - adjust the import path as needed
|
|
||||||
use ohttp_gateway::key_manager::{CipherSuiteConfig, KeyManager, KeyManagerConfig};
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_key_generation() {
|
async fn test_key_generation() {
|
||||||
|
|
@ -115,12 +112,14 @@ async fn test_get_encoded_config() {
|
||||||
|
|
||||||
let encoded_config = manager.get_encoded_config().await.unwrap();
|
let encoded_config = manager.get_encoded_config().await.unwrap();
|
||||||
|
|
||||||
// Should have at least 4 bytes (2 bytes length + some config data)
|
// Should have some config data (no length prefix anymore)
|
||||||
assert!(encoded_config.len() >= 4);
|
assert!(!encoded_config.is_empty());
|
||||||
|
assert!(encoded_config.len() > 0);
|
||||||
|
|
||||||
// First 2 bytes should be length in big endian
|
// The encoded config should be the raw config bytes without length prefix
|
||||||
let length = u16::from_be_bytes([encoded_config[0], encoded_config[1]]);
|
// We can't easily verify the exact content without duplicating the encoding logic,
|
||||||
assert_eq!(length as usize, encoded_config.len() - 2);
|
// but we can at least verify it's reasonable in size
|
||||||
|
assert!(encoded_config.len() < 1000); // Reasonable upper bound
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
|
@ -194,9 +193,8 @@ async fn test_bhttp_parsing() {
|
||||||
4, 47, 103, 101, 116, 10, 117, 115, 101, 114, 45, 97, 103, 101, 110, 116, 21, 79, 72, 84,
|
4, 47, 103, 101, 116, 10, 117, 115, 101, 114, 45, 97, 103, 101, 110, 116, 21, 79, 72, 84,
|
||||||
84, 80, 45, 84, 101, 115, 116, 45, 67, 108, 105, 101, 110, 116, 47, 49, 46, 48, 6, 97, 99,
|
84, 80, 45, 84, 101, 115, 116, 45, 67, 108, 105, 101, 110, 116, 47, 49, 46, 48, 6, 97, 99,
|
||||||
99, 101, 112, 116, 16, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 106, 115,
|
99, 101, 112, 116, 16, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 106, 115,
|
||||||
111, 110, 0, 0,
|
111, 110, 0, 0, 0,
|
||||||
];
|
];
|
||||||
let m = Message::read_bhttp(&mut Cursor::new(REQUEST)).unwrap();
|
let m = Message::read_bhttp(&mut Cursor::new(REQUEST)).unwrap();
|
||||||
println!("TEST {:?}", m);
|
|
||||||
assert!(m.header().get(b"accept").is_some());
|
assert!(m.header().get(b"accept").is_some());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue