[Add] Proper User managment
This commit is contained in:
parent
430c12e139
commit
b38b68ad96
38 changed files with 4331 additions and 1065 deletions
29
iota-util/tests/private_export.rs
Normal file
29
iota-util/tests/private_export.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
use iota_util::atomic_file::create_private;
|
||||
|
||||
#[test]
|
||||
fn private_export_refuses_to_replace_existing_file() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let path = directory.path().join("alice.tu");
|
||||
create_private(&path, b"first").unwrap();
|
||||
|
||||
assert_eq!(
|
||||
create_private(&path, b"second").unwrap_err().kind(),
|
||||
std::io::ErrorKind::AlreadyExists
|
||||
);
|
||||
assert_eq!(std::fs::read(path).unwrap(), b"first");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn private_export_uses_owner_only_permissions() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let path = directory.path().join("alice.tu");
|
||||
create_private(&path, b"secret").unwrap();
|
||||
|
||||
assert_eq!(
|
||||
std::fs::metadata(path).unwrap().permissions().mode() & 0o777,
|
||||
0o600
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue