mirror of
https://github.com/bitwarden/server.git
synced 2025-05-11 14:42:19 -05:00
Merge branch 'main' into ac/pm-14613/feature-flag-removal---step-1-remove-flagged-logic-from-clients/server-and-clients-feature-flag
This commit is contained in:
commit
a8ca724290
11
.github/workflows/build.yml
vendored
11
.github/workflows/build.yml
vendored
@ -14,6 +14,7 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
_AZ_REGISTRY: "bitwardenprod.azurecr.io"
|
_AZ_REGISTRY: "bitwardenprod.azurecr.io"
|
||||||
|
_GITHUB_PR_REPO_NAME: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
@ -234,12 +235,18 @@ jobs:
|
|||||||
- name: Generate Docker image tag
|
- name: Generate Docker image tag
|
||||||
id: tag
|
id: tag
|
||||||
run: |
|
run: |
|
||||||
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
|
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" || "${GITHUB_EVENT_NAME}" == "pull_request_target" ]]; then
|
||||||
IMAGE_TAG=$(echo "${GITHUB_HEAD_REF}" | sed "s#/#-#g")
|
IMAGE_TAG=$(echo "${GITHUB_HEAD_REF}" | sed "s/[^a-zA-Z0-9]/-/g") # Sanitize branch name to alphanumeric only
|
||||||
else
|
else
|
||||||
IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g")
|
IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "${{ github.event.pull_request.head.repo.fork }}" == "true" ]]; then
|
||||||
|
SANITIZED_REPO_NAME=$(echo "$_GITHUB_PR_REPO_NAME" | sed "s/[^a-zA-Z0-9]/-/g") # Sanitize repo name to alphanumeric only
|
||||||
|
IMAGE_TAG=$SANITIZED_REPO_NAME-$IMAGE_TAG # Add repo name to the tag
|
||||||
|
IMAGE_TAG=${IMAGE_TAG:0:128} # Limit to 128 characters, as that's the max length for Docker image tags
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$IMAGE_TAG" == "main" ]]; then
|
if [[ "$IMAGE_TAG" == "main" ]]; then
|
||||||
IMAGE_TAG=dev
|
IMAGE_TAG=dev
|
||||||
fi
|
fi
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Bit.Core.Entities;
|
using Bit.Core.Entities;
|
||||||
|
using Bit.Core.Exceptions;
|
||||||
|
|
||||||
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
|
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
|
||||||
|
|
||||||
|
@ -16,10 +16,11 @@ public class DuoUniversalTokenProvider(
|
|||||||
IDuoUniversalTokenService duoUniversalTokenService) : IUserTwoFactorTokenProvider<User>
|
IDuoUniversalTokenService duoUniversalTokenService) : IUserTwoFactorTokenProvider<User>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// We need the IServiceProvider to resolve the IUserService. There is a complex dependency dance
|
/// We need the IServiceProvider to resolve the <see cref="IUserService"/>. There is a complex dependency dance
|
||||||
/// occurring between IUserService, which extends the UserManager<User>, and the usage of the
|
/// occurring between <see cref="IUserService"/>, which extends the <see cref="UserManager{User}"/>, and the usage
|
||||||
/// UserManager<User> within this class. Trying to resolve the IUserService using the DI pipeline
|
/// of the <see cref="UserManager{User}"/> within this class. Trying to resolve the <see cref="IUserService"/> using
|
||||||
/// will not allow the server to start and it will hang and give no helpful indication as to the problem.
|
/// the DI pipeline will not allow the server to start and it will hang and give no helpful indication as to the
|
||||||
|
/// problem.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IServiceProvider _serviceProvider = serviceProvider;
|
private readonly IServiceProvider _serviceProvider = serviceProvider;
|
||||||
private readonly IDataProtectorTokenFactory<DuoUserStateTokenable> _tokenDataFactory = tokenDataFactory;
|
private readonly IDataProtectorTokenFactory<DuoUserStateTokenable> _tokenDataFactory = tokenDataFactory;
|
||||||
|
@ -7,4 +7,5 @@ public class TrialSendVerificationEmailRequestModel : RegisterSendVerificationEm
|
|||||||
{
|
{
|
||||||
public ProductTierType ProductTier { get; set; }
|
public ProductTierType ProductTier { get; set; }
|
||||||
public IEnumerable<ProductType> Products { get; set; }
|
public IEnumerable<ProductType> Products { get; set; }
|
||||||
|
public int? TrialLength { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Bit.Core.Auth.Models.Mail;
|
using Bit.Core.Auth.Models.Mail;
|
||||||
using Bit.Core.Billing.Enums;
|
using Bit.Core.Billing.Enums;
|
||||||
|
using Bit.Core.Enums;
|
||||||
|
|
||||||
namespace Bit.Core.Billing.Models.Mail;
|
namespace Bit.Core.Billing.Models.Mail;
|
||||||
|
|
||||||
@ -16,13 +17,26 @@ public class TrialInitiationVerifyEmail : RegisterVerifyEmail
|
|||||||
$"&email={Email}" +
|
$"&email={Email}" +
|
||||||
$"&fromEmail=true" +
|
$"&fromEmail=true" +
|
||||||
$"&productTier={(int)ProductTier}" +
|
$"&productTier={(int)ProductTier}" +
|
||||||
$"&product={string.Join(",", Product.Select(p => (int)p))}";
|
$"&product={string.Join(",", Product.Select(p => (int)p))}" +
|
||||||
|
$"&trialLength={TrialLength}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string VerifyYourEmailHTMLCopy =>
|
||||||
|
TrialLength == 7
|
||||||
|
? "Verify your email address below to finish signing up for your free trial."
|
||||||
|
: $"Verify your email address below to finish signing up for your {ProductTier.GetDisplayName()} plan.";
|
||||||
|
|
||||||
|
public string VerifyYourEmailTextCopy =>
|
||||||
|
TrialLength == 7
|
||||||
|
? "Verify your email address using the link below and start your free trial of Bitwarden."
|
||||||
|
: $"Verify your email address using the link below and start your {ProductTier.GetDisplayName()} Bitwarden plan.";
|
||||||
|
|
||||||
public ProductTierType ProductTier { get; set; }
|
public ProductTierType ProductTier { get; set; }
|
||||||
|
|
||||||
public IEnumerable<ProductType> Product { get; set; }
|
public IEnumerable<ProductType> Product { get; set; }
|
||||||
|
|
||||||
|
public int TrialLength { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Currently we only support one product type at a time, despite Product being a collection.
|
/// Currently we only support one product type at a time, despite Product being a collection.
|
||||||
/// If we receive both PasswordManager and SecretsManager, we'll send the user to the PM trial route
|
/// If we receive both PasswordManager and SecretsManager, we'll send the user to the PM trial route
|
||||||
|
@ -10,5 +10,6 @@ public interface ISendTrialInitiationEmailForRegistrationCommand
|
|||||||
string? name,
|
string? name,
|
||||||
bool receiveMarketingEmails,
|
bool receiveMarketingEmails,
|
||||||
ProductTierType productTier,
|
ProductTierType productTier,
|
||||||
IEnumerable<ProductType> products);
|
IEnumerable<ProductType> products,
|
||||||
|
int trialLength);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,8 @@ public class SendTrialInitiationEmailForRegistrationCommand(
|
|||||||
string? name,
|
string? name,
|
||||||
bool receiveMarketingEmails,
|
bool receiveMarketingEmails,
|
||||||
ProductTierType productTier,
|
ProductTierType productTier,
|
||||||
IEnumerable<ProductType> products)
|
IEnumerable<ProductType> products,
|
||||||
|
int trialLength)
|
||||||
{
|
{
|
||||||
ArgumentException.ThrowIfNullOrWhiteSpace(email, nameof(email));
|
ArgumentException.ThrowIfNullOrWhiteSpace(email, nameof(email));
|
||||||
|
|
||||||
@ -43,7 +44,12 @@ public class SendTrialInitiationEmailForRegistrationCommand(
|
|||||||
|
|
||||||
await PerformConstantTimeOperationsAsync();
|
await PerformConstantTimeOperationsAsync();
|
||||||
|
|
||||||
await mailService.SendTrialInitiationSignupEmailAsync(userExists, email, token, productTier, products);
|
if (trialLength != 0 && trialLength != 7)
|
||||||
|
{
|
||||||
|
trialLength = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
await mailService.SendTrialInitiationSignupEmailAsync(userExists, email, token, productTier, products, trialLength);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,6 @@ public static class FeatureFlagKeys
|
|||||||
public const string PM9112DeviceApprovalPersistence = "pm-9112-device-approval-persistence";
|
public const string PM9112DeviceApprovalPersistence = "pm-9112-device-approval-persistence";
|
||||||
public const string TwoFactorExtensionDataPersistence = "pm-9115-two-factor-extension-data-persistence";
|
public const string TwoFactorExtensionDataPersistence = "pm-9115-two-factor-extension-data-persistence";
|
||||||
public const string EmailVerification = "email-verification";
|
public const string EmailVerification = "email-verification";
|
||||||
public const string DeviceTrustLogging = "pm-8285-device-trust-logging";
|
|
||||||
public const string UnauthenticatedExtensionUIRefresh = "unauth-ui-refresh";
|
public const string UnauthenticatedExtensionUIRefresh = "unauth-ui-refresh";
|
||||||
public const string NewDeviceVerification = "new-device-verification";
|
public const string NewDeviceVerification = "new-device-verification";
|
||||||
public const string SetInitialPasswordRefactor = "pm-16117-set-initial-password-refactor";
|
public const string SetInitialPasswordRefactor = "pm-16117-set-initial-password-refactor";
|
||||||
@ -150,6 +149,7 @@ public static class FeatureFlagKeys
|
|||||||
public const string PM199566_UpdateMSPToChargeAutomatically = "pm-199566-update-msp-to-charge-automatically";
|
public const string PM199566_UpdateMSPToChargeAutomatically = "pm-199566-update-msp-to-charge-automatically";
|
||||||
public const string PM19956_RequireProviderPaymentMethodDuringSetup = "pm-19956-require-provider-payment-method-during-setup";
|
public const string PM19956_RequireProviderPaymentMethodDuringSetup = "pm-19956-require-provider-payment-method-during-setup";
|
||||||
public const string UseOrganizationWarningsService = "use-organization-warnings-service";
|
public const string UseOrganizationWarningsService = "use-organization-warnings-service";
|
||||||
|
public const string PM20322_AllowTrialLength0 = "pm-20322-allow-trial-length-0";
|
||||||
|
|
||||||
/* Data Insights and Reporting Team */
|
/* Data Insights and Reporting Team */
|
||||||
public const string RiskInsightsCriticalApplication = "pm-14466-risk-insights-critical-application";
|
public const string RiskInsightsCriticalApplication = "pm-14466-risk-insights-critical-application";
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<GenerateUserSecretsAttribute>false</GenerateUserSecretsAttribute>
|
<GenerateUserSecretsAttribute>false</GenerateUserSecretsAttribute>
|
||||||
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
|
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
|
||||||
<!-- Temp exclusions until warnings are fixed -->
|
<!-- Temp exclusions until warnings are fixed -->
|
||||||
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS1570;CS1574;CS9113;CS1998</WarningsNotAsErrors>
|
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS1574;CS9113;CS1998</WarningsNotAsErrors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
18
src/Core/Enums/EnumExtensions.cs
Normal file
18
src/Core/Enums/EnumExtensions.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Bit.Core.Enums;
|
||||||
|
|
||||||
|
public static class EnumExtensions
|
||||||
|
{
|
||||||
|
public static string GetDisplayName(this Enum value)
|
||||||
|
{
|
||||||
|
var field = value.GetType().GetField(value.ToString());
|
||||||
|
if (field?.GetCustomAttribute<DisplayAttribute>() is { } attribute)
|
||||||
|
{
|
||||||
|
return attribute.Name ?? value.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.ToString();
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
<table width="100%" cellpadding="0" cellspacing="0" style="margin: 0; box-sizing: border-box; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;">
|
<table width="100%" cellpadding="0" cellspacing="0" style="margin: 0; box-sizing: border-box; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;">
|
||||||
<tr style="margin: 0; box-sizing: border-box; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;">
|
<tr style="margin: 0; box-sizing: border-box; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;">
|
||||||
<td class="content-block" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0 0 10px; -webkit-text-size-adjust: none; text-align: left;" valign="top" align="center">
|
<td class="content-block" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0 0 10px; -webkit-text-size-adjust: none; text-align: left;" valign="top" align="center">
|
||||||
Verify your email address below to finish signing up for your free trial.
|
{{VerifyYourEmailHTMLCopy}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr style="margin: 0; box-sizing: border-box; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;">
|
<tr style="margin: 0; box-sizing: border-box; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{#>BasicTextLayout}}
|
{{#>BasicTextLayout}}
|
||||||
Verify your email address using the link below and start your free trial of Bitwarden.
|
{{VerifyYourEmailTextCopy}}
|
||||||
|
|
||||||
If you did not request this email from Bitwarden, you can safely ignore it.
|
If you did not request this email from Bitwarden, you can safely ignore it.
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@ public interface IMailService
|
|||||||
string email,
|
string email,
|
||||||
string token,
|
string token,
|
||||||
ProductTierType productTier,
|
ProductTierType productTier,
|
||||||
IEnumerable<ProductType> products);
|
IEnumerable<ProductType> products,
|
||||||
|
int trialLength);
|
||||||
Task SendVerifyDeleteEmailAsync(string email, Guid userId, string token);
|
Task SendVerifyDeleteEmailAsync(string email, Guid userId, string token);
|
||||||
Task SendCannotDeleteClaimedAccountEmailAsync(string email);
|
Task SendCannotDeleteClaimedAccountEmailAsync(string email);
|
||||||
Task SendChangeEmailAlreadyExistsEmailAsync(string fromEmail, string toEmail);
|
Task SendChangeEmailAlreadyExistsEmailAsync(string fromEmail, string toEmail);
|
||||||
|
@ -84,7 +84,8 @@ public class HandlebarsMailService : IMailService
|
|||||||
string email,
|
string email,
|
||||||
string token,
|
string token,
|
||||||
ProductTierType productTier,
|
ProductTierType productTier,
|
||||||
IEnumerable<ProductType> products)
|
IEnumerable<ProductType> products,
|
||||||
|
int trialLength)
|
||||||
{
|
{
|
||||||
var message = CreateDefaultMessage("Verify your email", email);
|
var message = CreateDefaultMessage("Verify your email", email);
|
||||||
var model = new TrialInitiationVerifyEmail
|
var model = new TrialInitiationVerifyEmail
|
||||||
@ -95,7 +96,8 @@ public class HandlebarsMailService : IMailService
|
|||||||
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
||||||
SiteName = _globalSettings.SiteName,
|
SiteName = _globalSettings.SiteName,
|
||||||
ProductTier = productTier,
|
ProductTier = productTier,
|
||||||
Product = products
|
Product = products,
|
||||||
|
TrialLength = trialLength
|
||||||
};
|
};
|
||||||
await AddMessageContentAsync(message, "Billing.TrialInitiationVerifyEmail", model);
|
await AddMessageContentAsync(message, "Billing.TrialInitiationVerifyEmail", model);
|
||||||
message.MetaData.Add("SendGridBypassListManagement", true);
|
message.MetaData.Add("SendGridBypassListManagement", true);
|
||||||
|
@ -112,6 +112,8 @@ public class StripePaymentService : IPaymentService
|
|||||||
throw new BadRequestException("You do not have an active subscription. Reinstate your subscription to make changes.");
|
throw new BadRequestException("You do not have an active subscription. Reinstate your subscription to make changes.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var existingCoupon = sub.Customer.Discount?.Coupon?.Id;
|
||||||
|
|
||||||
var collectionMethod = sub.CollectionMethod;
|
var collectionMethod = sub.CollectionMethod;
|
||||||
var daysUntilDue = sub.DaysUntilDue;
|
var daysUntilDue = sub.DaysUntilDue;
|
||||||
var chargeNow = collectionMethod == "charge_automatically";
|
var chargeNow = collectionMethod == "charge_automatically";
|
||||||
@ -216,6 +218,19 @@ public class StripePaymentService : IPaymentService
|
|||||||
DaysUntilDue = daysUntilDue,
|
DaysUntilDue = daysUntilDue,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var customer = await _stripeAdapter.CustomerGetAsync(sub.CustomerId);
|
||||||
|
|
||||||
|
var newCoupon = customer.Discount?.Coupon?.Id;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(existingCoupon) && string.IsNullOrEmpty(newCoupon))
|
||||||
|
{
|
||||||
|
// Re-add the lost coupon due to the update.
|
||||||
|
await _stripeAdapter.CustomerUpdateAsync(sub.CustomerId, new CustomerUpdateOptions
|
||||||
|
{
|
||||||
|
Coupon = existingCoupon
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return paymentIntentClientSecret;
|
return paymentIntentClientSecret;
|
||||||
|
@ -33,7 +33,8 @@ public class NoopMailService : IMailService
|
|||||||
string email,
|
string email,
|
||||||
string token,
|
string token,
|
||||||
ProductTierType productTier,
|
ProductTierType productTier,
|
||||||
IEnumerable<ProductType> products)
|
IEnumerable<ProductType> products,
|
||||||
|
int trailLength)
|
||||||
{
|
{
|
||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
using Bit.Core.Billing.Models.Api.Requests.Accounts;
|
using Bit.Core;
|
||||||
|
using Bit.Core.Billing.Models.Api.Requests.Accounts;
|
||||||
using Bit.Core.Billing.TrialInitiation.Registration;
|
using Bit.Core.Billing.TrialInitiation.Registration;
|
||||||
using Bit.Core.Context;
|
using Bit.Core.Context;
|
||||||
|
using Bit.Core.Services;
|
||||||
using Bit.Core.Tools.Enums;
|
using Bit.Core.Tools.Enums;
|
||||||
using Bit.Core.Tools.Models.Business;
|
using Bit.Core.Tools.Models.Business;
|
||||||
using Bit.Core.Tools.Services;
|
using Bit.Core.Tools.Services;
|
||||||
@ -15,18 +17,24 @@ namespace Bit.Identity.Billing.Controller;
|
|||||||
public class AccountsController(
|
public class AccountsController(
|
||||||
ICurrentContext currentContext,
|
ICurrentContext currentContext,
|
||||||
ISendTrialInitiationEmailForRegistrationCommand sendTrialInitiationEmailForRegistrationCommand,
|
ISendTrialInitiationEmailForRegistrationCommand sendTrialInitiationEmailForRegistrationCommand,
|
||||||
IReferenceEventService referenceEventService) : Microsoft.AspNetCore.Mvc.Controller
|
IReferenceEventService referenceEventService,
|
||||||
|
IFeatureService featureService) : Microsoft.AspNetCore.Mvc.Controller
|
||||||
{
|
{
|
||||||
[HttpPost("trial/send-verification-email")]
|
[HttpPost("trial/send-verification-email")]
|
||||||
[SelfHosted(NotSelfHostedOnly = true)]
|
[SelfHosted(NotSelfHostedOnly = true)]
|
||||||
public async Task<IActionResult> PostTrialInitiationSendVerificationEmailAsync([FromBody] TrialSendVerificationEmailRequestModel model)
|
public async Task<IActionResult> PostTrialInitiationSendVerificationEmailAsync([FromBody] TrialSendVerificationEmailRequestModel model)
|
||||||
{
|
{
|
||||||
|
var allowTrialLength0 = featureService.IsEnabled(FeatureFlagKeys.PM20322_AllowTrialLength0);
|
||||||
|
|
||||||
|
var trialLength = allowTrialLength0 ? model.TrialLength ?? 7 : 7;
|
||||||
|
|
||||||
var token = await sendTrialInitiationEmailForRegistrationCommand.Handle(
|
var token = await sendTrialInitiationEmailForRegistrationCommand.Handle(
|
||||||
model.Email,
|
model.Email,
|
||||||
model.Name,
|
model.Name,
|
||||||
model.ReceiveMarketingEmails,
|
model.ReceiveMarketingEmails,
|
||||||
model.ProductTier,
|
model.ProductTier,
|
||||||
model.Products);
|
model.Products,
|
||||||
|
trialLength);
|
||||||
|
|
||||||
var refEvent = new ReferenceEvent
|
var refEvent = new ReferenceEvent
|
||||||
{
|
{
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<UserSecretsId>bitwarden-Identity</UserSecretsId>
|
<UserSecretsId>bitwarden-Identity</UserSecretsId>
|
||||||
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
|
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
|
||||||
<!-- Temp exclusions until warnings are fixed -->
|
|
||||||
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS0162</WarningsNotAsErrors>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Identity' " />
|
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Identity' " />
|
||||||
|
@ -145,6 +145,7 @@ public class Startup
|
|||||||
// Services
|
// Services
|
||||||
services.AddBaseServices(globalSettings);
|
services.AddBaseServices(globalSettings);
|
||||||
services.AddDefaultServices(globalSettings);
|
services.AddDefaultServices(globalSettings);
|
||||||
|
services.AddOptionality();
|
||||||
services.AddCoreLocalizationServices();
|
services.AddCoreLocalizationServices();
|
||||||
services.AddBillingOperations();
|
services.AddBillingOperations();
|
||||||
|
|
||||||
|
@ -17,15 +17,11 @@ public class DeviceRepository : Repository<Device, Guid>, IDeviceRepository
|
|||||||
private readonly IGlobalSettings _globalSettings;
|
private readonly IGlobalSettings _globalSettings;
|
||||||
|
|
||||||
public DeviceRepository(GlobalSettings globalSettings)
|
public DeviceRepository(GlobalSettings globalSettings)
|
||||||
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
|
: base(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
|
||||||
{
|
{
|
||||||
_globalSettings = globalSettings;
|
_globalSettings = globalSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceRepository(string connectionString, string readOnlyConnectionString)
|
|
||||||
: base(connectionString, readOnlyConnectionString)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public async Task<Device?> GetByIdAsync(Guid id, Guid userId)
|
public async Task<Device?> GetByIdAsync(Guid id, Guid userId)
|
||||||
{
|
{
|
||||||
var device = await GetByIdAsync(id);
|
var device = await GetByIdAsync(id);
|
||||||
|
@ -304,7 +304,7 @@ public class GroupsControllerPutTests
|
|||||||
// Arrange repositories
|
// Arrange repositories
|
||||||
sutProvider.GetDependency<IGroupRepository>().GetManyUserIdsByIdAsync(group.Id).Returns(currentGroupUsers ?? []);
|
sutProvider.GetDependency<IGroupRepository>().GetManyUserIdsByIdAsync(group.Id).Returns(currentGroupUsers ?? []);
|
||||||
sutProvider.GetDependency<IGroupRepository>().GetByIdWithCollectionsAsync(group.Id)
|
sutProvider.GetDependency<IGroupRepository>().GetByIdWithCollectionsAsync(group.Id)
|
||||||
.Returns(new Tuple<Group, ICollection<CollectionAccessSelection>>(group, currentCollectionAccess ?? []));
|
.Returns(new Tuple<Group?, ICollection<CollectionAccessSelection>>(group, currentCollectionAccess ?? []));
|
||||||
if (savingUser != null)
|
if (savingUser != null)
|
||||||
{
|
{
|
||||||
sutProvider.GetDependency<IOrganizationUserRepository>().GetByOrganizationAsync(orgId, savingUser.UserId!.Value)
|
sutProvider.GetDependency<IOrganizationUserRepository>().GetByOrganizationAsync(orgId, savingUser.UserId!.Value)
|
||||||
|
@ -8,7 +8,6 @@ using Bit.Core.Entities;
|
|||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
using Bit.Core.Repositories;
|
using Bit.Core.Repositories;
|
||||||
using Bit.Core.Services;
|
using Bit.Core.Services;
|
||||||
using Bit.Core.Settings;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NSubstitute;
|
using NSubstitute;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
@ -23,7 +22,6 @@ public class DevicesControllerTest
|
|||||||
private readonly IUntrustDevicesCommand _untrustDevicesCommand;
|
private readonly IUntrustDevicesCommand _untrustDevicesCommand;
|
||||||
private readonly IUserRepository _userRepositoryMock;
|
private readonly IUserRepository _userRepositoryMock;
|
||||||
private readonly ICurrentContext _currentContextMock;
|
private readonly ICurrentContext _currentContextMock;
|
||||||
private readonly IGlobalSettings _globalSettingsMock;
|
|
||||||
private readonly ILogger<DevicesController> _loggerMock;
|
private readonly ILogger<DevicesController> _loggerMock;
|
||||||
private readonly DevicesController _sut;
|
private readonly DevicesController _sut;
|
||||||
|
|
||||||
|
@ -677,7 +677,7 @@ public class InviteOrganizationUserCommandTests
|
|||||||
// Assert
|
// Assert
|
||||||
Assert.IsType<Success<ScimInviteOrganizationUsersResponse>>(result);
|
Assert.IsType<Success<ScimInviteOrganizationUsersResponse>>(result);
|
||||||
|
|
||||||
sutProvider.GetDependency<IMailService>().Received(1)
|
await sutProvider.GetDependency<IMailService>().Received(1)
|
||||||
.SendOrganizationMaxSeatLimitReachedEmailAsync(organization, 2,
|
.SendOrganizationMaxSeatLimitReachedEmailAsync(organization, 2,
|
||||||
Arg.Is<IEnumerable<string>>(emails => emails.Any(email => email == "provider@email.com")));
|
Arg.Is<IEnumerable<string>>(emails => emails.Any(email => email == "provider@email.com")));
|
||||||
}
|
}
|
||||||
@ -768,7 +768,7 @@ public class InviteOrganizationUserCommandTests
|
|||||||
// Assert
|
// Assert
|
||||||
Assert.IsType<Success<ScimInviteOrganizationUsersResponse>>(result);
|
Assert.IsType<Success<ScimInviteOrganizationUsersResponse>>(result);
|
||||||
|
|
||||||
sutProvider.GetDependency<IMailService>().Received(1)
|
await sutProvider.GetDependency<IMailService>().Received(1)
|
||||||
.SendOrganizationAutoscaledEmailAsync(organization, 1,
|
.SendOrganizationAutoscaledEmailAsync(organization, 1,
|
||||||
Arg.Is<IEnumerable<string>>(emails => emails.Any(email => email == "provider@email.com")));
|
Arg.Is<IEnumerable<string>>(emails => emails.Any(email => email == "provider@email.com")));
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class InviteOrganizationUsersValidatorTests
|
|||||||
|
|
||||||
_ = await sutProvider.Sut.ValidateAsync(request);
|
_ = await sutProvider.Sut.ValidateAsync(request);
|
||||||
|
|
||||||
sutProvider.GetDependency<IUpdateSecretsManagerSubscriptionCommand>()
|
await sutProvider.GetDependency<IUpdateSecretsManagerSubscriptionCommand>()
|
||||||
.Received(1)
|
.Received(1)
|
||||||
.ValidateUpdateAsync(Arg.Is<SecretsManagerSubscriptionUpdate>(x =>
|
.ValidateUpdateAsync(Arg.Is<SecretsManagerSubscriptionUpdate>(x =>
|
||||||
x.SmSeatsChanged == true && x.SmSeats == 12));
|
x.SmSeatsChanged == true && x.SmSeats == 12));
|
||||||
|
@ -26,8 +26,8 @@ public class EventRouteServiceTests
|
|||||||
|
|
||||||
await Subject.CreateAsync(eventMessage);
|
await Subject.CreateAsync(eventMessage);
|
||||||
|
|
||||||
_broadcastEventWriteService.DidNotReceiveWithAnyArgs().CreateAsync(Arg.Any<EventMessage>());
|
await _broadcastEventWriteService.DidNotReceiveWithAnyArgs().CreateAsync(Arg.Any<EventMessage>());
|
||||||
_storageEventWriteService.Received(1).CreateAsync(eventMessage);
|
await _storageEventWriteService.Received(1).CreateAsync(eventMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory, BitAutoData]
|
[Theory, BitAutoData]
|
||||||
@ -37,8 +37,8 @@ public class EventRouteServiceTests
|
|||||||
|
|
||||||
await Subject.CreateAsync(eventMessage);
|
await Subject.CreateAsync(eventMessage);
|
||||||
|
|
||||||
_broadcastEventWriteService.Received(1).CreateAsync(eventMessage);
|
await _broadcastEventWriteService.Received(1).CreateAsync(eventMessage);
|
||||||
_storageEventWriteService.DidNotReceiveWithAnyArgs().CreateAsync(Arg.Any<EventMessage>());
|
await _storageEventWriteService.DidNotReceiveWithAnyArgs().CreateAsync(Arg.Any<EventMessage>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory, BitAutoData]
|
[Theory, BitAutoData]
|
||||||
@ -48,8 +48,8 @@ public class EventRouteServiceTests
|
|||||||
|
|
||||||
await Subject.CreateManyAsync(eventMessages);
|
await Subject.CreateManyAsync(eventMessages);
|
||||||
|
|
||||||
_broadcastEventWriteService.DidNotReceiveWithAnyArgs().CreateManyAsync(Arg.Any<IEnumerable<EventMessage>>());
|
await _broadcastEventWriteService.DidNotReceiveWithAnyArgs().CreateManyAsync(Arg.Any<IEnumerable<EventMessage>>());
|
||||||
_storageEventWriteService.Received(1).CreateManyAsync(eventMessages);
|
await _storageEventWriteService.Received(1).CreateManyAsync(eventMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory, BitAutoData]
|
[Theory, BitAutoData]
|
||||||
@ -59,7 +59,7 @@ public class EventRouteServiceTests
|
|||||||
|
|
||||||
await Subject.CreateManyAsync(eventMessages);
|
await Subject.CreateManyAsync(eventMessages);
|
||||||
|
|
||||||
_broadcastEventWriteService.Received(1).CreateManyAsync(eventMessages);
|
await _broadcastEventWriteService.Received(1).CreateManyAsync(eventMessages);
|
||||||
_storageEventWriteService.DidNotReceiveWithAnyArgs().CreateManyAsync(Arg.Any<IEnumerable<EventMessage>>());
|
await _storageEventWriteService.DidNotReceiveWithAnyArgs().CreateManyAsync(Arg.Any<IEnumerable<EventMessage>>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public class SlackEventHandlerTests
|
|||||||
var sutProvider = GetSutProvider(OneConfiguration());
|
var sutProvider = GetSutProvider(OneConfiguration());
|
||||||
|
|
||||||
await sutProvider.Sut.HandleEventAsync(eventMessage);
|
await sutProvider.Sut.HandleEventAsync(eventMessage);
|
||||||
sutProvider.GetDependency<ISlackService>().Received(1).SendSlackMessageByChannelIdAsync(
|
await sutProvider.GetDependency<ISlackService>().Received(1).SendSlackMessageByChannelIdAsync(
|
||||||
Arg.Is(AssertHelper.AssertPropertyEqual(_token)),
|
Arg.Is(AssertHelper.AssertPropertyEqual(_token)),
|
||||||
Arg.Is(AssertHelper.AssertPropertyEqual(
|
Arg.Is(AssertHelper.AssertPropertyEqual(
|
||||||
$"Date: {eventMessage.Date}, Type: {eventMessage.Type}, UserId: {eventMessage.UserId}")),
|
$"Date: {eventMessage.Date}, Type: {eventMessage.Type}, UserId: {eventMessage.UserId}")),
|
||||||
@ -103,13 +103,13 @@ public class SlackEventHandlerTests
|
|||||||
var sutProvider = GetSutProvider(TwoConfigurations());
|
var sutProvider = GetSutProvider(TwoConfigurations());
|
||||||
|
|
||||||
await sutProvider.Sut.HandleEventAsync(eventMessage);
|
await sutProvider.Sut.HandleEventAsync(eventMessage);
|
||||||
sutProvider.GetDependency<ISlackService>().Received(1).SendSlackMessageByChannelIdAsync(
|
await sutProvider.GetDependency<ISlackService>().Received(1).SendSlackMessageByChannelIdAsync(
|
||||||
Arg.Is(AssertHelper.AssertPropertyEqual(_token)),
|
Arg.Is(AssertHelper.AssertPropertyEqual(_token)),
|
||||||
Arg.Is(AssertHelper.AssertPropertyEqual(
|
Arg.Is(AssertHelper.AssertPropertyEqual(
|
||||||
$"Date: {eventMessage.Date}, Type: {eventMessage.Type}, UserId: {eventMessage.UserId}")),
|
$"Date: {eventMessage.Date}, Type: {eventMessage.Type}, UserId: {eventMessage.UserId}")),
|
||||||
Arg.Is(AssertHelper.AssertPropertyEqual(_channelId))
|
Arg.Is(AssertHelper.AssertPropertyEqual(_channelId))
|
||||||
);
|
);
|
||||||
sutProvider.GetDependency<ISlackService>().Received(1).SendSlackMessageByChannelIdAsync(
|
await sutProvider.GetDependency<ISlackService>().Received(1).SendSlackMessageByChannelIdAsync(
|
||||||
Arg.Is(AssertHelper.AssertPropertyEqual(_token2)),
|
Arg.Is(AssertHelper.AssertPropertyEqual(_token2)),
|
||||||
Arg.Is(AssertHelper.AssertPropertyEqual(
|
Arg.Is(AssertHelper.AssertPropertyEqual(
|
||||||
$"Date: {eventMessage.Date}, Type: {eventMessage.Type}, UserId: {eventMessage.UserId}")),
|
$"Date: {eventMessage.Date}, Type: {eventMessage.Type}, UserId: {eventMessage.UserId}")),
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
<!-- Temp exclusions until warnings are fixed -->
|
|
||||||
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS0672;CS1998</WarningsNotAsErrors>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -96,6 +96,7 @@ IBaseRequestValidatorTestWrapper
|
|||||||
return context.ValidatedTokenRequest.Subject ?? new ClaimsPrincipal();
|
return context.ValidatedTokenRequest.Subject ?? new ClaimsPrincipal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete]
|
||||||
protected override void SetErrorResult(
|
protected override void SetErrorResult(
|
||||||
BaseRequestValidationContextFake context,
|
BaseRequestValidationContextFake context,
|
||||||
Dictionary<string, object> customResponse)
|
Dictionary<string, object> customResponse)
|
||||||
@ -103,6 +104,7 @@ IBaseRequestValidatorTestWrapper
|
|||||||
context.GrantResult = new GrantValidationResult(TokenRequestErrors.InvalidGrant, customResponse: customResponse);
|
context.GrantResult = new GrantValidationResult(TokenRequestErrors.InvalidGrant, customResponse: customResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete]
|
||||||
protected override void SetSsoResult(
|
protected override void SetSsoResult(
|
||||||
BaseRequestValidationContextFake context,
|
BaseRequestValidationContextFake context,
|
||||||
Dictionary<string, object> customResponse)
|
Dictionary<string, object> customResponse)
|
||||||
@ -121,6 +123,7 @@ IBaseRequestValidatorTestWrapper
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete]
|
||||||
protected override void SetTwoFactorResult(
|
protected override void SetTwoFactorResult(
|
||||||
BaseRequestValidationContextFake context,
|
BaseRequestValidationContextFake context,
|
||||||
Dictionary<string, object> customResponse)
|
Dictionary<string, object> customResponse)
|
||||||
|
@ -56,9 +56,9 @@ public class UserManagerTestWrapper<TUser> : UserManager<TUser> where TUser : cl
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="user"></param>
|
/// <param name="user"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override async Task<bool> GetTwoFactorEnabledAsync(TUser user)
|
public override Task<bool> GetTwoFactorEnabledAsync(TUser user)
|
||||||
{
|
{
|
||||||
return TWO_FACTOR_ENABLED;
|
return Task.FromResult(TWO_FACTOR_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -66,9 +66,9 @@ public class UserManagerTestWrapper<TUser> : UserManager<TUser> where TUser : cl
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="user"></param>
|
/// <param name="user"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override async Task<IList<string>> GetValidTwoFactorProvidersAsync(TUser user)
|
public override Task<IList<string>> GetValidTwoFactorProvidersAsync(TUser user)
|
||||||
{
|
{
|
||||||
return TWO_FACTOR_PROVIDERS;
|
return Task.FromResult(TWO_FACTOR_PROVIDERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -77,9 +77,9 @@ public class UserManagerTestWrapper<TUser> : UserManager<TUser> where TUser : cl
|
|||||||
/// <param name="user"></param>
|
/// <param name="user"></param>
|
||||||
/// <param name="tokenProvider"></param>
|
/// <param name="tokenProvider"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override async Task<string> GenerateTwoFactorTokenAsync(TUser user, string tokenProvider)
|
public override Task<string> GenerateTwoFactorTokenAsync(TUser user, string tokenProvider)
|
||||||
{
|
{
|
||||||
return TWO_FACTOR_TOKEN;
|
return Task.FromResult(TWO_FACTOR_TOKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -89,8 +89,8 @@ public class UserManagerTestWrapper<TUser> : UserManager<TUser> where TUser : cl
|
|||||||
/// <param name="tokenProvider"></param>
|
/// <param name="tokenProvider"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override async Task<bool> VerifyTwoFactorTokenAsync(TUser user, string tokenProvider, string token)
|
public override Task<bool> VerifyTwoFactorTokenAsync(TUser user, string tokenProvider, string token)
|
||||||
{
|
{
|
||||||
return TWO_FACTOR_TOKEN_VERIFIED;
|
return Task.FromResult(TWO_FACTOR_TOKEN_VERIFIED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user