Skip to content

Commit 35868c2

Browse files
[PM-22434] Remove CreateDefaultLocation feature flag references (#6758)
* chore: remove ff ref from PoliciesController * chore: remove ff ref from OrganizationExportController, refs PM-22434 * chore: remove ff ref from CiphersController, refs PM-22434 * chore: remove ff ref from ConfirmOrganizationUserCommand, refs PM-22434 * chore: remove ff refs from OrganizationDataOwnershipPolicyValidator, refs PM-22434 * chore: remove ff ref from OrganizationUserControllerTests, refs PM-22434 * chore: remove ff refs from ConfirmOrganizationUserCommandTests, refs PM-22434 * chore: remove ff refs from OrganizationDataOwnershipPolicyValidatorTests, refs PM-22434 * chore: format, refs PM-22434
1 parent 2442d2d commit 35868c2

File tree

8 files changed

+15
-149
lines changed

8 files changed

+15
-149
lines changed

src/Api/AdminConsole/Controllers/PoliciesController.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Bit.Api.AdminConsole.Models.Response.Helpers;
88
using Bit.Api.AdminConsole.Models.Response.Organizations;
99
using Bit.Api.Models.Response;
10-
using Bit.Core;
1110
using Bit.Core.AdminConsole.Entities;
1211
using Bit.Core.AdminConsole.Enums;
1312
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationDomains.Interfaces;
@@ -212,7 +211,6 @@ public async Task<PolicyResponseModel> Put(Guid orgId, PolicyType type, [FromBod
212211
}
213212

214213
[HttpPut("{type}/vnext")]
215-
[RequireFeatureAttribute(FeatureFlagKeys.CreateDefaultLocation)]
216214
[Authorize<ManagePoliciesRequirement>]
217215
public async Task<PolicyResponseModel> PutVNext(Guid orgId, PolicyType type, [FromBody] SavePolicyRequest model)
218216
{

src/Api/Tools/Controllers/OrganizationExportController.cs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Bit.Api.Tools.Authorization;
22
using Bit.Api.Tools.Models.Response;
3-
using Bit.Core;
43
using Bit.Core.AdminConsole.OrganizationFeatures.Shared.Authorization;
54
using Bit.Core.Exceptions;
65
using Bit.Core.Repositories;
@@ -21,7 +20,6 @@ public class OrganizationExportController : Controller
2120
private readonly IAuthorizationService _authorizationService;
2221
private readonly IOrganizationCiphersQuery _organizationCiphersQuery;
2322
private readonly ICollectionRepository _collectionRepository;
24-
private readonly IFeatureService _featureService;
2523

2624
public OrganizationExportController(
2725
IUserService userService,
@@ -36,7 +34,6 @@ public OrganizationExportController(
3634
_authorizationService = authorizationService;
3735
_organizationCiphersQuery = organizationCiphersQuery;
3836
_collectionRepository = collectionRepository;
39-
_featureService = featureService;
4037
}
4138

4239
[HttpGet("export")]
@@ -46,33 +43,20 @@ public async Task<IActionResult> Export(Guid organizationId)
4643
VaultExportOperations.ExportWholeVault);
4744
var canExportManaged = await _authorizationService.AuthorizeAsync(User, new OrganizationScope(organizationId),
4845
VaultExportOperations.ExportManagedCollections);
49-
var createDefaultLocationEnabled = _featureService.IsEnabled(FeatureFlagKeys.CreateDefaultLocation);
5046

5147
if (canExportAll.Succeeded)
5248
{
53-
if (createDefaultLocationEnabled)
54-
{
55-
var allOrganizationCiphers =
56-
await _organizationCiphersQuery.GetAllOrganizationCiphersExcludingDefaultUserCollections(
57-
organizationId);
49+
var allOrganizationCiphers =
50+
await _organizationCiphersQuery.GetAllOrganizationCiphersExcludingDefaultUserCollections(
51+
organizationId);
5852

59-
var allCollections = await _collectionRepository
60-
.GetManySharedCollectionsByOrganizationIdAsync(
61-
organizationId);
53+
var allCollections = await _collectionRepository
54+
.GetManySharedCollectionsByOrganizationIdAsync(
55+
organizationId);
6256

6357

64-
return Ok(new OrganizationExportResponseModel(allOrganizationCiphers, allCollections,
65-
_globalSettings));
66-
}
67-
else
68-
{
69-
var allOrganizationCiphers = await _organizationCiphersQuery.GetAllOrganizationCiphers(organizationId);
70-
71-
var allCollections = await _collectionRepository.GetManyByOrganizationIdAsync(organizationId);
72-
73-
return Ok(new OrganizationExportResponseModel(allOrganizationCiphers, allCollections,
74-
_globalSettings));
75-
}
58+
return Ok(new OrganizationExportResponseModel(allOrganizationCiphers, allCollections,
59+
_globalSettings));
7660
}
7761

7862
if (canExportManaged.Succeeded)

src/Api/Vault/Controllers/CiphersController.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using Bit.Api.Vault.Models.Request;
1111
using Bit.Api.Vault.Models.Response;
1212
using Bit.Core;
13-
using Bit.Core.AdminConsole.Services;
1413
using Bit.Core.Context;
1514
using Bit.Core.Entities;
1615
using Bit.Core.Enums;
@@ -43,7 +42,6 @@ public class CiphersController : Controller
4342
private readonly ICipherService _cipherService;
4443
private readonly IUserService _userService;
4544
private readonly IAttachmentStorageService _attachmentStorageService;
46-
private readonly IProviderService _providerService;
4745
private readonly ICurrentContext _currentContext;
4846
private readonly ILogger<CiphersController> _logger;
4947
private readonly GlobalSettings _globalSettings;
@@ -52,31 +50,27 @@ public class CiphersController : Controller
5250
private readonly ICollectionRepository _collectionRepository;
5351
private readonly IArchiveCiphersCommand _archiveCiphersCommand;
5452
private readonly IUnarchiveCiphersCommand _unarchiveCiphersCommand;
55-
private readonly IFeatureService _featureService;
5653

5754
public CiphersController(
5855
ICipherRepository cipherRepository,
5956
ICollectionCipherRepository collectionCipherRepository,
6057
ICipherService cipherService,
6158
IUserService userService,
6259
IAttachmentStorageService attachmentStorageService,
63-
IProviderService providerService,
6460
ICurrentContext currentContext,
6561
ILogger<CiphersController> logger,
6662
GlobalSettings globalSettings,
6763
IOrganizationCiphersQuery organizationCiphersQuery,
6864
IApplicationCacheService applicationCacheService,
6965
ICollectionRepository collectionRepository,
7066
IArchiveCiphersCommand archiveCiphersCommand,
71-
IUnarchiveCiphersCommand unarchiveCiphersCommand,
72-
IFeatureService featureService)
67+
IUnarchiveCiphersCommand unarchiveCiphersCommand)
7368
{
7469
_cipherRepository = cipherRepository;
7570
_collectionCipherRepository = collectionCipherRepository;
7671
_cipherService = cipherService;
7772
_userService = userService;
7873
_attachmentStorageService = attachmentStorageService;
79-
_providerService = providerService;
8074
_currentContext = currentContext;
8175
_logger = logger;
8276
_globalSettings = globalSettings;
@@ -85,7 +79,6 @@ public CiphersController(
8579
_collectionRepository = collectionRepository;
8680
_archiveCiphersCommand = archiveCiphersCommand;
8781
_unarchiveCiphersCommand = unarchiveCiphersCommand;
88-
_featureService = featureService;
8982
}
9083

9184
[HttpGet("{id}")]
@@ -344,8 +337,7 @@ public async Task<ListResponseModel<CipherMiniDetailsResponseModel>> GetOrganiza
344337
throw new NotFoundException();
345338
}
346339

347-
bool excludeDefaultUserCollections = _featureService.IsEnabled(FeatureFlagKeys.CreateDefaultLocation) && !includeMemberItems;
348-
var allOrganizationCiphers = excludeDefaultUserCollections
340+
var allOrganizationCiphers = !includeMemberItems
349341
?
350342
await _organizationCiphersQuery.GetAllOrganizationCiphersExcludingDefaultUserCollections(organizationId)
351343
:

src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/ConfirmOrganizationUserCommand.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,6 @@ private async Task<IEnumerable<string>> GetUserDeviceIdsAsync(Guid userId)
280280
/// <param name="defaultUserCollectionName">The encrypted default user collection name.</param>
281281
private async Task CreateDefaultCollectionAsync(OrganizationUser organizationUser, string defaultUserCollectionName)
282282
{
283-
if (!_featureService.IsEnabled(FeatureFlagKeys.CreateDefaultLocation))
284-
{
285-
return;
286-
}
287-
288283
// Skip if no collection name provided (backwards compatibility)
289284
if (string.IsNullOrWhiteSpace(defaultUserCollectionName))
290285
{
@@ -323,11 +318,6 @@ private async Task CreateDefaultCollectionAsync(OrganizationUser organizationUse
323318
private async Task CreateManyDefaultCollectionsAsync(Guid organizationId,
324319
IEnumerable<OrganizationUser> confirmedOrganizationUsers, string defaultUserCollectionName)
325320
{
326-
if (!_featureService.IsEnabled(FeatureFlagKeys.CreateDefaultLocation))
327-
{
328-
return;
329-
}
330-
331321
// Skip if no collection name provided (backwards compatibility)
332322
if (string.IsNullOrWhiteSpace(defaultUserCollectionName))
333323
{

src/Core/AdminConsole/OrganizationFeatures/Policies/PolicyValidators/OrganizationDataOwnershipPolicyValidator.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyUpdateEvents.Interfaces;
77
using Bit.Core.AdminConsole.Repositories;
88
using Bit.Core.Repositories;
9-
using Bit.Core.Services;
109

1110
namespace Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyValidators;
1211

1312
public class OrganizationDataOwnershipPolicyValidator(
1413
IPolicyRepository policyRepository,
1514
ICollectionRepository collectionRepository,
16-
IEnumerable<IPolicyRequirementFactory<IPolicyRequirement>> factories,
17-
IFeatureService featureService)
15+
IEnumerable<IPolicyRequirementFactory<IPolicyRequirement>> factories)
1816
: OrganizationPolicyValidator(policyRepository, factories), IPostSavePolicySideEffect, IOnPolicyPostUpdateEvent
1917
{
2018
public PolicyType Type => PolicyType.OrganizationDataOwnership;
@@ -32,11 +30,6 @@ public async Task ExecuteSideEffectsAsync(
3230
Policy postUpdatedPolicy,
3331
Policy? previousPolicyState)
3432
{
35-
if (!featureService.IsEnabled(FeatureFlagKeys.CreateDefaultLocation))
36-
{
37-
return;
38-
}
39-
4033
if (policyRequest.Metadata is not OrganizationModelOwnershipPolicyModel metadata)
4134
{
4235
return;

test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUserControllerTests.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Bit.Api.IntegrationTest.Helpers;
66
using Bit.Api.Models.Request;
77
using Bit.Api.Models.Response;
8-
using Bit.Core;
98
using Bit.Core.AdminConsole.Entities;
109
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.DeleteClaimedAccount;
1110
using Bit.Core.AdminConsole.Repositories;
@@ -14,8 +13,6 @@
1413
using Bit.Core.Enums;
1514
using Bit.Core.Models.Data;
1615
using Bit.Core.Repositories;
17-
using Bit.Core.Services;
18-
using NSubstitute;
1916
using Xunit;
2017

2118
namespace Bit.Api.IntegrationTest.AdminConsole.Controllers;
@@ -28,12 +25,6 @@ public class OrganizationUserControllerTests : IClassFixture<ApiApplicationFacto
2825
public OrganizationUserControllerTests(ApiApplicationFactory apiFactory)
2926
{
3027
_factory = apiFactory;
31-
_factory.SubstituteService<IFeatureService>(featureService =>
32-
{
33-
featureService
34-
.IsEnabled(FeatureFlagKeys.CreateDefaultLocation)
35-
.Returns(true);
36-
});
3728
_client = _factory.CreateClient();
3829
_loginHelper = new LoginHelper(_factory, _client);
3930
}

test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/ConfirmOrganizationUserCommandTests.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ public async Task ConfirmUserAsync_WithPolicyRequirementsEnabled_AndTwoFactorEna
462462
}
463463

464464
[Theory, BitAutoData]
465-
public async Task ConfirmUserAsync_WithCreateDefaultLocationEnabled_WithOrganizationDataOwnershipPolicyApplicable_WithValidCollectionName_CreatesDefaultCollection(
465+
public async Task ConfirmUserAsync_WithOrganizationDataOwnershipPolicyApplicable_WithValidCollectionName_CreatesDefaultCollection(
466466
Organization organization, OrganizationUser confirmingUser,
467467
[OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
468468
string key, string collectionName, SutProvider<ConfirmOrganizationUserCommand> sutProvider)
@@ -475,8 +475,6 @@ public async Task ConfirmUserAsync_WithCreateDefaultLocationEnabled_WithOrganiza
475475
sutProvider.GetDependency<IOrganizationUserRepository>().GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
476476
sutProvider.GetDependency<IUserRepository>().GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
477477

478-
sutProvider.GetDependency<IFeatureService>().IsEnabled(FeatureFlagKeys.CreateDefaultLocation).Returns(true);
479-
480478
var policyDetails = new PolicyDetails
481479
{
482480
OrganizationId = organization.Id,
@@ -506,7 +504,7 @@ await sutProvider.GetDependency<ICollectionRepository>()
506504
}
507505

508506
[Theory, BitAutoData]
509-
public async Task ConfirmUserAsync_WithCreateDefaultLocationEnabled_WithOrganizationDataOwnershipPolicyApplicable_WithInvalidCollectionName_DoesNotCreateDefaultCollection(
507+
public async Task ConfirmUserAsync_WithOrganizationDataOwnershipPolicyApplicable_WithInvalidCollectionName_DoesNotCreateDefaultCollection(
510508
Organization org, OrganizationUser confirmingUser,
511509
[OrganizationUser(OrganizationUserStatusType.Accepted)] OrganizationUser orgUser, User user,
512510
string key, SutProvider<ConfirmOrganizationUserCommand> sutProvider)
@@ -519,8 +517,6 @@ public async Task ConfirmUserAsync_WithCreateDefaultLocationEnabled_WithOrganiza
519517
sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(org.Id).Returns(org);
520518
sutProvider.GetDependency<IUserRepository>().GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
521519

522-
sutProvider.GetDependency<IFeatureService>().IsEnabled(FeatureFlagKeys.CreateDefaultLocation).Returns(true);
523-
524520
await sutProvider.Sut.ConfirmUserAsync(orgUser.OrganizationId, orgUser.Id, key, confirmingUser.Id, "");
525521

526522
await sutProvider.GetDependency<ICollectionRepository>()
@@ -529,7 +525,7 @@ await sutProvider.GetDependency<ICollectionRepository>()
529525
}
530526

531527
[Theory, BitAutoData]
532-
public async Task ConfirmUserAsync_WithCreateDefaultLocationEnabled_WithOrganizationDataOwnershipPolicyNotApplicable_DoesNotCreateDefaultCollection(
528+
public async Task ConfirmUserAsync_WithOrganizationDataOwnershipPolicyNotApplicable_DoesNotCreateDefaultCollection(
533529
Organization org, OrganizationUser confirmingUser,
534530
[OrganizationUser(OrganizationUserStatusType.Accepted, OrganizationUserType.Owner)] OrganizationUser orgUser, User user,
535531
string key, string collectionName, SutProvider<ConfirmOrganizationUserCommand> sutProvider)
@@ -541,7 +537,6 @@ public async Task ConfirmUserAsync_WithCreateDefaultLocationEnabled_WithOrganiza
541537
sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(org.Id).Returns(org);
542538
sutProvider.GetDependency<IOrganizationUserRepository>().GetManyAsync(default).ReturnsForAnyArgs(new[] { orgUser });
543539
sutProvider.GetDependency<IUserRepository>().GetManyAsync(default).ReturnsForAnyArgs(new[] { user });
544-
sutProvider.GetDependency<IFeatureService>().IsEnabled(FeatureFlagKeys.CreateDefaultLocation).Returns(true);
545540

546541
var policyDetails = new PolicyDetails
547542
{

0 commit comments

Comments
 (0)