mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
[PM-2196] Improvements to the Swagger generator (#2914)
* Swagger fixes Co-Authored-By: Oscar Hinton <Hinton@users.noreply.github.com> * Make Response Models return Guids instead of strings * Change strings into guids in ScimApplicationFactory --------- Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
This commit is contained in:
@ -24,8 +24,6 @@ public class AccountsControllerTest : IClassFixture<ApiApplicationFactory>
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var content = await response.Content.ReadFromJsonAsync<ProfileResponseModel>();
|
||||
|
||||
Assert.NotEmpty(content!.Id);
|
||||
Assert.Equal("integration-test@bitwarden.com", content.Email);
|
||||
Assert.Null(content.Name);
|
||||
Assert.False(content.EmailVerified);
|
||||
|
@ -513,7 +513,7 @@ public class AccessPoliciesControllerTests : IClassFixture<ApiApplicationFactory
|
||||
|
||||
Assert.NotNull(result?.Data);
|
||||
Assert.NotEmpty(result!.Data);
|
||||
Assert.Equal(serviceAccount.Id.ToString(), result.Data.First(x => x.Id == serviceAccount.Id.ToString()).Id);
|
||||
Assert.Equal(serviceAccount.Id, result.Data.First(x => x.Id == serviceAccount.Id).Id);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@ -591,7 +591,7 @@ public class AccessPoliciesControllerTests : IClassFixture<ApiApplicationFactory
|
||||
|
||||
Assert.NotNull(result?.Data);
|
||||
Assert.NotEmpty(result!.Data);
|
||||
Assert.Equal(project.Id.ToString(), result.Data.First(x => x.Id == project.Id.ToString()).Id);
|
||||
Assert.Equal(project.Id, result.Data.First(x => x.Id == project.Id).Id);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
@ -144,7 +144,7 @@ public class ProjectsControllerTests : IClassFixture<ApiApplicationFactory>, IAs
|
||||
AssertHelper.AssertRecent(result.RevisionDate);
|
||||
AssertHelper.AssertRecent(result.CreationDate);
|
||||
|
||||
var createdProject = await _projectRepository.GetByIdAsync(new Guid(result.Id));
|
||||
var createdProject = await _projectRepository.GetByIdAsync(result.Id);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Name, createdProject.Name);
|
||||
AssertHelper.AssertRecent(createdProject.RevisionDate);
|
||||
@ -205,7 +205,7 @@ public class ProjectsControllerTests : IClassFixture<ApiApplicationFactory>, IAs
|
||||
AssertHelper.AssertRecent(result.RevisionDate);
|
||||
Assert.NotEqual(initialProject.RevisionDate, result.RevisionDate);
|
||||
|
||||
var updatedProject = await _projectRepository.GetByIdAsync(new Guid(result.Id));
|
||||
var updatedProject = await _projectRepository.GetByIdAsync(result.Id);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Name, updatedProject.Name);
|
||||
AssertHelper.AssertRecent(updatedProject.RevisionDate);
|
||||
|
@ -166,7 +166,7 @@ public class SecretsControllerTests : IClassFixture<ApiApplicationFactory>, IAsy
|
||||
AssertHelper.AssertRecent(result.RevisionDate);
|
||||
AssertHelper.AssertRecent(result.CreationDate);
|
||||
|
||||
var createdSecret = await _secretRepository.GetByIdAsync(new Guid(result.Id));
|
||||
var createdSecret = await _secretRepository.GetByIdAsync(result.Id);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Key, createdSecret.Key);
|
||||
Assert.Equal(request.Value, createdSecret.Value);
|
||||
@ -286,8 +286,8 @@ public class SecretsControllerTests : IClassFixture<ApiApplicationFactory>, IAsy
|
||||
var secret = result.Secret;
|
||||
|
||||
Assert.NotNull(secretResult);
|
||||
Assert.Equal(secret.Id.ToString(), secretResult!.Id);
|
||||
Assert.Equal(secret.OrganizationId.ToString(), secretResult.OrganizationId);
|
||||
Assert.Equal(secret.Id, secretResult!.Id);
|
||||
Assert.Equal(secret.OrganizationId, secretResult.OrganizationId);
|
||||
Assert.Equal(secret.Key, secretResult.Key);
|
||||
Assert.Equal(secret.Value, secretResult.Value);
|
||||
Assert.Equal(secret.Note, secretResult.Note);
|
||||
@ -463,8 +463,8 @@ public class SecretsControllerTests : IClassFixture<ApiApplicationFactory>, IAsy
|
||||
response.EnsureSuccessStatusCode();
|
||||
var result = await response.Content.ReadFromJsonAsync<SecretWithProjectsListResponseModel>();
|
||||
Assert.NotEmpty(result!.Secrets);
|
||||
Assert.Equal(secret.Id.ToString(), result.Secrets.First().Id);
|
||||
Assert.Equal(secret.OrganizationId.ToString(), result.Secrets.First().OrganizationId);
|
||||
Assert.Equal(secret.Id, result.Secrets.First().Id);
|
||||
Assert.Equal(secret.OrganizationId, result.Secrets.First().OrganizationId);
|
||||
Assert.Equal(secret.Key, result.Secrets.First().Key);
|
||||
Assert.Equal(secret.CreationDate, result.Secrets.First().CreationDate);
|
||||
Assert.Equal(secret.RevisionDate, result.Secrets.First().RevisionDate);
|
||||
@ -557,7 +557,7 @@ public class SecretsControllerTests : IClassFixture<ApiApplicationFactory>, IAsy
|
||||
AssertHelper.AssertRecent(result.RevisionDate);
|
||||
Assert.NotEqual(secret.RevisionDate, result.RevisionDate);
|
||||
|
||||
var updatedSecret = await _secretRepository.GetByIdAsync(new Guid(result.Id));
|
||||
var updatedSecret = await _secretRepository.GetByIdAsync(result.Id);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Key, updatedSecret.Key);
|
||||
Assert.Equal(request.Value, updatedSecret.Value);
|
||||
|
@ -177,8 +177,8 @@ public class ServiceAccountsControllerTests : IClassFixture<ApiApplicationFactor
|
||||
response.EnsureSuccessStatusCode();
|
||||
var result = await response.Content.ReadFromJsonAsync<ServiceAccountResponseModel>();
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(serviceAccount.Id.ToString(), result!.Id);
|
||||
Assert.Equal(serviceAccount.OrganizationId.ToString(), result.OrganizationId);
|
||||
Assert.Equal(serviceAccount.Id, result!.Id);
|
||||
Assert.Equal(serviceAccount.OrganizationId, result.OrganizationId);
|
||||
Assert.Equal(serviceAccount.Name, result.Name);
|
||||
Assert.Equal(serviceAccount.CreationDate, result.CreationDate);
|
||||
Assert.Equal(serviceAccount.RevisionDate, result.RevisionDate);
|
||||
@ -229,7 +229,7 @@ public class ServiceAccountsControllerTests : IClassFixture<ApiApplicationFactor
|
||||
AssertHelper.AssertRecent(result.RevisionDate);
|
||||
AssertHelper.AssertRecent(result.CreationDate);
|
||||
|
||||
var createdServiceAccount = await _serviceAccountRepository.GetByIdAsync(new Guid(result.Id));
|
||||
var createdServiceAccount = await _serviceAccountRepository.GetByIdAsync(result.Id);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.Name, createdServiceAccount.Name);
|
||||
AssertHelper.AssertRecent(createdServiceAccount.RevisionDate);
|
||||
|
@ -33,10 +33,8 @@ public class GroupsControllerTests
|
||||
organization,
|
||||
Arg.Any<IEnumerable<CollectionAccessSelection>>(),
|
||||
Arg.Any<IEnumerable<Guid>>());
|
||||
|
||||
Assert.NotNull(response.Id);
|
||||
Assert.Equal(groupRequestModel.Name, response.Name);
|
||||
Assert.Equal(organization.Id.ToString(), response.OrganizationId);
|
||||
Assert.Equal(organization.Id, response.OrganizationId);
|
||||
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
|
||||
}
|
||||
|
||||
@ -60,10 +58,8 @@ public class GroupsControllerTests
|
||||
Arg.Is<Organization>(o => o.Id == organization.Id),
|
||||
Arg.Any<IEnumerable<CollectionAccessSelection>>(),
|
||||
Arg.Any<IEnumerable<Guid>>());
|
||||
|
||||
Assert.NotNull(response.Id);
|
||||
Assert.Equal(groupRequestModel.Name, response.Name);
|
||||
Assert.Equal(organization.Id.ToString(), response.OrganizationId);
|
||||
Assert.Equal(organization.Id, response.OrganizationId);
|
||||
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class OrganizationDomainControllerTests
|
||||
var result = await sutProvider.Sut.Get(orgId.ToString());
|
||||
|
||||
Assert.IsType<ListResponseModel<OrganizationDomainResponseModel>>(result);
|
||||
Assert.Equal(orgId.ToString(), result.Data.Select(x => x.OrganizationId).FirstOrDefault());
|
||||
Assert.Equal(orgId, result.Data.Select(x => x.OrganizationId).FirstOrDefault());
|
||||
}
|
||||
|
||||
[Theory, BitAutoData]
|
||||
@ -125,7 +125,7 @@ public class OrganizationDomainControllerTests
|
||||
var result = await sutProvider.Sut.Get(orgId.ToString(), id.ToString());
|
||||
|
||||
Assert.IsType<OrganizationDomainResponseModel>(result);
|
||||
Assert.Equal(orgId.ToString(), result.OrganizationId);
|
||||
Assert.Equal(orgId, result.OrganizationId);
|
||||
}
|
||||
|
||||
[Theory, BitAutoData]
|
||||
|
@ -39,7 +39,7 @@ public class CiphersControllerTests
|
||||
|
||||
var result = await sutProvider.Sut.PutPartial(cipherId.ToString(), new CipherPartialRequestModel { Favorite = isFavorite, FolderId = folderId.ToString() });
|
||||
|
||||
Assert.Equal(folderId.ToString(), result.FolderId);
|
||||
Assert.Equal(folderId, result.FolderId);
|
||||
Assert.Equal(isFavorite, result.Favorite);
|
||||
}
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ public class SyncControllerTests
|
||||
foreach (var profProviderOrg in result.Profile.ProviderOrganizations)
|
||||
{
|
||||
var matchedProviderUserOrgDetails =
|
||||
providerUserOrganizationDetails.FirstOrDefault(p => p.OrganizationId.ToString() == profProviderOrg.Id);
|
||||
providerUserOrganizationDetails.FirstOrDefault(p => p.OrganizationId == profProviderOrg.Id);
|
||||
|
||||
if (matchedProviderUserOrgDetails != null)
|
||||
{
|
||||
|
Reference in New Issue
Block a user