mirror of
https://github.com/azaion/admin.git
synced 2026-06-21 16:01:09 +00:00
3a925b9b0f
- Deleted the `POST /resources/get/{dataFolder?}` and `GET /resources/get-installer` endpoints as part of the architectural shift towards simplified resource management.
- Removed associated methods and configurations, including `ResourcesService.GetEncryptedResource`, `ResourcesService.GetInstaller`, and related properties in `ResourcesConfig`.
- Cleaned up environment variables and configuration files to reflect the removal of installer-related settings.
- Eliminated the `GetResourceRequest` DTO and its validator, along with the `WrongResourceName` error code.
- Updated documentation to clarify the changes in resource handling and the retirement of per-user file encryption.
Co-authored-by: Cursor <cursoragent@cursor.com>
70 lines
2.1 KiB
C#
70 lines
2.1 KiB
C#
using System.Net;
|
|
using System.Net.Http.Json;
|
|
using System.Text;
|
|
using System.Text.Json;
|
|
using Azaion.E2E.Helpers;
|
|
using FluentAssertions;
|
|
using Xunit;
|
|
|
|
namespace Azaion.E2E.Tests;
|
|
|
|
[Collection("E2E")]
|
|
public sealed class ResourceTests
|
|
{
|
|
private static readonly JsonSerializerOptions ResponseJsonOptions = new()
|
|
{
|
|
PropertyNameCaseInsensitive = true
|
|
};
|
|
|
|
private sealed record ErrorResponse(int ErrorCode, string Message);
|
|
|
|
private readonly TestFixture _fixture;
|
|
|
|
public ResourceTests(TestFixture fixture) => _fixture = fixture;
|
|
|
|
[Fact]
|
|
public async Task File_upload_succeeds()
|
|
{
|
|
// Arrange
|
|
var folder = $"restest-{Guid.NewGuid():N}";
|
|
var fileBytes = Encoding.UTF8.GetBytes(new string('a', 100));
|
|
|
|
try
|
|
{
|
|
using var admin = _fixture.CreateAuthenticatedClient(_fixture.AdminToken);
|
|
|
|
// Act
|
|
using var response = await admin.UploadFileAsync($"/resources/{folder}", fileBytes, "upload.txt");
|
|
|
|
// Assert
|
|
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
|
}
|
|
finally
|
|
{
|
|
using var adminCleanup = _fixture.CreateAuthenticatedClient(_fixture.AdminToken);
|
|
using var clear = await adminCleanup.PostAsync($"/resources/clear/{folder}", new { });
|
|
clear.EnsureSuccessStatusCode();
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Upload_without_file_is_rejected_with_400_or_409_and_60_on_conflict()
|
|
{
|
|
// Arrange
|
|
var folder = $"restest-{Guid.NewGuid():N}";
|
|
using var content = new MultipartFormDataContent();
|
|
|
|
// Act
|
|
using var response = await _fixture.HttpClient.PostAsync($"/resources/{folder}", content);
|
|
|
|
// Assert
|
|
response.StatusCode.Should().BeOneOf(HttpStatusCode.BadRequest, HttpStatusCode.Conflict);
|
|
if (response.StatusCode == HttpStatusCode.Conflict)
|
|
{
|
|
var err = await response.Content.ReadFromJsonAsync<ErrorResponse>(ResponseJsonOptions);
|
|
err.Should().NotBeNull();
|
|
err!.ErrorCode.Should().Be(60);
|
|
}
|
|
}
|
|
}
|