The Free Software Media System - Server Backend & API
Improve naming
Bond_0095253483ce421
diff --git a/tests/Jellyfin.Server.Integration.Tests/Controllers/StartupControllerTests.cs b/tests/Jellyfin.Server.Integration.Tests/Controllers/StartupControllerTests.csindex bb38db1be4..169a5a6c52 100644--- a/tests/Jellyfin.Server.Integration.Tests/Controllers/StartupControllerTests.cs+++ b/tests/Jellyfin.Server.Integration.Tests/Controllers/StartupControllerTests.cs@@ -16,7 +16,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllerspublic sealed class StartupControllerTests : IClassFixture<JellyfinApplicationFactory>{private readonly JellyfinApplicationFactory _factory;- private readonly JsonSerializerOptions _jsonOpions = JsonDefaults.Options;+ private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;public StartupControllerTests(JellyfinApplicationFactory factory){@@ -24,93 +24,96 @@ namespace Jellyfin.Server.Integration.Tests.Controllers}[Fact]- [Priority(0)]+ [Priority(-2)]public async Task Configuration_EditConfig_Success(){var client = _factory.CreateClient();- using var res0 = await client.GetAsync("/Startup/Configuration").ConfigureAwait(false);- Assert.Equal(HttpStatusCode.OK, res0.StatusCode);- Assert.Equal(MediaTypeNames.Application.Json, res0.Content.Headers.ContentType?.MediaType);-- var content0 = await res0.Content.ReadAsStreamAsync().ConfigureAwait(false);- _ = await JsonSerializer.DeserializeAsync<StartupConfigurationDto>(content0, _jsonOpions).ConfigureAwait(false);-- var newConfig = new StartupConfigurationDto()+ var config = new StartupConfigurationDto(){UICulture = "NewCulture",MetadataCountryCode = "be",PreferredMetadataLanguage = "nl"};- var req1 = JsonSerializer.SerializeToUtf8Bytes(newConfig, _jsonOpions);- using var reqContent1 = new ByteArrayContent(req1);- reqContent1.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);- var res1 = await client.PostAsync("/Startup/Configuration", reqContent1).ConfigureAwait(false);- Assert.Equal(HttpStatusCode.NoContent, res1.StatusCode);-- var res2 = await client.GetAsync("/Startup/Configuration").ConfigureAwait(false);- Assert.Equal(HttpStatusCode.OK, res2.StatusCode);- Assert.Equal(MediaTypeNames.Application.Json, res2.Content.Headers.ContentType?.MediaType);-- var content2 = await res2.Content.ReadAsStreamAsync().ConfigureAwait(false);- var config2 = await JsonSerializer.DeserializeAsync<StartupConfigurationDto>(content2, _jsonOpions).ConfigureAwait(false);- Assert.Equal(newConfig.UICulture, config2!.UICulture);- Assert.Equal(newConfig.MetadataCountryCode, config2.MetadataCountryCode);- Assert.Equal(newConfig.PreferredMetadataLanguage, config2.PreferredMetadataLanguage);+ using var postContent = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(config, _jsonOptions));+ postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);+ using var postResponse = await client.PostAsync("/Startup/Configuration", postContent).ConfigureAwait(false);+ Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);++ using var getResponse = await client.GetAsync("/Startup/Configuration").ConfigureAwait(false);+ Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);+ Assert.Equal(MediaTypeNames.Application.Json, getResponse.Content.Headers.ContentType?.MediaType);++ using var responseStream = await getResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);+ var newConfig = await JsonSerializer.DeserializeAsync<StartupConfigurationDto>(responseStream, _jsonOptions).ConfigureAwait(false);+ Assert.Equal(config.UICulture, newConfig!.UICulture);+ Assert.Equal(config.MetadataCountryCode, newConfig.MetadataCountryCode);+ Assert.Equal(config.PreferredMetadataLanguage, newConfig.PreferredMetadataLanguage);}[Fact]- [Priority(0)]- public async Task User_EditUser_Success()+ [Priority(-2)]+ public async Task User_DefaultUser_NameWithoutPassword(){var client = _factory.CreateClient();- using var res0 = await client.GetAsync("/Startup/User").ConfigureAwait(false);- Assert.Equal(HttpStatusCode.OK, res0.StatusCode);- Assert.Equal(MediaTypeNames.Application.Json, res0.Content.Headers.ContentType?.MediaType);+ using var response = await client.GetAsync("/Startup/User").ConfigureAwait(false);+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);+ Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);++ using var contentStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);+ var user = await JsonSerializer.DeserializeAsync<StartupUserDto>(contentStream, _jsonOptions).ConfigureAwait(false);+ Assert.NotEmpty(user!.Name);+ Assert.Null(user.Password);+ }- var content0 = await res0.Content.ReadAsStreamAsync().ConfigureAwait(false);- var user = await JsonSerializer.DeserializeAsync<StartupUserDto>(content0, _jsonOpions).ConfigureAwait(false);+ [Fact]+ [Priority(-1)]+ public async Task User_EditUser_Success()+ {+ var client = _factory.CreateClient();- user!.Name = "NewName";- user.Password = "NewPassword";+ var user = new StartupUserDto()+ {+ Name = "NewName",+ Password = "NewPassword"+ };- var req1 = JsonSerializer.SerializeToUtf8Bytes(user, _jsonOpions);- using var reqContent1 = new ByteArrayContent(req1);- reqContent1.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);- var res1 = await client.PostAsync("/Startup/User", reqContent1).ConfigureAwait(false);- Assert.Equal(HttpStatusCode.NoContent, res1.StatusCode);+ using var postContent = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(user, _jsonOptions));+ postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);+ var postResponse = await client.PostAsync("/Startup/User", postContent).ConfigureAwait(false);+ Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);- var res2 = await client.GetAsync("/Startup/User").ConfigureAwait(false);- Assert.Equal(HttpStatusCode.OK, res2.StatusCode);- Assert.Equal(MediaTypeNames.Application.Json, res2.Content.Headers.ContentType?.MediaType);+ var getResponse = await client.GetAsync("/Startup/User").ConfigureAwait(false);+ Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);+ Assert.Equal(MediaTypeNames.Application.Json, getResponse.Content.Headers.ContentType?.MediaType);- var content2 = await res2.Content.ReadAsStreamAsync().ConfigureAwait(false);- var user2 = await JsonSerializer.DeserializeAsync<StartupUserDto>(content2, _jsonOpions).ConfigureAwait(false);- Assert.Equal(user.Name, user2!.Name);- Assert.NotEmpty(user2.Password);- Assert.NotEqual(user.Password, user2.Password);+ var contentStream = await getResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);+ var newUser = await JsonSerializer.DeserializeAsync<StartupUserDto>(contentStream, _jsonOptions).ConfigureAwait(false);+ Assert.Equal(user.Name, newUser!.Name);+ Assert.NotEmpty(newUser.Password);+ Assert.NotEqual(user.Password, newUser.Password);}[Fact]- [Priority(1)]+ [Priority(0)]public async Task CompleteWizard_Success(){var client = _factory.CreateClient();- var res = await client.PostAsync("/Startup/Complete", new ByteArrayContent(Array.Empty<byte>())).ConfigureAwait(false);- Assert.Equal(HttpStatusCode.NoContent, res.StatusCode);+ var response = await client.PostAsync("/Startup/Complete", new ByteArrayContent(Array.Empty<byte>())).ConfigureAwait(false);+ Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);}[Fact]- [Priority(2)]+ [Priority(1)]public async Task GetFirstUser_CompleteWizard_Unauthorized(){var client = _factory.CreateClient();- using var res0 = await client.GetAsync("/Startup/User").ConfigureAwait(false);- Assert.Equal(HttpStatusCode.Unauthorized, res0.StatusCode);+ using var response = await client.GetAsync("/Startup/User").ConfigureAwait(false);+ Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);}}}