- add: linux support
This commit is contained in:
@@ -10,7 +10,7 @@ public class CryptographicTest
|
||||
public async Task EncryptDecrypt()
|
||||
{
|
||||
var key = CryptographicStore.GetComputerKey();
|
||||
Console.WriteLine($"Key: {key}");
|
||||
Console.WriteLine($"Key: {Convert.ToBase64String(key)}");
|
||||
var entry = new TestEncryptEntry("Hello", "World");
|
||||
Console.WriteLine($"Raw data: {entry}");
|
||||
var encrypt = CryptographicStore.Encrypt(entry, key);
|
||||
|
||||
64
Nebula.UnitTest/NebulaSharedTests/TarTest.cs
Normal file
64
Nebula.UnitTest/NebulaSharedTests/TarTest.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System.IO.Compression;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Nebula.Shared;
|
||||
using Nebula.Shared.Services;
|
||||
using Nebula.Shared.Services.Logging;
|
||||
using Nebula.Shared.Utils;
|
||||
|
||||
namespace Nebula.UnitTest.NebulaSharedTests;
|
||||
|
||||
[TestFixture]
|
||||
[TestOf(typeof(DotnetResolverService))]
|
||||
public class TarTest : BaseSharedTest
|
||||
{
|
||||
private FileService _fileService = default!;
|
||||
private ConfigurationService _configurationService = default!;
|
||||
private readonly HttpClient _httpClient = new();
|
||||
|
||||
public override void BeforeServiceBuild(IServiceCollection services)
|
||||
{
|
||||
TestServiceHelper.InitFileServiceTest();
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public override void Setup()
|
||||
{
|
||||
base.Setup();
|
||||
_fileService = _sharedUnit.GetService<FileService>();
|
||||
_configurationService = _sharedUnit.GetService<ConfigurationService>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task DownloadTarAndUnzipTest()
|
||||
{
|
||||
DotnetUrlHelper.RidOverrideTest = "linux-x64";
|
||||
Console.WriteLine($"Downloading dotnet {DotnetUrlHelper.GetRuntimeIdentifier()}...");
|
||||
|
||||
var url = DotnetUrlHelper.GetCurrentPlatformDotnetUrl(
|
||||
_configurationService.GetConfigValue(CurrentConVar.DotnetUrl)!
|
||||
);
|
||||
|
||||
using var response = await _httpClient.GetAsync(url);
|
||||
response.EnsureSuccessStatusCode();
|
||||
await using var stream = await response.Content.ReadAsStreamAsync();
|
||||
|
||||
Directory.CreateDirectory(FileService.RootPath);
|
||||
|
||||
if (url.EndsWith(".zip", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
using var zipArchive = new ZipArchive(stream);
|
||||
zipArchive.ExtractToDirectory(FileService.RootPath, true);
|
||||
}
|
||||
else if (url.EndsWith(".tar.gz", StringComparison.OrdinalIgnoreCase)
|
||||
|| url.EndsWith(".tgz", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
TarUtils.ExtractTarGz(stream, FileService.RootPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException("Unsupported archive format.");
|
||||
}
|
||||
|
||||
Console.WriteLine("Downloading dotnet complete.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user