|
|
|
@ -2307,63 +2307,6 @@ mod tests {
|
|
|
|
|
assert!(permissions.readonly(), "File not set to readonly");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test(tokio::test)]
|
|
|
|
|
async fn set_permissions_should_support_following_symlinks_if_option_specified() {
|
|
|
|
|
let (api, ctx, _rx) = setup(1).await;
|
|
|
|
|
let temp = assert_fs::TempDir::new().unwrap();
|
|
|
|
|
let file = temp.child("file");
|
|
|
|
|
file.write_str("some text").unwrap();
|
|
|
|
|
|
|
|
|
|
let symlink = temp.child("link");
|
|
|
|
|
symlink.symlink_to_file(file.path()).unwrap();
|
|
|
|
|
|
|
|
|
|
// Verify that file is not readonly by default
|
|
|
|
|
let permissions = tokio::fs::symlink_metadata(file.path())
|
|
|
|
|
.await
|
|
|
|
|
.unwrap()
|
|
|
|
|
.permissions();
|
|
|
|
|
assert!(!permissions.readonly(), "File is already set to readonly");
|
|
|
|
|
|
|
|
|
|
// Verify that symlink is not readonly by default
|
|
|
|
|
let permissions = tokio::fs::symlink_metadata(symlink.path())
|
|
|
|
|
.await
|
|
|
|
|
.unwrap()
|
|
|
|
|
.permissions();
|
|
|
|
|
assert!(
|
|
|
|
|
!permissions.readonly(),
|
|
|
|
|
"Symlink is already set to readonly"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Change the permissions of the file pointed to by the symlink
|
|
|
|
|
api.set_permissions(
|
|
|
|
|
ctx,
|
|
|
|
|
symlink.path().to_path_buf(),
|
|
|
|
|
Permissions::readonly(),
|
|
|
|
|
SetPermissionsOptions {
|
|
|
|
|
follow_symlinks: true,
|
|
|
|
|
..Default::default()
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
.await
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
// Retrieve permissions of the file and symlink to verify set
|
|
|
|
|
let permissions = tokio::fs::symlink_metadata(file.path())
|
|
|
|
|
.await
|
|
|
|
|
.unwrap()
|
|
|
|
|
.permissions();
|
|
|
|
|
assert!(permissions.readonly(), "File not set to readonly");
|
|
|
|
|
|
|
|
|
|
let permissions = tokio::fs::symlink_metadata(symlink.path())
|
|
|
|
|
.await
|
|
|
|
|
.unwrap()
|
|
|
|
|
.permissions();
|
|
|
|
|
assert!(
|
|
|
|
|
!permissions.readonly(),
|
|
|
|
|
"Symlink unexpectedly set to readonly"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NOTE: Ignoring on windows because it's using WSL which wants a Linux path
|
|
|
|
|
// with / but thinks it's on windows and is providing \
|
|
|
|
|
#[test(tokio::test)]
|
|
|
|
|