DCL: test empty authentication data

next
Sayan Nandan 6 months ago
parent 6c3fffea79
commit 15b4f384af
No known key found for this signature in database
GPG Key ID: 0EBD769024B24F0A

@ -359,7 +359,7 @@ pub enum ConfigSource {
impl ConfigSource { impl ConfigSource {
fn as_str(&self) -> &'static str { fn as_str(&self) -> &'static str {
match self { match self {
ConfigSource::Cli => "CLI", ConfigSource::Cli => "command-line arguments",
ConfigSource::Env => "ENV", ConfigSource::Env => "ENV",
ConfigSource::File => "config file", ConfigSource::File => "config file",
} }
@ -530,8 +530,8 @@ fn arg_decode_auth<CS: ConfigurationSource>(
return Err(ConfigError::with_src( return Err(ConfigError::with_src(
CS::SOURCE, CS::SOURCE,
ConfigErrorKind::ErrorString(format!( ConfigErrorKind::ErrorString(format!(
"to enable auth, you must provide values for {}", "to enable password auth, you must provide a value for '{}'",
CS::KEY_AUTH_DRIVER, CS::KEY_AUTH_ROOT_PASSWORD,
)), )),
) )
.into()); .into());

@ -31,7 +31,10 @@ mod dml_sec;
use { use {
crate::engine::error::QueryError, crate::engine::error::QueryError,
sky_macros::dbtest, sky_macros::dbtest,
skytable::{error::Error, query}, skytable::{
error::{ConnectionSetupError, Error},
query,
},
}; };
const INVALID_SYNTAX_ERR: u16 = QueryError::QLInvalidSyntax.value_u8() as u16; const INVALID_SYNTAX_ERR: u16 = QueryError::QLInvalidSyntax.value_u8() as u16;
@ -52,3 +55,12 @@ fn deny_unknown_tokens() {
); );
} }
} }
#[dbtest(username = "root", password = "")]
fn ensure_empty_password_returns_hs_error_5() {
let db = db_connect!();
assert_err_eq!(
db,
Error::ConnectionSetupErr(ConnectionSetupError::HandshakeError(5))
);
}

@ -241,6 +241,14 @@ pub fn dbtest(attrs: TokenStream, item: TokenStream) -> TokenStream {
block = quote! { block = quote! {
#block #block
/// Get a Skyhash connection the database (defined by [`sky_macros::dbtest`]) /// Get a Skyhash connection the database (defined by [`sky_macros::dbtest`])
#[allow(unused_macros)]
macro_rules! db_connect {
() => {{
skytable::Config::new(__DBTEST_HOST, __DBTEST_PORT, __DBTEST_USER, __DBTEST_PASS).connect()
}}
}
/// Get a Skyhash connection the database (defined by [`sky_macros::dbtest`])
#[allow(unused_macros)]
macro_rules! db { macro_rules! db {
() => {{ () => {{
skytable::Config::new(__DBTEST_HOST, __DBTEST_PORT, __DBTEST_USER, __DBTEST_PASS).connect().unwrap() skytable::Config::new(__DBTEST_HOST, __DBTEST_PORT, __DBTEST_USER, __DBTEST_PASS).connect().unwrap()

Loading…
Cancel
Save