mirror of
https://github.com/bitwarden/server.git
synced 2025-05-20 19:14:32 -05:00
[AC-2699] Remove AccessAll from api request/response models (#4203)
This commit is contained in:
parent
01d67dce48
commit
6262686c0c
@ -9,7 +9,6 @@ public class GroupRequestModel
|
|||||||
[Required]
|
[Required]
|
||||||
[StringLength(100)]
|
[StringLength(100)]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public bool? AccessAll { get; set; }
|
|
||||||
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
|
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
|
||||||
public IEnumerable<Guid> Users { get; set; }
|
public IEnumerable<Guid> Users { get; set; }
|
||||||
|
|
||||||
@ -24,7 +23,6 @@ public class GroupRequestModel
|
|||||||
public Group ToGroup(Group existingGroup)
|
public Group ToGroup(Group existingGroup)
|
||||||
{
|
{
|
||||||
existingGroup.Name = Name;
|
existingGroup.Name = Name;
|
||||||
existingGroup.AccessAll = AccessAll ?? false;
|
|
||||||
return existingGroup;
|
return existingGroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ public class OrganizationUserInviteRequestModel
|
|||||||
public IEnumerable<string> Emails { get; set; }
|
public IEnumerable<string> Emails { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public OrganizationUserType? Type { get; set; }
|
public OrganizationUserType? Type { get; set; }
|
||||||
public bool AccessAll { get; set; }
|
|
||||||
public bool AccessSecretsManager { get; set; }
|
public bool AccessSecretsManager { get; set; }
|
||||||
public Permissions Permissions { get; set; }
|
public Permissions Permissions { get; set; }
|
||||||
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
|
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
|
||||||
@ -27,7 +26,6 @@ public class OrganizationUserInviteRequestModel
|
|||||||
{
|
{
|
||||||
Emails = Emails,
|
Emails = Emails,
|
||||||
Type = Type,
|
Type = Type,
|
||||||
AccessAll = AccessAll,
|
|
||||||
AccessSecretsManager = AccessSecretsManager,
|
AccessSecretsManager = AccessSecretsManager,
|
||||||
Collections = Collections?.Select(c => c.ToSelectionReadOnly()),
|
Collections = Collections?.Select(c => c.ToSelectionReadOnly()),
|
||||||
Groups = Groups,
|
Groups = Groups,
|
||||||
@ -86,7 +84,6 @@ public class OrganizationUserUpdateRequestModel
|
|||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
public OrganizationUserType? Type { get; set; }
|
public OrganizationUserType? Type { get; set; }
|
||||||
public bool AccessAll { get; set; }
|
|
||||||
public bool AccessSecretsManager { get; set; }
|
public bool AccessSecretsManager { get; set; }
|
||||||
public Permissions Permissions { get; set; }
|
public Permissions Permissions { get; set; }
|
||||||
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
|
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
|
||||||
@ -96,7 +93,6 @@ public class OrganizationUserUpdateRequestModel
|
|||||||
{
|
{
|
||||||
existingUser.Type = Type.Value;
|
existingUser.Type = Type.Value;
|
||||||
existingUser.Permissions = CoreHelpers.ClassToJsonData(Permissions);
|
existingUser.Permissions = CoreHelpers.ClassToJsonData(Permissions);
|
||||||
existingUser.AccessAll = AccessAll;
|
|
||||||
existingUser.AccessSecretsManager = AccessSecretsManager;
|
existingUser.AccessSecretsManager = AccessSecretsManager;
|
||||||
return existingUser;
|
return existingUser;
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,12 @@ public class GroupResponseModel : ResponseModel
|
|||||||
Id = group.Id;
|
Id = group.Id;
|
||||||
OrganizationId = group.OrganizationId;
|
OrganizationId = group.OrganizationId;
|
||||||
Name = group.Name;
|
Name = group.Name;
|
||||||
AccessAll = group.AccessAll;
|
|
||||||
ExternalId = group.ExternalId;
|
ExternalId = group.ExternalId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public Guid OrganizationId { get; set; }
|
public Guid OrganizationId { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public bool AccessAll { get; set; }
|
|
||||||
public string ExternalId { get; set; }
|
public string ExternalId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ public class OrganizationUserResponseModel : ResponseModel
|
|||||||
UserId = organizationUser.UserId;
|
UserId = organizationUser.UserId;
|
||||||
Type = organizationUser.Type;
|
Type = organizationUser.Type;
|
||||||
Status = organizationUser.Status;
|
Status = organizationUser.Status;
|
||||||
AccessAll = organizationUser.AccessAll;
|
|
||||||
ExternalId = organizationUser.ExternalId;
|
ExternalId = organizationUser.ExternalId;
|
||||||
AccessSecretsManager = organizationUser.AccessSecretsManager;
|
AccessSecretsManager = organizationUser.AccessSecretsManager;
|
||||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(organizationUser.Permissions);
|
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(organizationUser.Permissions);
|
||||||
@ -42,7 +41,6 @@ public class OrganizationUserResponseModel : ResponseModel
|
|||||||
UserId = organizationUser.UserId;
|
UserId = organizationUser.UserId;
|
||||||
Type = organizationUser.Type;
|
Type = organizationUser.Type;
|
||||||
Status = organizationUser.Status;
|
Status = organizationUser.Status;
|
||||||
AccessAll = organizationUser.AccessAll;
|
|
||||||
ExternalId = organizationUser.ExternalId;
|
ExternalId = organizationUser.ExternalId;
|
||||||
AccessSecretsManager = organizationUser.AccessSecretsManager;
|
AccessSecretsManager = organizationUser.AccessSecretsManager;
|
||||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(organizationUser.Permissions);
|
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(organizationUser.Permissions);
|
||||||
@ -55,7 +53,6 @@ public class OrganizationUserResponseModel : ResponseModel
|
|||||||
public Guid? UserId { get; set; }
|
public Guid? UserId { get; set; }
|
||||||
public OrganizationUserType Type { get; set; }
|
public OrganizationUserType Type { get; set; }
|
||||||
public OrganizationUserStatusType Status { get; set; }
|
public OrganizationUserStatusType Status { get; set; }
|
||||||
public bool AccessAll { get; set; }
|
|
||||||
public string ExternalId { get; set; }
|
public string ExternalId { get; set; }
|
||||||
public bool AccessSecretsManager { get; set; }
|
public bool AccessSecretsManager { get; set; }
|
||||||
public Permissions Permissions { get; set; }
|
public Permissions Permissions { get; set; }
|
||||||
|
@ -39,14 +39,12 @@ public class GroupsControllerTests
|
|||||||
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
|
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
|
||||||
await sutProvider.GetDependency<ICreateGroupCommand>().Received(1).CreateGroupAsync(
|
await sutProvider.GetDependency<ICreateGroupCommand>().Received(1).CreateGroupAsync(
|
||||||
Arg.Is<Group>(g =>
|
Arg.Is<Group>(g =>
|
||||||
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name &&
|
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name),
|
||||||
g.AccessAll == groupRequestModel.AccessAll),
|
|
||||||
organization,
|
organization,
|
||||||
Arg.Any<ICollection<CollectionAccessSelection>>(),
|
Arg.Any<ICollection<CollectionAccessSelection>>(),
|
||||||
Arg.Any<IEnumerable<Guid>>());
|
Arg.Any<IEnumerable<Guid>>());
|
||||||
Assert.Equal(groupRequestModel.Name, response.Name);
|
Assert.Equal(groupRequestModel.Name, response.Name);
|
||||||
Assert.Equal(organization.Id, response.OrganizationId);
|
Assert.Equal(organization.Id, response.OrganizationId);
|
||||||
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
@ -85,15 +83,13 @@ public class GroupsControllerTests
|
|||||||
// Assert that it saved the data
|
// Assert that it saved the data
|
||||||
await sutProvider.GetDependency<ICreateGroupCommand>().Received(1).CreateGroupAsync(
|
await sutProvider.GetDependency<ICreateGroupCommand>().Received(1).CreateGroupAsync(
|
||||||
Arg.Is<Group>(g =>
|
Arg.Is<Group>(g =>
|
||||||
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name &&
|
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name),
|
||||||
g.AccessAll == groupRequestModel.AccessAll),
|
|
||||||
organization,
|
organization,
|
||||||
Arg.Is<ICollection<CollectionAccessSelection>>(access =>
|
Arg.Is<ICollection<CollectionAccessSelection>>(access =>
|
||||||
access.All(c => requestModelCollectionIds.Contains(c.Id))),
|
access.All(c => requestModelCollectionIds.Contains(c.Id))),
|
||||||
Arg.Any<IEnumerable<Guid>>());
|
Arg.Any<IEnumerable<Guid>>());
|
||||||
Assert.Equal(groupRequestModel.Name, response.Name);
|
Assert.Equal(groupRequestModel.Name, response.Name);
|
||||||
Assert.Equal(organization.Id, response.OrganizationId);
|
Assert.Equal(organization.Id, response.OrganizationId);
|
||||||
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
@ -151,8 +147,7 @@ public class GroupsControllerTests
|
|||||||
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
|
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
|
||||||
await sutProvider.GetDependency<IUpdateGroupCommand>().Received(1).UpdateGroupAsync(
|
await sutProvider.GetDependency<IUpdateGroupCommand>().Received(1).UpdateGroupAsync(
|
||||||
Arg.Is<Group>(g =>
|
Arg.Is<Group>(g =>
|
||||||
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name &&
|
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name),
|
||||||
g.AccessAll == groupRequestModel.AccessAll),
|
|
||||||
Arg.Is<Organization>(o => o.Id == organization.Id),
|
Arg.Is<Organization>(o => o.Id == organization.Id),
|
||||||
// Should overwrite any existing collections
|
// Should overwrite any existing collections
|
||||||
Arg.Is<ICollection<CollectionAccessSelection>>(access =>
|
Arg.Is<ICollection<CollectionAccessSelection>>(access =>
|
||||||
@ -160,7 +155,6 @@ public class GroupsControllerTests
|
|||||||
Arg.Any<IEnumerable<Guid>>());
|
Arg.Any<IEnumerable<Guid>>());
|
||||||
Assert.Equal(groupRequestModel.Name, response.Name);
|
Assert.Equal(groupRequestModel.Name, response.Name);
|
||||||
Assert.Equal(organization.Id, response.OrganizationId);
|
Assert.Equal(organization.Id, response.OrganizationId);
|
||||||
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
@ -248,14 +242,12 @@ public class GroupsControllerTests
|
|||||||
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
|
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
|
||||||
await sutProvider.GetDependency<IUpdateGroupCommand>().Received(1).UpdateGroupAsync(
|
await sutProvider.GetDependency<IUpdateGroupCommand>().Received(1).UpdateGroupAsync(
|
||||||
Arg.Is<Group>(g =>
|
Arg.Is<Group>(g =>
|
||||||
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name &&
|
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name),
|
||||||
g.AccessAll == groupRequestModel.AccessAll),
|
|
||||||
Arg.Is<Organization>(o => o.Id == organization.Id),
|
Arg.Is<Organization>(o => o.Id == organization.Id),
|
||||||
Arg.Any<ICollection<CollectionAccessSelection>>(),
|
Arg.Any<ICollection<CollectionAccessSelection>>(),
|
||||||
Arg.Any<IEnumerable<Guid>>());
|
Arg.Any<IEnumerable<Guid>>());
|
||||||
Assert.Equal(groupRequestModel.Name, response.Name);
|
Assert.Equal(groupRequestModel.Name, response.Name);
|
||||||
Assert.Equal(organization.Id, response.OrganizationId);
|
Assert.Equal(organization.Id, response.OrganizationId);
|
||||||
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
@ -295,14 +287,12 @@ public class GroupsControllerTests
|
|||||||
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
|
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
|
||||||
await sutProvider.GetDependency<IUpdateGroupCommand>().Received(1).UpdateGroupAsync(
|
await sutProvider.GetDependency<IUpdateGroupCommand>().Received(1).UpdateGroupAsync(
|
||||||
Arg.Is<Group>(g =>
|
Arg.Is<Group>(g =>
|
||||||
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name &&
|
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name),
|
||||||
g.AccessAll == groupRequestModel.AccessAll),
|
|
||||||
Arg.Is<Organization>(o => o.Id == organization.Id),
|
Arg.Is<Organization>(o => o.Id == organization.Id),
|
||||||
Arg.Any<ICollection<CollectionAccessSelection>>(),
|
Arg.Any<ICollection<CollectionAccessSelection>>(),
|
||||||
Arg.Any<IEnumerable<Guid>>());
|
Arg.Any<IEnumerable<Guid>>());
|
||||||
Assert.Equal(groupRequestModel.Name, response.Name);
|
Assert.Equal(groupRequestModel.Name, response.Name);
|
||||||
Assert.Equal(organization.Id, response.OrganizationId);
|
Assert.Equal(organization.Id, response.OrganizationId);
|
||||||
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
@ -378,8 +368,7 @@ public class GroupsControllerTests
|
|||||||
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
|
await sutProvider.GetDependency<ICurrentContext>().Received(1).ManageGroups(organization.Id);
|
||||||
await sutProvider.GetDependency<IUpdateGroupCommand>().Received(1).UpdateGroupAsync(
|
await sutProvider.GetDependency<IUpdateGroupCommand>().Received(1).UpdateGroupAsync(
|
||||||
Arg.Is<Group>(g =>
|
Arg.Is<Group>(g =>
|
||||||
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name &&
|
g.OrganizationId == organization.Id && g.Name == groupRequestModel.Name),
|
||||||
g.AccessAll == groupRequestModel.AccessAll),
|
|
||||||
Arg.Is<Organization>(o => o.Id == organization.Id),
|
Arg.Is<Organization>(o => o.Id == organization.Id),
|
||||||
Arg.Is<List<CollectionAccessSelection>>(cas =>
|
Arg.Is<List<CollectionAccessSelection>>(cas =>
|
||||||
cas.Select(c => c.Id).SequenceEqual(currentCollectionAccess.Select(c => c.Id)) &&
|
cas.Select(c => c.Id).SequenceEqual(currentCollectionAccess.Select(c => c.Id)) &&
|
||||||
@ -389,7 +378,6 @@ public class GroupsControllerTests
|
|||||||
Arg.Any<IEnumerable<Guid>>());
|
Arg.Any<IEnumerable<Guid>>());
|
||||||
Assert.Equal(groupRequestModel.Name, response.Name);
|
Assert.Equal(groupRequestModel.Name, response.Name);
|
||||||
Assert.Equal(organization.Id, response.OrganizationId);
|
Assert.Equal(organization.Id, response.OrganizationId);
|
||||||
Assert.Equal(groupRequestModel.AccessAll, response.AccessAll);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user