Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b834c37
refactor: sln migration, test project added, test for status endpoint…
Fildrance Jul 17, 2026
a7c4fcd
refactor: revert change for Program.cs from top-level-statement
Fildrance Jul 17, 2026
3112be7
refactor: method for polling data from server, support for different …
Fildrance Jul 18, 2026
b65fc3b
refactor: ForkDownloadController tests
Fildrance Jul 18, 2026
7022f69
refactor: tests for multi-file ForkDownloadController download call
Fildrance Jul 19, 2026
90fb01c
refactor: ForkManifestControllerTests, publishing one-shot added as w…
Fildrance Jul 20, 2026
6cd22f6
refactor: minor cleanups
Fildrance Jul 20, 2026
20a7f4d
refactor: base DownloadController tests class, compatibility controll…
Fildrance Jul 20, 2026
8cf9d91
refactor: extracted publish into TestBase
Fildrance Jul 20, 2026
f8c46c6
refactor: whitespaces
Fildrance Jul 20, 2026
4da92a2
refactor: one-shot publish tests
Fildrance Jul 20, 2026
8db6bda
refactor: test output for server logs attached
Fildrance Jul 20, 2026
d6eb0d5
refactor: multi step publish process tests
Fildrance Jul 20, 2026
4862ed6
refactor: ForkUpdateController tests
Fildrance Jul 20, 2026
a64a3b5
refactor: build razor page tests
Fildrance Jul 20, 2026
40b9774
refactor: restart publish test
Fildrance Jul 20, 2026
5fc6fb1
refactor: POST Download with empty request body test
Fildrance Jul 20, 2026
3975712
refactor: fix DownloadPost_EmptyRequestBody_ReturnsStreamHeaderOnly
Fildrance Jul 21, 2026
0c5879e
refactor: revert debug changes
Fildrance Jul 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = crlf

[*.{csproj,xml,yml,dll.config,msbuildproj,targets,props,json}]
indent_size = 2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Robust.Cdn/content.db*
Robust.Cdn/manifest.db*
*.user
testData/
/.vs/**
5 changes: 5 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@
<PackageVersion Include="SharpZstd.Interop" Version="1.5.6" />
<PackageVersion Include="SharpZstd" Version="1.5.6" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions Robust.Cdn.Tests/ControllerTestCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc.Testing;

namespace Robust.Cdn.Tests;

/// <summary>
/// Defines a test collection that uses <c>DatabaseFixture</c> for cleanup.
/// </summary>
[CollectionDefinition("ControllerTests")]
public sealed class ControllerTestCollection
: ICollectionFixture<WebApplicationFactory<Program>>, ICollectionFixture<DatabaseFixture>
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using Microsoft.AspNetCore.Mvc.Testing;
using System.Net;
using System.Net.Http.Headers;
using Xunit.Abstractions;

namespace Robust.Cdn.Tests.Controllers;

/// <summary>
/// Integration tests for <c>DownloadCompatibilityController</c> (legacy /version/{version}/... routes).
///
/// Endpoints:
/// GET /version/{version}/manifest
/// OPTIONS /version/{version}/download
/// POST /version/{version}/download
/// </summary>
public sealed class DownloadCompatibilityControllerTests(
WebApplicationFactory<Program> factory,
DatabaseFixture database,
ITestOutputHelper testOutput
) : DownloadControllerTestBase(factory, database, testOutput)
{
private const string CompatFork = "testfork-compat";

protected override string ForkName => CompatFork;
protected override string RoutePrefix => "/version";

protected override Dictionary<string, string?> GetConfigurationOverrides()
{
return new()
{
["Cdn:DefaultFork"] = CompatFork,
["Cdn:DatabaseFileName"] = Database.CreateTempDb(),
["Manifest:FileDiskPath"] = Database.CreateTestVersionOnDisk(CompatFork, ExistingVersion, content: FileContent),
};
}

[Fact]
public async Task GetManifest_VersionNotFound_ReturnsNotFound()
{
var client = Factory.CreateClient();

var response = await PollUntilCondition(
() => client.GetAsync("/version/0.0.0/manifest"),
r => Task.FromResult(r.StatusCode == HttpStatusCode.NotFound));

Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}

[Fact]
public async Task GetManifest_DefaultForkNull_ReturnsNotFound()
{
var client = FactoryWithNoDefaultFork().CreateClient();
var response = await client.GetAsync($"/version/{ExistingVersion}/manifest");
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}

[Fact]
public async Task DownloadOptions_DefaultForkNull_ReturnsNotFound()
{
var client = FactoryWithNoDefaultFork().CreateClient();
var response = await client.SendAsync(new(HttpMethod.Options, $"/version/{ExistingVersion}/download"));
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}

[Fact]
public async Task DownloadPost_DefaultForkNull_ReturnsNotFound()
{
var client = FactoryWithNoDefaultFork().CreateClient();

var content = new ByteArrayContent(new byte[4]);
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

var request = new HttpRequestMessage(HttpMethod.Post, $"/version/{ExistingVersion}/download")
{
Content = content
};
request.Headers.Add("X-Robust-Download-Protocol", "1");

var response = await client.SendAsync(request);
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}

private WebApplicationFactory<Program> FactoryWithNoDefaultFork()
{
return Factory.WithWebHostBuilder(builder =>
{
builder.ConfigureAppConfiguration((_, configBuilder) =>
{
configBuilder.AddInMemoryCollection(new Dictionary<string, string?>
{
["Cdn:DefaultFork"] = null,
});
});
});
}
}
Loading
Loading