Skip to content

Add testing guide: HTTP request file, integration tests, and README#1

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/build-base-server-integration
Draft

Add testing guide: HTTP request file, integration tests, and README#1
Copilot wants to merge 4 commits into
mainfrom
copilot/build-base-server-integration

Conversation

Copilot AI commented Feb 20, 2026

Copy link
Copy Markdown

No documentation or tooling existed to exercise the API after standing it up. Three testing surfaces are now provided.

MilestoneBaseServer.http

Step-by-step REST Client file covering the full workflow — login → register server → sync cameras → manage users → grant permissions → create views → verify viewer isolation. Works natively in Visual Studio 2022 and VS Code with REST Client.

Integration tests (ApiIntegrationTests)

11 end-to-end tests using WebApplicationFactory<Program>. Each test gets an isolated in-memory database via a custom TestApiFactory. Covers the complete HTTP contract:

  • Auth: valid login returns JWT, wrong password → 401, no token → 401
  • RBAC: viewer token on admin endpoint → 403
  • Full CRUD for servers, users, permissions, views
  • Permission grants make cameras visible to the viewer
  • Shared views are visible across users
internal sealed class TestApiFactory : WebApplicationFactory<Program>
{
    private readonly string _dbName = "IntegrationTest-" + Guid.NewGuid();

    protected override void ConfigureWebHost(IWebHostBuilder builder)
    {
        builder.ConfigureServices(services =>
        {
            // swap in a fresh isolated in-memory database per test
            services.RemoveAll<DbContextOptions<BaseServerDbContext>>();
            services.AddDbContext<BaseServerDbContext>(opt =>
                opt.UseInMemoryDatabase(_dbName));
        });
    }
}

README

Added quick-start, three testing paths (dotnet test, .http file, curl/PowerShell), full API reference table, and architecture diagram.

Bug fix

launchSettings.json had the http and https profiles merged into a single invalid JSON object; split them back into separate profiles.

Original prompt

I want to build a Base Server to connect different milestone management servers into. It will not matter what version/feature set they have. Then the xprotect client will connect/authenticate into the base server where it will view the associated cameras. The permissions for the base server and view setup's will be done in the base server.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 20, 2026 21:35
…d tests

Co-authored-by: njsnowman <219679845+njsnowman@users.noreply.github.com>
Co-authored-by: njsnowman <219679845+njsnowman@users.noreply.github.com>
Copilot AI changed the title [WIP] Add base server for milestone management integration Add ASP.NET Core 8 Base Server for Milestone XProtect integration Feb 20, 2026
Copilot AI requested a review from njsnowman February 20, 2026 21:40
Co-authored-by: njsnowman <219679845+njsnowman@users.noreply.github.com>
Copilot AI changed the title Add ASP.NET Core 8 Base Server for Milestone XProtect integration Add testing guide: HTTP request file, integration tests, and README Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants