mirror of
https://github.com/bitwarden/server.git
synced 2024-11-29 13:25:17 +01:00
Send f4e offer email
This commit is contained in:
parent
8480379e32
commit
094de41c0e
@ -50,10 +50,8 @@ namespace Bit.Core.Services
|
|||||||
Task SendProviderUserRemoved(string providerName, string email);
|
Task SendProviderUserRemoved(string providerName, string email);
|
||||||
Task SendUpdatedTempPasswordEmailAsync(string email, string userName);
|
Task SendUpdatedTempPasswordEmailAsync(string email, string userName);
|
||||||
// TODO: Change signature to hold data needed for email
|
// TODO: Change signature to hold data needed for email
|
||||||
Task SendFamiliesForEnterpriseInviteRedeemableEmailAsync(string email, string organizationName, string token);
|
Task SendFamiliesForEnterpriseOfferEmailAsync(string email, string organizationName, string token);
|
||||||
// NOTE: Not married to these next two names
|
Task SendFamiliesForEnterpriseRedeemedEmailsAsync(string familyUserEmail, string sponsorEmail, string sponsorOrgName);
|
||||||
Task SendFamiliesForEnterpriseInviteRedeemedToFamilyUserEmailAsync(string email);
|
|
||||||
Task SendFamiliesForEnterpriseInviteRedeemedToOrgUserEmailAsync(string email, string organizationName);
|
|
||||||
Task SendFamiliesForEnterpriseReconfirmationRequiredEmailAsync(string email);
|
Task SendFamiliesForEnterpriseReconfirmationRequiredEmailAsync(string email);
|
||||||
Task SendFamiliesForEnterpriseSponsorshipRevertingEmailAsync(string email);
|
Task SendFamiliesForEnterpriseSponsorshipRevertingEmailAsync(string email);
|
||||||
Task SendFamiliesForEnterpriseSponsorshipEndingEmailAsync(string email);
|
Task SendFamiliesForEnterpriseSponsorshipEndingEmailAsync(string email);
|
||||||
|
@ -757,7 +757,7 @@ namespace Bit.Core.Services
|
|||||||
await _mailDeliveryService.SendEmailAsync(message);
|
await _mailDeliveryService.SendEmailAsync(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SendFamiliesForEnterpriseInviteRedeemableEmailAsync(string email, string organizationName, string token)
|
public async Task SendFamiliesForEnterpriseOfferEmailAsync(string email, string organizationName, string token)
|
||||||
{
|
{
|
||||||
// TODO: Complete emails
|
// TODO: Complete emails
|
||||||
var message = CreateDefaultMessage("A Family Organization Invite Is Redeemable", email);
|
var message = CreateDefaultMessage("A Family Organization Invite Is Redeemable", email);
|
||||||
@ -780,7 +780,17 @@ namespace Bit.Core.Services
|
|||||||
await _mailDeliveryService.SendEmailAsync(message);
|
await _mailDeliveryService.SendEmailAsync(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SendFamiliesForEnterpriseInviteRedeemedToFamilyUserEmailAsync(string email)
|
public async Task SendFamiliesForEnterpriseRedeemedEmailsAsync(string familyUserEmail, string sponsorEmail, string sponsorOrgName)
|
||||||
|
{
|
||||||
|
// TODO: complete emails
|
||||||
|
// Email family user
|
||||||
|
await SendFamiliesForEnterpriseInviteRedeemedToFamilyUserEmailAsync(familyUserEmail);
|
||||||
|
|
||||||
|
// Email enterprise org user
|
||||||
|
await SendFamiliesForEnterpriseInviteRedeemedToOrgUserEmailAsync(sponsorEmail, sponsorOrgName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SendFamiliesForEnterpriseInviteRedeemedToFamilyUserEmailAsync(string email)
|
||||||
{
|
{
|
||||||
// TODO: Complete emails
|
// TODO: Complete emails
|
||||||
var message = CreateDefaultMessage("You Have Redeemed A Family Organization Sponsorship", email);
|
var message = CreateDefaultMessage("You Have Redeemed A Family Organization Sponsorship", email);
|
||||||
@ -793,7 +803,7 @@ namespace Bit.Core.Services
|
|||||||
await _mailDeliveryService.SendEmailAsync(message);
|
await _mailDeliveryService.SendEmailAsync(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SendFamiliesForEnterpriseInviteRedeemedToOrgUserEmailAsync(string email, string organizationName)
|
private async Task SendFamiliesForEnterpriseInviteRedeemedToOrgUserEmailAsync(string email, string organizationName)
|
||||||
{
|
{
|
||||||
// TODO: Complete emails
|
// TODO: Complete emails
|
||||||
var message = CreateDefaultMessage("A User Has Redeemeed Your Sponsorship", email);
|
var message = CreateDefaultMessage("A User Has Redeemeed Your Sponsorship", email);
|
||||||
|
@ -16,16 +16,20 @@ namespace Bit.Core.Services
|
|||||||
private readonly IOrganizationSponsorshipRepository _organizationSponsorshipRepository;
|
private readonly IOrganizationSponsorshipRepository _organizationSponsorshipRepository;
|
||||||
private readonly IOrganizationRepository _organizationRepository;
|
private readonly IOrganizationRepository _organizationRepository;
|
||||||
private readonly IPaymentService _paymentService;
|
private readonly IPaymentService _paymentService;
|
||||||
|
private readonly IMailService _mailService;
|
||||||
|
|
||||||
private readonly IDataProtector _dataProtector;
|
private readonly IDataProtector _dataProtector;
|
||||||
|
|
||||||
public OrganizationSponsorshipService(IOrganizationSponsorshipRepository organizationSponsorshipRepository,
|
public OrganizationSponsorshipService(IOrganizationSponsorshipRepository organizationSponsorshipRepository,
|
||||||
IOrganizationRepository organizationRepository,
|
IOrganizationRepository organizationRepository,
|
||||||
IPaymentService paymentService,
|
IPaymentService paymentService,
|
||||||
|
IMailService mailService,
|
||||||
IDataProtectionProvider dataProtectionProvider)
|
IDataProtectionProvider dataProtectionProvider)
|
||||||
{
|
{
|
||||||
_organizationSponsorshipRepository = organizationSponsorshipRepository;
|
_organizationSponsorshipRepository = organizationSponsorshipRepository;
|
||||||
_organizationRepository = organizationRepository;
|
_organizationRepository = organizationRepository;
|
||||||
_paymentService = paymentService;
|
_paymentService = paymentService;
|
||||||
|
_mailService = mailService;
|
||||||
_dataProtector = dataProtectionProvider.CreateProtector("OrganizationSponsorshipServiceDataProtector");
|
_dataProtector = dataProtectionProvider.CreateProtector("OrganizationSponsorshipServiceDataProtector");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,8 +91,8 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
sponsorship = await _organizationSponsorshipRepository.CreateAsync(sponsorship);
|
sponsorship = await _organizationSponsorshipRepository.CreateAsync(sponsorship);
|
||||||
|
|
||||||
// TODO: send email to sponsoredEmail w/ redemption token link
|
await _mailService.SendFamiliesForEnterpriseOfferEmailAsync(sponsoredEmail, sponsoringOrg.Name,
|
||||||
// var _ = RedemptionToken(sponsorship.Id, sponsorshipType);
|
RedemptionToken(sponsorship.Id, sponsorshipType));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -201,17 +201,12 @@ namespace Bit.Core.Services
|
|||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SendFamiliesForEnterpriseInviteRedeemableEmailAsync(string email, string organizationName, string token)
|
public Task SendFamiliesForEnterpriseOfferEmailAsync(string email, string organizationName, string token)
|
||||||
{
|
{
|
||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SendFamiliesForEnterpriseInviteRedeemedToFamilyUserEmailAsync(string email)
|
public Task SendFamiliesForEnterpriseRedeemedEmailsAsync(string familyUserEmail, string sponsorEmail, string sponsorOrgName)
|
||||||
{
|
|
||||||
return Task.FromResult(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task SendFamiliesForEnterpriseInviteRedeemedToOrgUserEmailAsync(string email, string organizationName)
|
|
||||||
{
|
{
|
||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,11 @@ using Bit.Core.Services;
|
|||||||
using Bit.Test.Common.AutoFixture;
|
using Bit.Test.Common.AutoFixture;
|
||||||
using Bit.Test.Common.AutoFixture.Attributes;
|
using Bit.Test.Common.AutoFixture.Attributes;
|
||||||
using Bit.Test.Common.Helpers;
|
using Bit.Test.Common.Helpers;
|
||||||
|
using Microsoft.AspNetCore.DataProtection;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using NSubstitute;
|
using NSubstitute;
|
||||||
using NSubstitute.ExceptionExtensions;
|
using NSubstitute.ExceptionExtensions;
|
||||||
|
using NSubstitute.Extensions;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Bit.Core.Test.Services
|
namespace Bit.Core.Test.Services
|
||||||
@ -34,13 +36,24 @@ namespace Bit.Core.Test.Services
|
|||||||
[Theory]
|
[Theory]
|
||||||
[BitAutoData]
|
[BitAutoData]
|
||||||
public async Task OfferSponsorship_CreatesSponsorship(Organization sponsoringOrg, OrganizationUser sponsoringOrgUser,
|
public async Task OfferSponsorship_CreatesSponsorship(Organization sponsoringOrg, OrganizationUser sponsoringOrgUser,
|
||||||
string sponsoredEmail, string friendlyName, SutProvider<OrganizationSponsorshipService> sutProvider)
|
string sponsoredEmail, string friendlyName, Guid sponsorshipId,
|
||||||
|
SutProvider<OrganizationSponsorshipService> sutProvider)
|
||||||
{
|
{
|
||||||
|
var dataProtector = Substitute.For<IDataProtector>();
|
||||||
|
sutProvider.GetDependency<IDataProtectionProvider>().CreateProtector(default).ReturnsForAnyArgs(dataProtector);
|
||||||
|
sutProvider.GetDependency<IOrganizationSponsorshipRepository>().CreateAsync(default).ReturnsForAnyArgs(callInfo =>
|
||||||
|
{
|
||||||
|
var sponsorship = callInfo.Arg<OrganizationSponsorship>();
|
||||||
|
sponsorship.Id = sponsorshipId;
|
||||||
|
return sponsorship;
|
||||||
|
});
|
||||||
|
|
||||||
await sutProvider.Sut.OfferSponsorshipAsync(sponsoringOrg, sponsoringOrgUser,
|
await sutProvider.Sut.OfferSponsorshipAsync(sponsoringOrg, sponsoringOrgUser,
|
||||||
PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, friendlyName);
|
PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, friendlyName);
|
||||||
|
|
||||||
var expectedSponsorship = new OrganizationSponsorship
|
var expectedSponsorship = new OrganizationSponsorship
|
||||||
{
|
{
|
||||||
|
Id = sponsorshipId,
|
||||||
SponsoringOrganizationId = sponsoringOrg.Id,
|
SponsoringOrganizationId = sponsoringOrg.Id,
|
||||||
SponsoringOrganizationUserId = sponsoringOrgUser.Id,
|
SponsoringOrganizationUserId = sponsoringOrgUser.Id,
|
||||||
FriendlyName = friendlyName,
|
FriendlyName = friendlyName,
|
||||||
@ -51,7 +64,10 @@ namespace Bit.Core.Test.Services
|
|||||||
|
|
||||||
await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().Received(1)
|
await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().Received(1)
|
||||||
.CreateAsync(Arg.Is<OrganizationSponsorship>(s => sponsorshipValidator(s, expectedSponsorship)));
|
.CreateAsync(Arg.Is<OrganizationSponsorship>(s => sponsorshipValidator(s, expectedSponsorship)));
|
||||||
// TODO: Validate email called with appropriate token.s
|
|
||||||
|
await sutProvider.GetDependency<IMailService>().Received(1).
|
||||||
|
SendFamiliesForEnterpriseOfferEmailAsync(sponsoredEmail, sponsoringOrg.Name,
|
||||||
|
Arg.Any<string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
Loading…
Reference in New Issue
Block a user