Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AC-1682] Flexible collections: EF data migrations integration tests #3937

Closed
wants to merge 119 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
e14ba4d
[AC-1682] Data migrations for OrgUsers or Groups with AccessAll enabled
r-tome Nov 10, 2023
1527af7
[AC-1682] Added script to update [dbo].[CollectionUser] with [Manage]…
r-tome Nov 10, 2023
577e591
[AC-1682] Updated sql data migration procedures with performance reco…
r-tome Nov 13, 2023
23a3e5c
[AC-1682] Moved data migration scripts to DbScripts_transition folder
r-tome Nov 13, 2023
d693511
Apply suggestions from code review: Remove Manage permission from Col…
r-tome Dec 6, 2023
0475b93
[AC-1682] Removed unnecessary Collection table join on ManagersEditAs…
r-tome Dec 6, 2023
3e7e3a0
[AC-1682] Change JOIN to INNER JOIN in SQL scripts
r-tome Dec 6, 2023
be35a2b
[AC-1682] Renamed sql script to recent date and added correct order t…
r-tome Dec 6, 2023
b7773b6
Merge branch 'master' into ac/ac-1682/data-migrations-for-deprecated-…
r-tome Dec 6, 2023
003b6dc
[AC-1682] Added EF migrations
r-tome Dec 17, 2023
2e9be13
[AC-1682] dotnet format
r-tome Dec 17, 2023
7d718b6
[AC-1682] Add new rows to CollectionUser for Managers and users with …
r-tome Dec 18, 2023
69c0997
Merge branch 'main' into ac/ac-1682/data-migrations-for-deprecated-pe…
r-tome Dec 18, 2023
87d420a
Merge branch 'ac/ac-1682/data-migrations-for-deprecated-permissions' …
r-tome Dec 19, 2023
5f1f7d6
[AC-1682] Added new mysql migration
r-tome Dec 19, 2023
fc8606a
[AC-1682] mySql scripts formatting
r-tome Dec 19, 2023
c5f1be4
[AC-1682] MySql migrations
r-tome Dec 19, 2023
86ba89f
[AC-1682] Postgres migrations
r-tome Dec 20, 2023
73a1315
[AC-1682] Sqlite migrations + dotnet format
r-tome Dec 20, 2023
e7ce15f
Merge branch 'main' into ac/ac-1682/data-migrations-for-deprecated-pe…
r-tome Jan 9, 2024
fcd2dd3
[AC-1682] Update FC data migration scripts to clear AccessAll flags a…
r-tome Jan 10, 2024
8bf17eb
[AC-1682] Updated data migration scripts to bump the account revision…
r-tome Jan 10, 2024
dfc4032
[AC-1682] Created Organization_EnableCollectionEnhancements to migrat…
r-tome Jan 10, 2024
0d8609a
[AC-1682] Added script to migrate all organization data for flexible …
r-tome Jan 10, 2024
54cc6fa
[AC-1682] Deleted old data migration scripts
r-tome Jan 10, 2024
a214c60
Revert "[AC-1682] Deleted old data migration scripts"
r-tome Jan 11, 2024
ee43767
[AC-1682] Modified AccessAllCollectionUsers script to bump revision d…
r-tome Jan 11, 2024
71978fe
Merge branch 'main' into ac/ac-1682/data-migrations-for-deprecated-pe…
r-tome Jan 11, 2024
f4450c0
[AC-1682] Update data migration script to only enable collection enha…
r-tome Jan 11, 2024
8cc8895
[AC-1682] Updated AccessAllCollectionGroups migration script to use U…
r-tome Jan 11, 2024
8a5ea76
[AC-1682] Bumped up the date on data migration scripts
r-tome Jan 11, 2024
68c586f
[AC-1682] Added back batching system to AccessAllCollectionUsers data…
r-tome Jan 11, 2024
ba06076
[AC-1682] Added data migration script to set FlexibleCollections = 1 …
r-tome Jan 11, 2024
f78e28f
[AC-1682] Modified data migration script to contain multiple transact…
r-tome Jan 11, 2024
3bf1b53
[AC-1682] Deleted old data migration scripts
r-tome Jan 11, 2024
c4ad7d7
[AC-1682] Placed temp tables outside transactions
r-tome Jan 11, 2024
96b5278
[AC-1682] Removed batching from AllOrgsEnableCollectionEnhancements s…
r-tome Jan 11, 2024
5c08d18
Merge branch 'main' into ac/ac-1682/ef-migrations
r-tome Jan 12, 2024
19fb7e5
[AC-1682] Bumped up the dates on the migration scripts
r-tome Jan 12, 2024
752e2c0
[AC-1682] Updated mysql migrations
r-tome Jan 12, 2024
d5b41c1
[AC-1682] Updated postgres migrations
r-tome Jan 12, 2024
667f3cd
Merge branch 'main' into ac/ac-1682/data-migrations-for-deprecated-pe…
r-tome Jan 12, 2024
57cb97d
Merge branch 'ac/ac-1682/data-migrations-for-deprecated-permissions' …
r-tome Jan 12, 2024
8a0e90c
[AC-1682] sqlite data migrations
r-tome Jan 15, 2024
39e336e
Merge branch 'main' into ac/ac-1682/ef-migrations
r-tome Feb 16, 2024
f7f692c
[AC-1682] Update RevisionDate in Group table
r-tome Feb 16, 2024
6d1ead5
[AC-1682] Bumped up date on migration scripts
r-tome Feb 16, 2024
a24465b
[AC-1682] Bumped up dates on EF migrations
r-tome Feb 16, 2024
2f434b3
[AC-1682] Remove unnecessary migration scripts
r-tome Feb 16, 2024
0f3aa5d
Merge branch 'main' into ac/ac-1682/ef-migrations
r-tome Feb 26, 2024
988d90f
Merge branch 'main' into ac/ac-1682/ef-migrations
r-tome Feb 27, 2024
6c21d4e
Merge branch 'main' into ac/ac-1682/ef-migrations
r-tome Mar 22, 2024
5383cd1
[AC-1682] Removed MySql scripts and migrations
r-tome Mar 22, 2024
bb00cb4
[AC-1682] Removed Postgres scripts and migrations
r-tome Mar 22, 2024
d6f7d94
[AC-1682] Removed Sqlite migrations and scripts
r-tome Mar 22, 2024
d367f6d
[AC-1682] Added MySql migration and script
r-tome Mar 22, 2024
9bde160
[AC-1682] Added Postgres migration and script
r-tome Mar 25, 2024
262887f
[AC-1682] Added Sqlite migration and script
r-tome Mar 25, 2024
00eea06
[AC-1682] dotnet format
r-tome Mar 25, 2024
1de0f32
[AC-2323] Added script to migrate all sql organizations to use flexib…
r-tome Mar 25, 2024
6651bb1
[AC-2323] Overriding FlexibleCollectionsSignup to true for local usage
r-tome Mar 25, 2024
71f574f
Merge branch 'ac/ac-2323/sql-automatic-data-migrations' into ac/ac-16…
r-tome Mar 25, 2024
73d455b
[AC-2323] Fix script comment
r-tome Mar 25, 2024
f131004
[AC-2323] Fixed typo
r-tome Mar 25, 2024
26f5bf8
[AC-1682] Fixed Sqlite query
r-tome Mar 28, 2024
3d6ef1d
[AC-1682] Updated integration tests to run for EF database providers
r-tome Mar 28, 2024
d3f5184
[AC-1682] Moved EF data migration scripts to Infrastructure.EntityFra…
r-tome Mar 28, 2024
2a6b53e
[AC-1682] Updated migrations to use execution interface
r-tome Mar 28, 2024
0c8faa0
[AC-1682] Added summary to EnableCollectionEnhancements method
r-tome Mar 28, 2024
c20912f
[AC-1682] Drop temp tables if they exist when starting the scripts
r-tome Mar 29, 2024
7b54d78
[AC-1682] Removed MySql transaction from script because EF migration …
r-tome Mar 29, 2024
28bba94
[AC-1682] Setting FlexibleCollections = 1 only for Orgs that had data…
r-tome Mar 29, 2024
a957530
[AC-1682] Updated queries to check for OrganizationId
r-tome Mar 29, 2024
deee483
[AC-1682] Fixed MySql script
r-tome Mar 29, 2024
c3ca9ec
[AC-1682] Fixed Postgres query
r-tome Mar 29, 2024
fada0a8
[AC-1682] Fix Sqlite query
r-tome Mar 29, 2024
7dfd282
Merge branch 'ac/ac-2323/sql-automatic-data-migrations' into ac/ac-16…
r-tome Apr 1, 2024
6c290e2
Merge branch 'ac/ac-1682/ef-migrations' into ac/ac-1682/ef-migrations…
eliykat Apr 3, 2024
f98646a
Merge branch 'main' into ac/ac-1682/ef-migrations
r-tome Apr 3, 2024
bd3b21b
[AC-1682] Reverted scripts back to enabling Flexible Collections to a…
r-tome Apr 3, 2024
8ad901f
Merge branch 'ac/ac-1682/ef-migrations' into ac/ac-1682/ef-migrations…
r-tome Apr 3, 2024
bf34e96
[AC-1682] Added unit test to verify migration across multiple organiz…
r-tome Apr 3, 2024
e027bb4
Revert "Merge branch 'main' into ac/ac-1682/ef-migrations"
r-tome Apr 3, 2024
58721cd
Merge branch 'ac/ac-1682/ef-migrations' into ac/ac-1682/ef-migrations…
eliykat Apr 4, 2024
eb7794d
[AC-1682] Removed dropping temporary table from scripts
r-tome Apr 4, 2024
2fbba0e
Merge branch 'ac/ac-1682/ef-migrations' into ac/ac-1682/ef-migrations…
r-tome Apr 4, 2024
ab95045
[AC-1682] Added group to test
r-tome Apr 4, 2024
26768b7
[AC-1682] Removed other temp table drops
r-tome Apr 4, 2024
9260ed9
Merge branch 'ac/ac-1682/ef-migrations' into ac/ac-1682/ef-migrations…
r-tome Apr 4, 2024
617cc6a
[AC-1682] Added assertions for the groups access on the unit test
r-tome Apr 4, 2024
0fbf5c1
[AC-1682] Added MySql migration and script
r-tome Mar 22, 2024
61f611e
[AC-1682] Added Postgres migration and script
r-tome Mar 25, 2024
36ba0de
[AC-1682] Added Sqlite migration and script
r-tome Mar 25, 2024
95e76f8
[AC-1682] dotnet format
r-tome Mar 25, 2024
d9c08d8
[AC-1682] Fixed Sqlite query
r-tome Mar 28, 2024
7f7ffe1
[AC-1682] Drop temp tables if they exist when starting the scripts
r-tome Mar 29, 2024
bbff087
[AC-1682] Removed MySql transaction from script because EF migration …
r-tome Mar 29, 2024
139318e
[AC-1682] Setting FlexibleCollections = 1 only for Orgs that had data…
r-tome Mar 29, 2024
4ed911a
[AC-1682] Updated queries to check for OrganizationId
r-tome Mar 29, 2024
e2857ad
[AC-1682] Fixed MySql script
r-tome Mar 29, 2024
467e3dc
[AC-1682] Fixed Postgres query
r-tome Mar 29, 2024
28bfb52
[AC-1682] Fix Sqlite query
r-tome Mar 29, 2024
0a1f297
[AC-1682] Reverted scripts back to enabling Flexible Collections to a…
r-tome Apr 3, 2024
51c914e
[AC-1682] Removed dropping temporary table from scripts
r-tome Apr 4, 2024
c37b0c1
[AC-1682] Removed other temp table drops
r-tome Apr 4, 2024
7dc789f
[AC-1978] Fix issue that allows the web app to have the user type Man…
r-tome Apr 10, 2024
ed988ae
Merge branch 'main' into ac-1682
r-tome Apr 15, 2024
c0f16f4
Merge branch 'main' into ac-1682
r-tome Apr 25, 2024
36cdca7
[AC-1682] Bump dates on migration scripts
r-tome Apr 25, 2024
ba274f2
Merge branch 'main' into ac-1682
eliykat Apr 26, 2024
ee50ea5
[AC-1682] Updated integration tests to run for EF database providers
r-tome Mar 28, 2024
6edf1e0
[AC-1682] Moved EF data migration scripts to Infrastructure.EntityFra…
r-tome Mar 28, 2024
040e640
[AC-1682] Updated migrations to use execution interface
r-tome Mar 28, 2024
ad659bd
[AC-1682] Added summary to EnableCollectionEnhancements method
r-tome Mar 28, 2024
51ac31e
[AC-1682] Added unit test to verify migration across multiple organiz…
r-tome Apr 3, 2024
22204a9
[AC-1682] Added group to test
r-tome Apr 4, 2024
8af2e95
[AC-1682] Added assertions for the groups access on the unit test
r-tome Apr 4, 2024
f79bba5
[AC-1682] Update EF migration scripts
r-tome Apr 26, 2024
a0b0757
Merge branch 'ac/ac-1682/ef-migrations-tests' of https://github.com/b…
r-tome Apr 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/renovate.json
Expand Up @@ -44,7 +44,6 @@
"matchPackageNames": [
"AspNetCoreRateLimit",
"AspNetCoreRateLimit.Redis",
"Azure.Data.Tables",
"Azure.Extensions.AspNetCore.DataProtection.Blobs",
"Azure.Messaging.EventGrid",
"Azure.Messaging.ServiceBus",
Expand All @@ -54,6 +53,7 @@
"Fido2.AspNet",
"Duende.IdentityServer",
"Microsoft.Azure.Cosmos",
"Microsoft.Azure.Cosmos.Table",
"Microsoft.Extensions.Caching.StackExchangeRedis",
"Microsoft.Extensions.Identity.Stores",
"Otp.NET",
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/scan.yml
Expand Up @@ -10,6 +10,8 @@ on:
pull_request_target:
types: [opened, synchronize]

permissions: read-all

jobs:
check-run:
name: Check PR run
Expand All @@ -20,8 +22,6 @@ jobs:
runs-on: ubuntu-22.04
needs: check-run
permissions:
contents: read
pull-requests: write
security-events: write

steps:
Expand All @@ -46,17 +46,14 @@ jobs:
--output-path . ${{ env.INCREMENTAL }}

- name: Upload Checkmarx results to GitHub
uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
uses: github/codeql-action/upload-sarif@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # v3.24.6
with:
sarif_file: cx_result.sarif

quality:
name: Quality scan
runs-on: ubuntu-22.04
needs: check-run
permissions:
contents: read
pull-requests: write

steps:
- name: Check out repo
Expand Down
7 changes: 6 additions & 1 deletion bitwarden_license/src/Scim/appsettings.json
Expand Up @@ -30,6 +30,10 @@
"connectionString": "SECRET",
"applicationCacheTopicName": "SECRET"
},
"documentDb": {
"uri": "SECRET",
"key": "SECRET"
},
"sentry": {
"dsn": "SECRET"
},
Expand All @@ -54,5 +58,6 @@
"region": "SECRET"
}
},
"scimSettings": {}
"scimSettings": {
}
}
4 changes: 4 additions & 0 deletions bitwarden_license/src/Sso/appsettings.json
Expand Up @@ -31,6 +31,10 @@
"connectionString": "SECRET",
"applicationCacheTopicName": "SECRET"
},
"documentDb": {
"uri": "SECRET",
"key": "SECRET"
},
"notificationHub": {
"connectionString": "SECRET",
"hubName": "SECRET"
Expand Down
8 changes: 2 additions & 6 deletions src/Admin/Jobs/JobsHostedService.cs
Expand Up @@ -76,18 +76,14 @@ public override async Task StartAsync(CancellationToken cancellationToken)
{
new Tuple<Type, ITrigger>(typeof(DeleteSendsJob), everyFiveMinutesTrigger),
new Tuple<Type, ITrigger>(typeof(DatabaseExpiredGrantsJob), everyFridayAt10pmTrigger),
new Tuple<Type, ITrigger>(typeof(DatabaseUpdateStatisticsJob), everySaturdayAtMidnightTrigger),
new Tuple<Type, ITrigger>(typeof(DatabaseRebuildlIndexesJob), everySundayAtMidnightTrigger),
new Tuple<Type, ITrigger>(typeof(DeleteCiphersJob), everyDayAtMidnightUtc),
new Tuple<Type, ITrigger>(typeof(DatabaseExpiredSponsorshipsJob), everyMondayAtMidnightTrigger),
new Tuple<Type, ITrigger>(typeof(DeleteAuthRequestsJob), everyFifteenMinutesTrigger),
new Tuple<Type, ITrigger>(typeof(DeleteUnverifiedOrganizationDomainsJob), everyDayAtTwoAmUtcTrigger),
};

if (!(_globalSettings.SqlServer?.DisableDatabaseMaintenanceJobs ?? false))
{
jobs.Add(new Tuple<Type, ITrigger>(typeof(DatabaseUpdateStatisticsJob), everySaturdayAtMidnightTrigger));
jobs.Add(new Tuple<Type, ITrigger>(typeof(DatabaseRebuildlIndexesJob), everySundayAtMidnightTrigger));
}

if (!_globalSettings.SelfHosted)
{
jobs.Add(new Tuple<Type, ITrigger>(typeof(AliveJob), everyTopOfTheHourTrigger));
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/Startup.cs
Expand Up @@ -88,7 +88,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddBaseServices(globalSettings);
services.AddDefaultServices(globalSettings);
services.AddScoped<IAccessControlService, AccessControlService>();
services.AddBillingOperations();
services.AddBillingCommands();

#if OSS
services.AddOosServices();
Expand Down
4 changes: 4 additions & 0 deletions src/Admin/appsettings.json
Expand Up @@ -30,6 +30,10 @@
"connectionString": "SECRET",
"applicationCacheTopicName": "SECRET"
},
"documentDb": {
"uri": "SECRET",
"key": "SECRET"
},
"notificationHub": {
"connectionString": "SECRET",
"hubName": "SECRET"
Expand Down
8 changes: 4 additions & 4 deletions src/Api/AdminConsole/Controllers/OrganizationsController.cs
Expand Up @@ -67,7 +67,7 @@ public class OrganizationsController : Controller
private readonly IAddSecretsManagerSubscriptionCommand _addSecretsManagerSubscriptionCommand;
private readonly IPushNotificationService _pushNotificationService;
private readonly ICancelSubscriptionCommand _cancelSubscriptionCommand;
private readonly ISubscriberQueries _subscriberQueries;
private readonly IGetSubscriptionQuery _getSubscriptionQuery;
private readonly IReferenceEventService _referenceEventService;
private readonly IOrganizationEnableCollectionEnhancementsCommand _organizationEnableCollectionEnhancementsCommand;
private readonly IProviderRepository _providerRepository;
Expand Down Expand Up @@ -96,7 +96,7 @@ public class OrganizationsController : Controller
IAddSecretsManagerSubscriptionCommand addSecretsManagerSubscriptionCommand,
IPushNotificationService pushNotificationService,
ICancelSubscriptionCommand cancelSubscriptionCommand,
ISubscriberQueries subscriberQueries,
IGetSubscriptionQuery getSubscriptionQuery,
IReferenceEventService referenceEventService,
IOrganizationEnableCollectionEnhancementsCommand organizationEnableCollectionEnhancementsCommand,
IProviderRepository providerRepository,
Expand Down Expand Up @@ -124,7 +124,7 @@ public class OrganizationsController : Controller
_addSecretsManagerSubscriptionCommand = addSecretsManagerSubscriptionCommand;
_pushNotificationService = pushNotificationService;
_cancelSubscriptionCommand = cancelSubscriptionCommand;
_subscriberQueries = subscriberQueries;
_getSubscriptionQuery = getSubscriptionQuery;
_referenceEventService = referenceEventService;
_organizationEnableCollectionEnhancementsCommand = organizationEnableCollectionEnhancementsCommand;
_providerRepository = providerRepository;
Expand Down Expand Up @@ -486,7 +486,7 @@ public async Task PostCancel(Guid id, [FromBody] SubscriptionCancellationRequest
throw new NotFoundException();
}

var subscription = await _subscriberQueries.GetSubscriptionOrThrow(organization);
var subscription = await _getSubscriptionQuery.GetSubscription(organization);

await _cancelSubscriptionCommand.CancelSubscription(subscription,
new OffboardingSurveyResponse
Expand Down
Expand Up @@ -126,14 +126,8 @@ public OrganizationSubscriptionResponseModel(Organization organization, Subscrip
if (hideSensitiveData)
{
BillingEmail = null;
if (Subscription != null)
{
Subscription.Items = null;
}
if (UpcomingInvoice != null)
{
UpcomingInvoice.Amount = null;
}
Subscription.Items = null;
UpcomingInvoice.Amount = null;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Api/Auth/Controllers/AccountsController.cs
Expand Up @@ -69,7 +69,7 @@ public class AccountsController : Controller
private readonly IRotateUserKeyCommand _rotateUserKeyCommand;
private readonly IFeatureService _featureService;
private readonly ICancelSubscriptionCommand _cancelSubscriptionCommand;
private readonly ISubscriberQueries _subscriberQueries;
private readonly IGetSubscriptionQuery _getSubscriptionQuery;
private readonly IReferenceEventService _referenceEventService;
private readonly ICurrentContext _currentContext;

Expand Down Expand Up @@ -104,7 +104,7 @@ public class AccountsController : Controller
IRotateUserKeyCommand rotateUserKeyCommand,
IFeatureService featureService,
ICancelSubscriptionCommand cancelSubscriptionCommand,
ISubscriberQueries subscriberQueries,
IGetSubscriptionQuery getSubscriptionQuery,
IReferenceEventService referenceEventService,
ICurrentContext currentContext,
IRotationValidator<IEnumerable<CipherWithIdRequestModel>, IEnumerable<Cipher>> cipherValidator,
Expand Down Expand Up @@ -133,7 +133,7 @@ public class AccountsController : Controller
_rotateUserKeyCommand = rotateUserKeyCommand;
_featureService = featureService;
_cancelSubscriptionCommand = cancelSubscriptionCommand;
_subscriberQueries = subscriberQueries;
_getSubscriptionQuery = getSubscriptionQuery;
_referenceEventService = referenceEventService;
_currentContext = currentContext;
_cipherValidator = cipherValidator;
Expand Down Expand Up @@ -831,7 +831,7 @@ public async Task PostCancel([FromBody] SubscriptionCancellationRequestModel req
throw new UnauthorizedAccessException();
}

var subscription = await _subscriberQueries.GetSubscriptionOrThrow(user);
var subscription = await _getSubscriptionQuery.GetSubscription(user);

await _cancelSubscriptionCommand.CancelSubscription(subscription,
new OffboardingSurveyResponse
Expand Down
3 changes: 3 additions & 0 deletions src/Api/Controllers/CollectionsController.cs
Expand Up @@ -2,6 +2,7 @@
using Bit.Api.Models.Response;
using Bit.Api.Utilities;
using Bit.Api.Vault.AuthorizationHandlers.Collections;
using Bit.Core;
using Bit.Core.Context;
using Bit.Core.Entities;
using Bit.Core.Enums;
Expand All @@ -10,6 +11,7 @@
using Bit.Core.OrganizationFeatures.OrganizationCollections.Interfaces;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

Expand Down Expand Up @@ -320,6 +322,7 @@ public async Task PutUsers(Guid orgId, Guid id, [FromBody] IEnumerable<Selection
}

[HttpPost("bulk-access")]
[RequireFeature(FeatureFlagKeys.BulkCollectionAccess)]
public async Task PostBulkCollectionAccess(Guid orgId, [FromBody] BulkCollectionAccessRequestModel model)
{
// Authorization logic assumes flexible collections is enabled
Expand Down
8 changes: 0 additions & 8 deletions src/Api/Models/Response/SubscriptionResponseModel.cs
Expand Up @@ -67,10 +67,6 @@ public BillingSubscription(SubscriptionInfo.BillingSubscription sub)
{
Items = sub.Items.Select(i => new BillingSubscriptionItem(i));
}
CollectionMethod = sub.CollectionMethod;
SuspensionDate = sub.SuspensionDate;
UnpaidPeriodEndDate = sub.UnpaidPeriodEndDate;
GracePeriod = sub.GracePeriod;
}

public DateTime? TrialStartDate { get; set; }
Expand All @@ -82,10 +78,6 @@ public BillingSubscription(SubscriptionInfo.BillingSubscription sub)
public string Status { get; set; }
public bool Cancelled { get; set; }
public IEnumerable<BillingSubscriptionItem> Items { get; set; } = new List<BillingSubscriptionItem>();
public string CollectionMethod { get; set; }
public DateTime? SuspensionDate { get; set; }
public DateTime? UnpaidPeriodEndDate { get; set; }
public int? GracePeriod { get; set; }

public class BillingSubscriptionItem
{
Expand Down
3 changes: 2 additions & 1 deletion src/Api/Startup.cs
Expand Up @@ -170,7 +170,8 @@ public void ConfigureServices(IServiceCollection services)
services.AddDefaultServices(globalSettings);
services.AddOrganizationSubscriptionServices();
services.AddCoreLocalizationServices();
services.AddBillingOperations();
services.AddBillingCommands();
services.AddBillingQueries();

// Authorization Handlers
services.AddAuthorizationHandlers();
Expand Down
4 changes: 4 additions & 0 deletions src/Api/appsettings.json
Expand Up @@ -32,6 +32,10 @@
"send": {
"connectionString": "SECRET"
},
"documentDb": {
"uri": "SECRET",
"key": "SECRET"
},
"sentry": {
"dsn": "SECRET"
},
Expand Down
4 changes: 4 additions & 0 deletions src/Billing/appsettings.json
Expand Up @@ -30,6 +30,10 @@
"connectionString": "SECRET",
"applicationCacheTopicName": "SECRET"
},
"documentDb": {
"uri": "SECRET",
"key": "SECRET"
},
"sentry": {
"dsn": "SECRET"
},
Expand Down
22 changes: 1 addition & 21 deletions src/Core/AdminConsole/Entities/Provider/Provider.cs
Expand Up @@ -6,7 +6,7 @@

namespace Bit.Core.AdminConsole.Entities.Provider;

public class Provider : ITableObject<Guid>, ISubscriber
public class Provider : ITableObject<Guid>
{
public Guid Id { get; set; }
/// <summary>
Expand Down Expand Up @@ -34,26 +34,6 @@ public class Provider : ITableObject<Guid>, ISubscriber
public string GatewayCustomerId { get; set; }
public string GatewaySubscriptionId { get; set; }

public string BillingEmailAddress() => BillingEmail?.ToLowerInvariant().Trim();

public string BillingName() => DisplayBusinessName();

public string SubscriberName() => DisplayName();

public string BraintreeCustomerIdPrefix() => "p";

public string BraintreeIdField() => "provider_id";

public string BraintreeCloudRegionField() => "region";

public bool IsOrganization() => false;

public bool IsUser() => false;

public string SubscriberType() => "Provider";

public bool IsExpired() => false;

public void SetNewId()
{
if (Id == default)
Expand Down
Expand Up @@ -146,8 +146,7 @@ public Organization ToOrganization()
OwnersNotifiedOfAutoscaling = OwnersNotifiedOfAutoscaling,
LimitCollectionCreationDeletion = LimitCollectionCreationDeletion,
AllowAdminAccessToAllCollectionItems = AllowAdminAccessToAllCollectionItems,
FlexibleCollections = FlexibleCollections,
Status = Status
FlexibleCollections = FlexibleCollections
};
}
}
Expand Up @@ -15,5 +15,12 @@ public interface IOrganizationRepository : IRepository<Organization, Guid>
Task<SelfHostedOrganizationDetails> GetSelfHostedOrganizationDetailsById(Guid id);
Task<ICollection<Organization>> SearchUnassignedToProviderAsync(string name, string ownerEmail, int skip, int take);
Task<IEnumerable<string>> GetOwnerEmailAddressesById(Guid organizationId);
/// <summary>
/// Enable collection enhancements.
/// </summary>
/// <remarks>
/// On SQL, it will migrate the data for the given organization.
/// On EF providers, it will migrate the data for all existing organizations.
/// </remarks>
Task EnableCollectionEnhancements(Guid organizationId);
}
9 changes: 0 additions & 9 deletions src/Core/Billing/BillingException.cs

This file was deleted.

2 changes: 2 additions & 0 deletions src/Core/Billing/Commands/ICancelSubscriptionCommand.cs
@@ -1,6 +1,7 @@
using Bit.Core.AdminConsole.Entities;
using Bit.Core.Billing.Models;
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Stripe;

namespace Bit.Core.Billing.Commands;
Expand All @@ -16,6 +17,7 @@ public interface ICancelSubscriptionCommand
/// <param name="subscription">The <see cref="User"/> or <see cref="Organization"/> with the subscription to cancel.</param>
/// <param name="offboardingSurveyResponse">An <see cref="OffboardingSurveyResponse"/> DTO containing user-provided feedback on why they are cancelling the subscription.</param>
/// <param name="cancelImmediately">A flag indicating whether to cancel the subscription immediately or at the end of the subscription period.</param>
/// <exception cref="GatewayException">Thrown when the provided subscription is already in an inactive state.</exception>
Task CancelSubscription(
Subscription subscription,
OffboardingSurveyResponse offboardingSurveyResponse,
Expand Down
7 changes: 0 additions & 7 deletions src/Core/Billing/Commands/IRemovePaymentMethodCommand.cs
Expand Up @@ -4,12 +4,5 @@ namespace Bit.Core.Billing.Commands;

public interface IRemovePaymentMethodCommand
{
/// <summary>
/// Attempts to remove an Organization's saved payment method. If the Stripe <see cref="Stripe.Customer"/> representing the
/// <see cref="Organization"/> contains a valid <b>"btCustomerId"</b> key in its <see cref="Stripe.Customer.Metadata"/> property,
/// this command will attempt to remove the Braintree <see cref="Braintree.PaymentMethod"/>. Otherwise, it will attempt to remove the
/// Stripe <see cref="Stripe.PaymentMethod"/>.
/// </summary>
/// <param name="organization">The organization to remove the saved payment method for.</param>
Task RemovePaymentMethod(Organization organization);
}