mirror of
https://github.com/bitwarden/server.git
synced 2025-04-13 00:58:13 -05:00
WIP
This commit is contained in:
parent
08924e10d2
commit
989f64d449
@ -150,6 +150,7 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
|
|||||||
FriendlyName = friendlyName,
|
FriendlyName = friendlyName,
|
||||||
OfferedToEmail = sponsoredEmail,
|
OfferedToEmail = sponsoredEmail,
|
||||||
PlanSponsorshipType = PlanSponsorshipType.FamiliesForEnterprise,
|
PlanSponsorshipType = PlanSponsorshipType.FamiliesForEnterprise,
|
||||||
|
IsAdminInitiated = false
|
||||||
};
|
};
|
||||||
|
|
||||||
await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().Received(1)
|
await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().Received(1)
|
||||||
@ -253,4 +254,54 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
|
|||||||
|
|
||||||
Assert.Equal("You do not have permissions to send sponsorships on behalf of the organization.", actual.Message);
|
Assert.Equal("You do not have permissions to send sponsorships on behalf of the organization.", actual.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[BitAutoData(OrganizationUserType.Admin)]
|
||||||
|
[BitAutoData(OrganizationUserType.Custom)]
|
||||||
|
[BitAutoData(OrganizationUserType.Owner)]
|
||||||
|
public async Task CreateSponsorship_CreatesAdminInitiatedSponsorship(
|
||||||
|
OrganizationUserType organizationUserType,
|
||||||
|
Organization sponsoringOrg, OrganizationUser sponsoringOrgUser, User user, string sponsoredEmail,
|
||||||
|
string friendlyName, Guid sponsorshipId, Guid currentUserId, SutProvider<CreateSponsorshipCommand> sutProvider)
|
||||||
|
{
|
||||||
|
sponsoringOrg.PlanType = PlanType.EnterpriseAnnually;
|
||||||
|
sponsoringOrgUser.Status = OrganizationUserStatusType.Confirmed;
|
||||||
|
|
||||||
|
sutProvider.GetDependency<IUserService>().GetUserByIdAsync(sponsoringOrgUser.UserId.Value).Returns(user);
|
||||||
|
sutProvider.GetDependency<IOrganizationSponsorshipRepository>().WhenForAnyArgs(x => x.UpsertAsync(default)).Do(callInfo =>
|
||||||
|
{
|
||||||
|
var sponsorship = callInfo.Arg<OrganizationSponsorship>();
|
||||||
|
sponsorship.Id = sponsorshipId;
|
||||||
|
});
|
||||||
|
sutProvider.GetDependency<ICurrentContext>().UserId.Returns(currentUserId);
|
||||||
|
sutProvider.GetDependency<ICurrentContext>().Organizations.Returns([
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Id = sponsoringOrg.Id,
|
||||||
|
Permissions = new Permissions
|
||||||
|
{
|
||||||
|
ManageUsers = true,
|
||||||
|
},
|
||||||
|
Type = organizationUserType
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
await sutProvider.Sut.CreateSponsorshipAsync(sponsoringOrg, sponsoringOrgUser,
|
||||||
|
PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, friendlyName);
|
||||||
|
|
||||||
|
|
||||||
|
var expectedSponsorship = new OrganizationSponsorship
|
||||||
|
{
|
||||||
|
Id = sponsorshipId,
|
||||||
|
SponsoringOrganizationId = sponsoringOrg.Id,
|
||||||
|
SponsoringOrganizationUserId = sponsoringOrgUser.Id,
|
||||||
|
FriendlyName = friendlyName,
|
||||||
|
OfferedToEmail = sponsoredEmail,
|
||||||
|
PlanSponsorshipType = PlanSponsorshipType.FamiliesForEnterprise,
|
||||||
|
IsAdminInitiated = true
|
||||||
|
};
|
||||||
|
|
||||||
|
await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().Received(1)
|
||||||
|
.UpsertAsync(Arg.Is<OrganizationSponsorship>(s => SponsorshipValidator(s, expectedSponsorship)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user