new keyring, needs tests

This commit is contained in:
John Smith
2022-01-08 23:33:25 -05:00
parent 0a7ebcb3be
commit 84b1ef5e9e
14 changed files with 372 additions and 152 deletions

View File

@@ -432,6 +432,10 @@ pub async fn test_split_url() {
pub async fn test_protected_store() {
info!("testing protected store");
xxx move into its own test
let _ = intf::remove_user_secret("test", "_test_key").await;
let _ = intf::remove_user_secret("test", "_test_broken").await;

View File

@@ -94,11 +94,20 @@ cfg_if! {
out
}
pub fn get_tablestore_path() -> String {
pub fn get_table_store_path() -> String {
let mut out = get_data_dir();
std::fs::create_dir_all(&out).unwrap();
out.push("tablestore");
out.push("table_store");
out.into_os_string().into_string().unwrap()
}
pub fn get_protected_store_path() -> String {
let mut out = get_data_dir();
std::fs::create_dir_all(&out).unwrap();
out.push("protected_store");
out.into_os_string().into_string().unwrap()
}
@@ -149,6 +158,7 @@ pub fn setup_veilid_core() -> VeilidCoreSetup {
pub fn config_callback(key: String) -> Result<Box<dyn core::any::Any>, String> {
match key.as_str() {
"program_name" => Ok(Box::new(String::from("Veilid"))),
"namespace" => Ok(Box::new(String::from(""))),
"capabilities.protocol_udp" => Ok(Box::new(true)),
"capabilities.protocol_connect_tcp" => Ok(Box::new(true)),
@@ -157,7 +167,10 @@ pub fn config_callback(key: String) -> Result<Box<dyn core::any::Any>, String> {
"capabilities.protocol_accept_ws" => Ok(Box::new(true)),
"capabilities.protocol_connect_wss" => Ok(Box::new(true)),
"capabilities.protocol_accept_wss" => Ok(Box::new(true)),
"tablestore.directory" => Ok(Box::new(get_tablestore_path())),
"tablestore.directory" => Ok(Box::new(get_table_store_path())),
"protected_store.allow_insecure_fallback" => Ok(Box::new(true)),
"protected_store.always_use_insecure_storage" => Ok(Box::new(false)),
"protected_store.insecure_fallback_directory" => Ok(Box::new(get_protected_store_path())),
"network.max_connections" => Ok(Box::new(16u32)),
"network.connection_initial_timeout" => Ok(Box::new(2_000_000u64)),
"network.node_id" => Ok(Box::new(dht::key::DHTKey::default())),
@@ -240,6 +253,7 @@ pub async fn test_config() {
}
}
let inner = vc.get();
assert_eq!(inner.program_name, String::from("Veilid"));
assert_eq!(inner.namespace, String::from(""));
assert_eq!(inner.capabilities.protocol_udp, true);
assert_eq!(inner.capabilities.protocol_connect_tcp, true);
@@ -248,7 +262,13 @@ pub async fn test_config() {
assert_eq!(inner.capabilities.protocol_accept_ws, true);
assert_eq!(inner.capabilities.protocol_connect_wss, true);
assert_eq!(inner.capabilities.protocol_accept_wss, true);
assert_eq!(inner.tablestore.directory, get_tablestore_path());
assert_eq!(inner.table_store.directory, get_table_store_path());
assert_eq!(inner.protected_store.allow_insecure_fallback, true);
assert_eq!(inner.protected_store.always_use_insecure_storage, false);
assert_eq!(
inner.protected_store.insecure_fallback_directory,
get_protected_store_path()
);
assert_eq!(inner.network.max_connections, 16);
assert_eq!(inner.network.connection_initial_timeout, 2_000_000u64);
assert!(inner.network.node_id.valid);