b4202e9794
- Stable links per package (/api/downloads/agent/Agent.msi, Agent.zip, Agent-<os>-<arch>.zip) always serve the newest build (GET and HEAD, X-Agent-Version); /api/downloads/agent lists version, SHA-256, size and link as JSON. With offload on they redirect to a fresh presigned link (S3 presigned links cannot be permanent). - Public Downloads setting (off by default): on, anyone; off, install scripts (their package URLs carry the bootstrap token) and signed-in users with devices.view. - No MSI/ZIP choice: the Windows script installs the MSI, or the ZIP in Windows PE. Add Device is redesigned: platform cards, token step with summary chips, install step, and per-platform downloads. - Settings > Enrollment Tokens gains an Agent Downloads card. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
1.9 KiB
C#
58 lines
1.9 KiB
C#
using System.Net;
|
|
using Shared.Contracts.Api;
|
|
using Xunit;
|
|
|
|
namespace Backend.Tests;
|
|
|
|
public class InstallEndpointTests : IClassFixture<BackendTestFixture>
|
|
{
|
|
private readonly BackendTestFixture fixture;
|
|
|
|
public InstallEndpointTests(BackendTestFixture fixture) => this.fixture = fixture;
|
|
|
|
[Fact]
|
|
public async Task InstallScriptEmbedsTokenAndInstallCommand()
|
|
{
|
|
using var client = fixture.CreateClient();
|
|
|
|
var response = await client.GetAsync($"{ApiRoutes.InstallScript}?token=test-token-123");
|
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
|
|
|
var script = await response.Content.ReadAsStringAsync();
|
|
Assert.Contains("test-token-123", script);
|
|
Assert.Contains("msiexec.exe", script);
|
|
Assert.Contains("BOOTSTRAPTOKEN=$token", script);
|
|
Assert.Contains("/api/enrollment/agent-package", script);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task InstallScriptRequiresToken()
|
|
{
|
|
using var client = fixture.CreateClient();
|
|
var response = await client.GetAsync(ApiRoutes.InstallScript);
|
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task ZipInstallScriptUsesInitializeCommand()
|
|
{
|
|
using var client = fixture.CreateClient();
|
|
|
|
var response = await client.GetAsync($"{ApiRoutes.InstallScript}?token=t&type=zip");
|
|
var script = await response.Content.ReadAsStringAsync();
|
|
|
|
Assert.Contains("ZipFile]::ExtractToDirectory", script);
|
|
Assert.Contains("initialize", script);
|
|
Assert.Contains("type=zip", script);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task AgentPackageReturns404WhenAbsent()
|
|
{
|
|
await fixture.SetPublicDownloadsAsync(true);
|
|
using var client = fixture.CreateClient();
|
|
var response = await client.GetAsync($"{ApiRoutes.AgentPackage}?type=msi");
|
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
|
}
|
|
}
|