use super::defs::*;
use crate::support::error::Error;
#[test]
fn capability_declared() {
test_require_capability("xcrycapa", "XCRY");
}
#[test]
fn user_configuration() {
let setup = set_up_new_root();
let mut client = setup.connect("xcryucfg");
quick_log_in(&mut client);
command!(
[response] = client,
c("XCRY SET-USER-CONFIG INTERNAL-KEY-PATTERN \"../foo\"")
);
assert_error_response(
response,
Some(s::RespTextCode::Cannot(())),
Error::UnsafeName,
);
command!(
[response] = client,
c("XCRY SET-USER-CONFIG EXTERNAL-KEY-PATTERN \"../foo\"")
);
assert_error_response(
response,
Some(s::RespTextCode::Cannot(())),
Error::UnsafeName,
);
command!(
[response] = client,
c("XCRY SET-USER-CONFIG EXTERNAL-KEY-PATTERN \"foo%\"")
);
assert_error_response(
response,
Some(s::RespTextCode::Cannot(())),
Error::UnsafeName,
);
command!(mut responses = client,
c("XCRY SET-USER-CONFIG INTERNAL-KEY-PATTERN \"ikp%Y\" \
EXTERNAL-KEY-PATTERN \"ekp%d\""));
assert_tagged_ok(responses.pop().unwrap());
has_untagged_response_matching! {
s::Response::XCryBackupFile(..) in responses
};
command!(mut responses = client, c("XCRY GET-USER-CONFIG"));
assert_tagged_ok(responses.pop().unwrap());
has_untagged_response_matching! {
s::Response::XCryUserConfig(ref cfg) in responses => {
assert_eq!("ikp%Y", cfg.internal_key_pattern);
assert_eq!("ekp%d", cfg.external_key_pattern);
assert!(cfg.password_changed.is_none());
}
};
command!(mut responses = client,
c("XCRY SET-USER-CONFIG PASSWORD hunter3"));
assert_tagged_ok(responses.pop().unwrap());
has_untagged_response_matching! {
s::Response::XCryBackupFile(..) in responses
};
let mut client = setup.connect("xcryucfg");
ok_command!(client, c("LOGIN azure hunter3"));
command!(mut responses = client, c("XCRY GET-USER-CONFIG"));
assert_tagged_ok(responses.pop().unwrap());
has_untagged_response_matching! {
s::Response::XCryUserConfig(ref cfg) in responses => {
assert_eq!("ikp%Y", cfg.internal_key_pattern);
assert_eq!("ekp%d", cfg.external_key_pattern);
assert!(cfg.password_changed.is_some());
}
};
}