From 4d59dd4a6b13ccc745f41e13497af12f2d4213f5 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Mon, 28 Aug 2023 10:20:01 +1000 Subject: [PATCH] Fix typo: CurrentContent -> CurrentContext (#3231) --- src/Core/Context/CurrentContext.cs | 36 +++++++++---------- ...ation.cs => CurrentContextOrganization.cs} | 6 ++-- ...tProvider.cs => CurrentContextProvider.cs} | 6 ++-- src/Core/Context/ICurrentContext.cs | 6 ++-- src/Core/Utilities/CoreHelpers.cs | 4 +-- .../AutoFixture/CurrentContextFixtures.cs | 2 +- test/Core.Test/Utilities/CoreHelpersTests.cs | 18 +++++----- 7 files changed, 39 insertions(+), 39 deletions(-) rename src/Core/Context/{CurrentContentOrganization.cs => CurrentContextOrganization.cs} (81%) rename src/Core/Context/{CurrentContentProvider.cs => CurrentContextProvider.cs} (77%) diff --git a/src/Core/Context/CurrentContext.cs b/src/Core/Context/CurrentContext.cs index 627e4f584..4877a9a8f 100644 --- a/src/Core/Context/CurrentContext.cs +++ b/src/Core/Context/CurrentContext.cs @@ -26,8 +26,8 @@ public class CurrentContext : ICurrentContext public virtual string DeviceIdentifier { get; set; } public virtual DeviceType? DeviceType { get; set; } public virtual string IpAddress { get; set; } - public virtual List Organizations { get; set; } - public virtual List Providers { get; set; } + public virtual List Organizations { get; set; } + public virtual List Providers { get; set; } public virtual Guid? InstallationId { get; set; } public virtual Guid? OrganizationId { get; set; } public virtual bool CloudflareWorkerProxied { get; set; } @@ -166,17 +166,17 @@ public class CurrentContext : ICurrentContext return Task.FromResult(0); } - private List GetOrganizations(Dictionary> claimsDict, bool orgApi) + private List GetOrganizations(Dictionary> claimsDict, bool orgApi) { var accessSecretsManager = claimsDict.ContainsKey(Claims.SecretsManagerAccess) ? claimsDict[Claims.SecretsManagerAccess].ToDictionary(s => s.Value, _ => true) : new Dictionary(); - var organizations = new List(); + var organizations = new List(); if (claimsDict.ContainsKey(Claims.OrganizationOwner)) { organizations.AddRange(claimsDict[Claims.OrganizationOwner].Select(c => - new CurrentContentOrganization + new CurrentContextOrganization { Id = new Guid(c.Value), Type = OrganizationUserType.Owner, @@ -185,7 +185,7 @@ public class CurrentContext : ICurrentContext } else if (orgApi && OrganizationId.HasValue) { - organizations.Add(new CurrentContentOrganization + organizations.Add(new CurrentContextOrganization { Id = OrganizationId.Value, Type = OrganizationUserType.Owner, @@ -195,7 +195,7 @@ public class CurrentContext : ICurrentContext if (claimsDict.ContainsKey(Claims.OrganizationAdmin)) { organizations.AddRange(claimsDict[Claims.OrganizationAdmin].Select(c => - new CurrentContentOrganization + new CurrentContextOrganization { Id = new Guid(c.Value), Type = OrganizationUserType.Admin, @@ -206,7 +206,7 @@ public class CurrentContext : ICurrentContext if (claimsDict.ContainsKey(Claims.OrganizationUser)) { organizations.AddRange(claimsDict[Claims.OrganizationUser].Select(c => - new CurrentContentOrganization + new CurrentContextOrganization { Id = new Guid(c.Value), Type = OrganizationUserType.User, @@ -217,7 +217,7 @@ public class CurrentContext : ICurrentContext if (claimsDict.ContainsKey(Claims.OrganizationManager)) { organizations.AddRange(claimsDict[Claims.OrganizationManager].Select(c => - new CurrentContentOrganization + new CurrentContextOrganization { Id = new Guid(c.Value), Type = OrganizationUserType.Manager, @@ -228,7 +228,7 @@ public class CurrentContext : ICurrentContext if (claimsDict.ContainsKey(Claims.OrganizationCustom)) { organizations.AddRange(claimsDict[Claims.OrganizationCustom].Select(c => - new CurrentContentOrganization + new CurrentContextOrganization { Id = new Guid(c.Value), Type = OrganizationUserType.Custom, @@ -240,13 +240,13 @@ public class CurrentContext : ICurrentContext return organizations; } - private List GetProviders(Dictionary> claimsDict) + private List GetProviders(Dictionary> claimsDict) { - var providers = new List(); + var providers = new List(); if (claimsDict.ContainsKey(Claims.ProviderAdmin)) { providers.AddRange(claimsDict[Claims.ProviderAdmin].Select(c => - new CurrentContentProvider + new CurrentContextProvider { Id = new Guid(c.Value), Type = ProviderUserType.ProviderAdmin @@ -256,7 +256,7 @@ public class CurrentContext : ICurrentContext if (claimsDict.ContainsKey(Claims.ProviderServiceUser)) { providers.AddRange(claimsDict[Claims.ProviderServiceUser].Select(c => - new CurrentContentProvider + new CurrentContextProvider { Id = new Guid(c.Value), Type = ProviderUserType.ServiceUser @@ -483,26 +483,26 @@ public class CurrentContext : ICurrentContext return Organizations?.Any(o => o.Id == orgId && o.AccessSecretsManager) ?? false; } - public async Task> OrganizationMembershipAsync( + public async Task> OrganizationMembershipAsync( IOrganizationUserRepository organizationUserRepository, Guid userId) { if (Organizations == null) { var userOrgs = await organizationUserRepository.GetManyDetailsByUserAsync(userId); Organizations = userOrgs.Where(ou => ou.Status == OrganizationUserStatusType.Confirmed) - .Select(ou => new CurrentContentOrganization(ou)).ToList(); + .Select(ou => new CurrentContextOrganization(ou)).ToList(); } return Organizations; } - public async Task> ProviderMembershipAsync( + public async Task> ProviderMembershipAsync( IProviderUserRepository providerUserRepository, Guid userId) { if (Providers == null) { var userProviders = await providerUserRepository.GetManyByUserAsync(userId); Providers = userProviders.Where(ou => ou.Status == ProviderUserStatusType.Confirmed) - .Select(ou => new CurrentContentProvider(ou)).ToList(); + .Select(ou => new CurrentContextProvider(ou)).ToList(); } return Providers; } diff --git a/src/Core/Context/CurrentContentOrganization.cs b/src/Core/Context/CurrentContextOrganization.cs similarity index 81% rename from src/Core/Context/CurrentContentOrganization.cs rename to src/Core/Context/CurrentContextOrganization.cs index b21598a03..cf2c8b40c 100644 --- a/src/Core/Context/CurrentContentOrganization.cs +++ b/src/Core/Context/CurrentContextOrganization.cs @@ -5,11 +5,11 @@ using Bit.Core.Utilities; namespace Bit.Core.Context; -public class CurrentContentOrganization +public class CurrentContextOrganization { - public CurrentContentOrganization() { } + public CurrentContextOrganization() { } - public CurrentContentOrganization(OrganizationUserOrganizationDetails orgUser) + public CurrentContextOrganization(OrganizationUserOrganizationDetails orgUser) { Id = orgUser.OrganizationId; Type = orgUser.Type; diff --git a/src/Core/Context/CurrentContentProvider.cs b/src/Core/Context/CurrentContextProvider.cs similarity index 77% rename from src/Core/Context/CurrentContentProvider.cs rename to src/Core/Context/CurrentContextProvider.cs index f089be7b8..57792840c 100644 --- a/src/Core/Context/CurrentContentProvider.cs +++ b/src/Core/Context/CurrentContextProvider.cs @@ -5,11 +5,11 @@ using Bit.Core.Utilities; namespace Bit.Core.Context; -public class CurrentContentProvider +public class CurrentContextProvider { - public CurrentContentProvider() { } + public CurrentContextProvider() { } - public CurrentContentProvider(ProviderUser providerUser) + public CurrentContextProvider(ProviderUser providerUser) { Id = providerUser.ProviderId; Type = providerUser.Type; diff --git a/src/Core/Context/ICurrentContext.cs b/src/Core/Context/ICurrentContext.cs index 76a71e01a..c2e362d43 100644 --- a/src/Core/Context/ICurrentContext.cs +++ b/src/Core/Context/ICurrentContext.cs @@ -16,7 +16,7 @@ public interface ICurrentContext string DeviceIdentifier { get; set; } DeviceType? DeviceType { get; set; } string IpAddress { get; set; } - List Organizations { get; set; } + List Organizations { get; set; } Guid? InstallationId { get; set; } Guid? OrganizationId { get; set; } ClientType ClientType { get; set; } @@ -64,10 +64,10 @@ public interface ICurrentContext bool AccessProviderOrganizations(Guid providerId); bool ManageProviderOrganizations(Guid providerId); - Task> OrganizationMembershipAsync( + Task> OrganizationMembershipAsync( IOrganizationUserRepository organizationUserRepository, Guid userId); - Task> ProviderMembershipAsync( + Task> ProviderMembershipAsync( IProviderUserRepository providerUserRepository, Guid userId); Task ProviderIdForOrg(Guid orgId); diff --git a/src/Core/Utilities/CoreHelpers.cs b/src/Core/Utilities/CoreHelpers.cs index f0c3d1833..66ff08c07 100644 --- a/src/Core/Utilities/CoreHelpers.cs +++ b/src/Core/Utilities/CoreHelpers.cs @@ -624,8 +624,8 @@ public static class CoreHelpers return configDict; } - public static List> BuildIdentityClaims(User user, ICollection orgs, - ICollection providers, bool isPremium) + public static List> BuildIdentityClaims(User user, ICollection orgs, + ICollection providers, bool isPremium) { var claims = new List>() { diff --git a/test/Core.Test/AutoFixture/CurrentContextFixtures.cs b/test/Core.Test/AutoFixture/CurrentContextFixtures.cs index 0f6c3ee95..a7b2f6d55 100644 --- a/test/Core.Test/AutoFixture/CurrentContextFixtures.cs +++ b/test/Core.Test/AutoFixture/CurrentContextFixtures.cs @@ -32,7 +32,7 @@ internal class CurrentContextBuilder : ISpecimenBuilder } var obj = new Fixture().WithAutoNSubstitutions().Create(); - obj.Organizations = context.Create>(); + obj.Organizations = context.Create>(); return obj; } } diff --git a/test/Core.Test/Utilities/CoreHelpersTests.cs b/test/Core.Test/Utilities/CoreHelpersTests.cs index f66f9ca01..b4a4034d9 100644 --- a/test/Core.Test/Utilities/CoreHelpersTests.cs +++ b/test/Core.Test/Utilities/CoreHelpersTests.cs @@ -273,8 +273,8 @@ public class CoreHelpersTests { "sstamp", user.SecurityStamp }, }.ToList(); - var actual = CoreHelpers.BuildIdentityClaims(user, Array.Empty(), - Array.Empty(), isPremium); + var actual = CoreHelpers.BuildIdentityClaims(user, Array.Empty(), + Array.Empty(), isPremium); foreach (var claim in expected) { @@ -289,23 +289,23 @@ public class CoreHelpersTests var fixture = new Fixture().WithAutoNSubstitutions(); foreach (var organizationUserType in Enum.GetValues().Except(new[] { OrganizationUserType.Custom })) { - var org = fixture.Create(); + var org = fixture.Create(); org.Type = organizationUserType; var expected = new KeyValuePair($"org{organizationUserType.ToString().ToLower()}", org.Id.ToString()); - var actual = CoreHelpers.BuildIdentityClaims(user, new[] { org }, Array.Empty(), false); + var actual = CoreHelpers.BuildIdentityClaims(user, new[] { org }, Array.Empty(), false); Assert.Contains(expected, actual); } } [Theory, BitAutoData, UserCustomize] - public void BuildIdentityClaims_CustomOrganizationUserClaims_Success(User user, CurrentContentOrganization org) + public void BuildIdentityClaims_CustomOrganizationUserClaims_Success(User user, CurrentContextOrganization org) { var fixture = new Fixture().WithAutoNSubstitutions(); org.Type = OrganizationUserType.Custom; - var actual = CoreHelpers.BuildIdentityClaims(user, new[] { org }, Array.Empty(), false); + var actual = CoreHelpers.BuildIdentityClaims(user, new[] { org }, Array.Empty(), false); foreach (var (permitted, claimName) in org.Permissions.ClaimsMap) { var claim = new KeyValuePair(claimName, org.Id.ToString()); @@ -325,10 +325,10 @@ public class CoreHelpersTests public void BuildIdentityClaims_ProviderClaims_Success(User user) { var fixture = new Fixture().WithAutoNSubstitutions(); - var providers = new List(); + var providers = new List(); foreach (var providerUserType in Enum.GetValues()) { - var provider = fixture.Create(); + var provider = fixture.Create(); provider.Type = providerUserType; providers.Add(provider); } @@ -357,7 +357,7 @@ public class CoreHelpersTests } } - var actual = CoreHelpers.BuildIdentityClaims(user, Array.Empty(), providers, false); + var actual = CoreHelpers.BuildIdentityClaims(user, Array.Empty(), providers, false); foreach (var claim in claims) { Assert.Contains(claim, actual);