private Mono.Unix.FileAccessPermissions ConvertPermissions(PlaywrightSharp.Helpers.Linux.FileAccessPermissions executableFilePermissions) { Mono.Unix.FileAccessPermissions output = 0; var map = new Dictionary <PlaywrightSharp.Helpers.Linux.FileAccessPermissions, Mono.Unix.FileAccessPermissions>() { { PlaywrightSharp.Helpers.Linux.FileAccessPermissions.OtherExecute, Mono.Unix.FileAccessPermissions.OtherExecute }, { PlaywrightSharp.Helpers.Linux.FileAccessPermissions.OtherWrite, Mono.Unix.FileAccessPermissions.OtherWrite }, { PlaywrightSharp.Helpers.Linux.FileAccessPermissions.OtherRead, Mono.Unix.FileAccessPermissions.OtherRead }, { PlaywrightSharp.Helpers.Linux.FileAccessPermissions.GroupExecute, Mono.Unix.FileAccessPermissions.GroupExecute }, { PlaywrightSharp.Helpers.Linux.FileAccessPermissions.GroupWrite, Mono.Unix.FileAccessPermissions.GroupWrite }, { PlaywrightSharp.Helpers.Linux.FileAccessPermissions.GroupRead, Mono.Unix.FileAccessPermissions.GroupRead }, { PlaywrightSharp.Helpers.Linux.FileAccessPermissions.UserExecute, Mono.Unix.FileAccessPermissions.UserExecute }, { PlaywrightSharp.Helpers.Linux.FileAccessPermissions.UserWrite, Mono.Unix.FileAccessPermissions.UserWrite }, { PlaywrightSharp.Helpers.Linux.FileAccessPermissions.UserRead, Mono.Unix.FileAccessPermissions.UserRead } }; foreach (var item in map.Keys) { if ((executableFilePermissions & item) == item) { output |= map[item]; } } return(output); }
public async Task ShouldDownloadAndExtractFirefoxLinuxBinary() { using var browserFetcher = Puppeteer.CreateBrowserFetcher(new BrowserFetcherOptions { Platform = Platform.Linux, Path = _downloadsFolder, Host = TestConstants.ServerUrl, Product = Product.Firefox }); var expectedVersion = "75.0a1"; var revisionInfo = browserFetcher.RevisionInfo(expectedVersion); Server.SetRedirect( revisionInfo.Url.Substring(TestConstants.ServerUrl.Length), "/firefox.zip"); Assert.False(revisionInfo.Local); Assert.Equal(Platform.Linux, revisionInfo.Platform); Assert.False(await browserFetcher.CanDownloadAsync("100000")); Assert.True(await browserFetcher.CanDownloadAsync(expectedVersion)); try { revisionInfo = await browserFetcher.DownloadAsync(expectedVersion); Assert.True(revisionInfo.Local); Assert.Equal("FIREFOX LINUX BINARY\n", File.ReadAllText(revisionInfo.ExecutablePath)); if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { #if NETCOREAPP //This will not be run on net4x anyway. Mono.Unix.FileAccessPermissions permissions = ConvertPermissions(LinuxSysCall.ExecutableFilePermissions); Assert.Equal(permissions, UnixFileSystemInfo.GetFileSystemEntry(revisionInfo.ExecutablePath).FileAccessPermissions & permissions); #endif } Assert.Equal(new[] { expectedVersion }, browserFetcher.LocalRevisions()); browserFetcher.Remove(expectedVersion); Assert.Empty(browserFetcher.LocalRevisions()); //Download should return data from a downloaded version //This section is not in the Puppeteer test. await browserFetcher.DownloadAsync(expectedVersion); Server.Reset(); revisionInfo = await browserFetcher.DownloadAsync(expectedVersion); Assert.True(revisionInfo.Local); Assert.Equal("FIREFOX LINUX BINARY\n", File.ReadAllText(revisionInfo.ExecutablePath)); } finally { EnsureDownloadsFolderIsDeleted(); } }
public async Task ShouldDownloadAndExtractLinuxBinary() { var browserFetcher = Playwright.CreateBrowserFetcher(new BrowserFetcherOptions { Platform = Platform.Linux, Path = _downloadsFolder.Path, Host = TestConstants.ServerUrl }); var revisionInfo = browserFetcher.GetRevisionInfo("123456"); Server.SetRedirect(revisionInfo.Url.Substring(TestConstants.ServerUrl.Length), "/chromium-linux.zip"); Assert.False(revisionInfo.Local); Assert.Equal(Platform.Linux, revisionInfo.Platform); Assert.False(await browserFetcher.CanDownloadAsync("100000")); Assert.True(await browserFetcher.CanDownloadAsync("123456")); revisionInfo = await browserFetcher.DownloadAsync("123456"); Assert.True(revisionInfo.Local); Assert.Equal("LINUX BINARY\n", File.ReadAllText(revisionInfo.ExecutablePath)); if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { #if NETCOREAPP //This will not be run on net4x anyway. Mono.Unix.FileAccessPermissions permissions = ConvertPermissions(LinuxSysCall.ExecutableFilePermissions); Assert.Equal(permissions, UnixFileSystemInfo.GetFileSystemEntry(revisionInfo.ExecutablePath).FileAccessPermissions & permissions); #endif } Assert.Equal(new[] { "123456" }, browserFetcher.GetLocalRevisions()); browserFetcher.Remove("123456"); Assert.Empty(browserFetcher.GetLocalRevisions()); //Download should return data from a downloaded version //This section is not in the Playwright test. await browserFetcher.DownloadAsync("123456"); Server.Reset(); revisionInfo = await browserFetcher.DownloadAsync("123456"); Assert.True(revisionInfo.Local); Assert.Equal("LINUX BINARY\n", File.ReadAllText(revisionInfo.ExecutablePath)); }