InventoryEndpointUnconfiguredTests.cs 1.1 KB

123456789101112131415161718192021222324252627282930
  1. using System.Net;
  2. using System.Net.Http.Json;
  3. using Xunit.Abstractions;
  4. namespace Tests.Api;
  5. public class InventoryEndpointUnconfiguredTests(ITestOutputHelper output) : ApiTestBase(output) {
  6. protected override void ConfigureTestConfiguration(IDictionary<string, string?> config) =>
  7. config.Remove("RPK_API_KEY");
  8. [Fact]
  9. public async Task Missing_Server_Api_Key_Returns_503() {
  10. HttpClient client = CreateClient(true);
  11. HttpResponseMessage response = await client.PostAsJsonAsync("/api/inventory",
  12. new { yaml = "resources:\n - kind: Server\n name: x" });
  13. Assert.Equal(HttpStatusCode.ServiceUnavailable, response.StatusCode);
  14. }
  15. [Fact]
  16. public async Task Missing_Server_Api_Key_Returns_503_Even_Without_Client_Header() {
  17. HttpClient client = CreateClient();
  18. HttpResponseMessage response = await client.PostAsJsonAsync("/api/inventory",
  19. new { yaml = "resources:\n - kind: Server\n name: x" });
  20. Assert.Equal(HttpStatusCode.ServiceUnavailable, response.StatusCode);
  21. }
  22. }