mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-03 02:55:01 +03:00
2407d44f4f
* Fix overflow when speed tests have no eligible profiles * Preserve core executable permissions in Debian packages * Avoid requesting an icon refresh before view initialization
43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
namespace ServiceLib.Tests.Common;
|
|
|
|
public class UnixFileModeTests
|
|
{
|
|
[Test]
|
|
public async Task AlreadyExecutableSystemBinary_ShouldNotRequireOwnership()
|
|
{
|
|
if (OperatingSystem.IsWindows())
|
|
{
|
|
return;
|
|
}
|
|
|
|
// /bin/sh is executable but owned by root on the Unix CI runners.
|
|
// A regular user must not need chmod permission just to launch it.
|
|
var mode = File.GetUnixFileMode("/bin/sh");
|
|
await Utils.SetUnixFileMode("/bin/sh").Should().BeTrue();
|
|
await File.GetUnixFileMode("/bin/sh").Should().BeEqualTo(mode);
|
|
}
|
|
|
|
[Test]
|
|
public async Task NonExecutableOwnedFile_ShouldGainExecuteBitsWithoutLosingOtherPermissions()
|
|
{
|
|
if (OperatingSystem.IsWindows())
|
|
{
|
|
return;
|
|
}
|
|
|
|
var path = Path.GetTempFileName();
|
|
try
|
|
{
|
|
var mode = UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.GroupRead;
|
|
File.SetUnixFileMode(path, mode);
|
|
|
|
await Utils.SetUnixFileMode(path).Should().BeTrue();
|
|
await File.GetUnixFileMode(path).Should().BeEqualTo(mode | UnixFileMode.UserExecute | UnixFileMode.GroupExecute | UnixFileMode.OtherExecute);
|
|
}
|
|
finally
|
|
{
|
|
File.Delete(path);
|
|
}
|
|
}
|
|
}
|