diff --git a/nss_db/src/lib.rs b/nss_db/src/lib.rs index 565346c..2d6306c 100644 --- a/nss_db/src/lib.rs +++ b/nss_db/src/lib.rs @@ -8,4 +8,5 @@ pub use crate::log::setup_log; pub use config::Config; pub use db::Db; pub use user::User; +pub use error::Error; diff --git a/radius/tests/db_test.rs b/nss_db/tests/db_test.rs similarity index 60% rename from radius/tests/db_test.rs rename to nss_db/tests/db_test.rs index ade572e..cbb08cb 100644 --- a/radius/tests/db_test.rs +++ b/nss_db/tests/db_test.rs @@ -1,4 +1,7 @@ -use radius_virtual::prelude::*; +use nss_db::Db; +use nss_db::Error; +use radius::User; +use radius::Attribute; mod helpers; use helpers::*; @@ -7,15 +10,16 @@ use helpers::*; fn it_store_user() -> Result<(), Error> { let conf = config()?; let mut db = Db::with_config(&conf)?; - let mut user = user::User::new("testing"); - user.attributes.push(user::Attribute { + let mut user = User::new("testing"); + user.attributes.push(Attribute { vendor: 1, subtype: 1, data: vec![0xAA], }); - let user = db::User::lookup(&conf, &user).ok_or(Error::UserNotFound)?; + let user = conf.map_user(&user).ok_or(Error::UserNotFound)?; db.store_user(&user)?; let user_r = db.get_user("testing")?; assert_eq!(user, user_r); Ok(()) } + diff --git a/nss_db/tests/helpers.rs b/nss_db/tests/helpers.rs new file mode 100644 index 0000000..30b3460 --- /dev/null +++ b/nss_db/tests/helpers.rs @@ -0,0 +1,9 @@ +use nss_db::Config; +use nss_db::Error; + +pub fn config() -> Result { + let path = std::env::current_dir()?; + let path = path.join("../tests/config.toml"); + Config::read_file(path) +} + diff --git a/radius/src/lib.rs b/radius/src/lib.rs index aca037d..e938b60 100644 --- a/radius/src/lib.rs +++ b/radius/src/lib.rs @@ -8,6 +8,7 @@ mod error; pub use client::Client; pub use user::User; +pub use user::Attribute; pub use config::Config; pub use credentials::Credentials; pub use error::Error; diff --git a/radius/tests/helpers.rs b/radius/tests/helpers.rs index cdd423d..a6877ea 100644 --- a/radius/tests/helpers.rs +++ b/radius/tests/helpers.rs @@ -1,4 +1,5 @@ -use radius_virtual::prelude::*; +use radius::Config; +use radius::Error; pub fn config() -> Result { let path = std::env::current_dir()?; diff --git a/radius/tests/radius_test.rs b/radius/tests/radius_test.rs index ad1a30e..a9183d1 100644 --- a/radius/tests/radius_test.rs +++ b/radius/tests/radius_test.rs @@ -1,6 +1,8 @@ #[macro_use] extern crate assert_matches; -use radius_virtual::prelude::*; +use radius::Credentials; +use radius::Client; +use radius::Error; mod helpers; use helpers::*; diff --git a/tests/config.toml b/tests/config.toml index 7c4f826..76840d3 100644 --- a/tests/config.toml +++ b/tests/config.toml @@ -7,7 +7,7 @@ address = "127.0.0.1" timeout = 3 [mapping.db] -path = "/tmp/radius_auth_virtual.db" +path = "../build/radius_auth_virtual.db" [mapping.default_user] username = "radius" diff --git a/tests/run.sh b/tests/run.sh index b686a06..0b54de3 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -5,6 +5,7 @@ export LD_LIBRARY_PATH=./build/kqueue/ +rm ./build/radius_auth_virtual.db cp ./tests/authorize build/freeradius/dist/etc/raddb/mods-config/files/authorize ./build/freeradius/dist/sbin/radiusd -f -l stdout &