1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

[AC-2699] Remove AccessAll from api request/response models (#4203)

This commit is contained in:
Thomas Rittson 2024-06-21 09:00:01 +10:00 committed by GitHub
parent 01d67dce48
commit 6262686c0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 6 additions and 29 deletions

View File

@ -9,7 +9,6 @@ public class GroupRequestModel
[Required]
[StringLength(100)]
public string Name { get; set; }
public bool? AccessAll { get; set; }
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
public IEnumerable<Guid> Users { get; set; }
@ -24,7 +23,6 @@ public class GroupRequestModel
public Group ToGroup(Group existingGroup)
{
existingGroup.Name = Name;
existingGroup.AccessAll = AccessAll ?? false;
return existingGroup;
}
}

View File

@ -15,7 +15,6 @@ public class OrganizationUserInviteRequestModel
public IEnumerable<string> Emails { get; set; }
[Required]
public OrganizationUserType? Type { get; set; }
public bool AccessAll { get; set; }
public bool AccessSecretsManager { get; set; }
public Permissions Permissions { get; set; }
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
@ -27,7 +26,6 @@ public class OrganizationUserInviteRequestModel
{
Emails = Emails,
Type = Type,
AccessAll = AccessAll,
AccessSecretsManager = AccessSecretsManager,
Collections = Collections?.Select(c => c.ToSelectionReadOnly()),
Groups = Groups,
@ -86,7 +84,6 @@ public class OrganizationUserUpdateRequestModel
{
[Required]
public OrganizationUserType? Type { get; set; }
public bool AccessAll { get; set; }
public bool AccessSecretsManager { get; set; }
public Permissions Permissions { get; set; }
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
@ -96,7 +93,6 @@ public class OrganizationUserUpdateRequestModel
{
existingUser.Type = Type.Value;
existingUser.Permissions = CoreHelpers.ClassToJsonData(Permissions);
existingUser.AccessAll = AccessAll;
existingUser.AccessSecretsManager = AccessSecretsManager;
return existingUser;
}

View File

@ -18,14 +18,12 @@ public class GroupResponseModel : ResponseModel
Id = group.Id;
OrganizationId = group.OrganizationId;
Name = group.Name;
AccessAll = group.AccessAll;
ExternalId = group.ExternalId;
}
public Guid Id { get; set; }
public Guid OrganizationId { get; set; }
public string Name { get; set; }
public bool AccessAll { get; set; }
public string ExternalId { get; set; }
}

View File

@ -23,7 +23,6 @@ public class OrganizationUserResponseModel : ResponseModel
UserId = organizationUser.UserId;
Type = organizationUser.Type;
Status = organizationUser.Status;
AccessAll = organizationUser.AccessAll;
ExternalId = organizationUser.ExternalId;
AccessSecretsManager = organizationUser.AccessSecretsManager;
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(organizationUser.Permissions);
@ -42,7 +41,6 @@ public class OrganizationUserResponseModel : ResponseModel
UserId = organizationUser.UserId;
Type = organizationUser.Type;
Status = organizationUser.Status;
AccessAll = organizationUser.AccessAll;
ExternalId = organizationUser.ExternalId;
AccessSecretsManager = organizationUser.AccessSecretsManager;
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(organizationUser.Permissions);
@ -55,7 +53,6 @@ public class OrganizationUserResponseModel : ResponseModel
public Guid? UserId { get; set; }
public OrganizationUserType Type { get; set; }
public OrganizationUserStatusType Status { get; set; }
public bool AccessAll { get; set; }
public string ExternalId { get; set; }
public bool AccessSecretsManager { get; set; }
public Permissions Permissions { get; set; }

View File

@ -39,14 +39,12 @@ public class GroupsControllerTests
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
await sutProvider.GetDependency<ICreateGroupCommand>().Received(1).CreateGroupAsync(
Arg.Is<Group>(g =>
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name &&
g.AccessAll == groupRequestModel.AccessAll),
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name),
organization,
Arg.Any<ICollection<CollectionAccessSelection>>(),
Arg.Any<IEnumerable<Guid>>());
Assert.Equal(groupRequestModel.Name, response.Name);
Assert.Equal(organization.Id, response.OrganizationId);
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
}
[Theory]
@ -85,15 +83,13 @@ public class GroupsControllerTests
// Assert that it saved the data
await sutProvider.GetDependency<ICreateGroupCommand>().Received(1).CreateGroupAsync(
Arg.Is<Group>(g =>
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name &&
g.AccessAll == groupRequestModel.AccessAll),
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name),
organization,
Arg.Is<ICollection<CollectionAccessSelection>>(access =>
access.All(c => requestModelCollectionIds.Contains(c.Id))),
Arg.Any<IEnumerable<Guid>>());
Assert.Equal(groupRequestModel.Name, response.Name);
Assert.Equal(organization.Id, response.OrganizationId);
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
}
[Theory]
@ -151,8 +147,7 @@ public class GroupsControllerTests
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
await sutProvider.GetDependency<IUpdateGroupCommand>().Received(1).UpdateGroupAsync(
Arg.Is<Group>(g =>
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name &&
g.AccessAll == groupRequestModel.AccessAll),
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name),
Arg.Is<Organization>(o => o.Id == organization.Id),
// Should overwrite any existing collections
Arg.Is<ICollection<CollectionAccessSelection>>(access =>
@ -160,7 +155,6 @@ public class GroupsControllerTests
Arg.Any<IEnumerable<Guid>>());
Assert.Equal(groupRequestModel.Name, response.Name);
Assert.Equal(organization.Id, response.OrganizationId);
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
}
[Theory]
@ -248,14 +242,12 @@ public class GroupsControllerTests
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
await sutProvider.GetDependency<IUpdateGroupCommand>().Received(1).UpdateGroupAsync(
Arg.Is<Group>(g =>
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name &&
g.AccessAll == groupRequestModel.AccessAll),
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name),
Arg.Is<Organization>(o => o.Id == organization.Id),
Arg.Any<ICollection<CollectionAccessSelection>>(),
Arg.Any<IEnumerable<Guid>>());
Assert.Equal(groupRequestModel.Name, response.Name);
Assert.Equal(organization.Id, response.OrganizationId);
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
}
[Theory]
@ -295,14 +287,12 @@ public class GroupsControllerTests
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
await sutProvider.GetDependency<IUpdateGroupCommand>().Received(1).UpdateGroupAsync(
Arg.Is<Group>(g =>
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name &&
g.AccessAll == groupRequestModel.AccessAll),
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name),
Arg.Is<Organization>(o => o.Id == organization.Id),
Arg.Any<ICollection<CollectionAccessSelection>>(),
Arg.Any<IEnumerable<Guid>>());
Assert.Equal(groupRequestModel.Name, response.Name);
Assert.Equal(organization.Id, response.OrganizationId);
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
}
[Theory]
@ -378,8 +368,7 @@ public class GroupsControllerTests
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
await sutProvider.GetDependency<IUpdateGroupCommand>().Received(1).UpdateGroupAsync(
Arg.Is<Group>(g =>
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name &&
g.AccessAll == groupRequestModel.AccessAll),
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name),
Arg.Is<Organization>(o => o.Id == organization.Id),
Arg.Is<List<CollectionAccessSelection>>(cas =>
cas.Select(c => c.Id).SequenceEqual(currentCollectionAccess.Select(c => c.Id)) &&
@ -389,7 +378,6 @@ public class GroupsControllerTests
Arg.Any<IEnumerable<Guid>>());
Assert.Equal(groupRequestModel.Name, response.Name);
Assert.Equal(organization.Id, response.OrganizationId);
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
}
[Theory]