mirror of
https://github.com/bitwarden/server
synced 2025-12-27 13:43:18 +00:00
Merge remote-tracking branch 'origin/master' into feature/sm-billing
This commit is contained in:
@@ -3273,133 +3273,133 @@
|
||||
"api": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AspNetCore.HealthChecks.AzureServiceBus": "[6.1.0, )",
|
||||
"AspNetCore.HealthChecks.AzureStorage": "[6.1.2, )",
|
||||
"AspNetCore.HealthChecks.Network": "[6.0.4, )",
|
||||
"AspNetCore.HealthChecks.Redis": "[6.0.4, )",
|
||||
"AspNetCore.HealthChecks.SendGrid": "[6.0.2, )",
|
||||
"AspNetCore.HealthChecks.SqlServer": "[6.0.2, )",
|
||||
"AspNetCore.HealthChecks.Uris": "[6.0.3, )",
|
||||
"Azure.Messaging.EventGrid": "[4.10.0, )",
|
||||
"Commercial.Core": "[2023.5.0, )",
|
||||
"Commercial.Infrastructure.EntityFramework": "[2023.5.0, )",
|
||||
"Core": "[2023.5.0, )",
|
||||
"SharedWeb": "[2023.5.0, )",
|
||||
"Swashbuckle.AspNetCore": "[6.5.0, )"
|
||||
"AspNetCore.HealthChecks.AzureServiceBus": "6.1.0",
|
||||
"AspNetCore.HealthChecks.AzureStorage": "6.1.2",
|
||||
"AspNetCore.HealthChecks.Network": "6.0.4",
|
||||
"AspNetCore.HealthChecks.Redis": "6.0.4",
|
||||
"AspNetCore.HealthChecks.SendGrid": "6.0.2",
|
||||
"AspNetCore.HealthChecks.SqlServer": "6.0.2",
|
||||
"AspNetCore.HealthChecks.Uris": "6.0.3",
|
||||
"Azure.Messaging.EventGrid": "4.10.0",
|
||||
"Commercial.Core": "2023.5.1",
|
||||
"Commercial.Infrastructure.EntityFramework": "2023.5.1",
|
||||
"Core": "2023.5.1",
|
||||
"SharedWeb": "2023.5.1",
|
||||
"Swashbuckle.AspNetCore": "6.5.0"
|
||||
}
|
||||
},
|
||||
"commercial.core": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "[2023.5.0, )"
|
||||
"Core": "2023.5.1"
|
||||
}
|
||||
},
|
||||
"commercial.infrastructure.entityframework": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
|
||||
"Core": "[2023.5.0, )",
|
||||
"Infrastructure.EntityFramework": "[2023.5.0, )"
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "12.0.1",
|
||||
"Core": "2023.5.1",
|
||||
"Infrastructure.EntityFramework": "2023.5.1"
|
||||
}
|
||||
},
|
||||
"common": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoFixture.AutoNSubstitute": "[4.17.0, )",
|
||||
"AutoFixture.Xunit2": "[4.17.0, )",
|
||||
"Core": "[2023.5.0, )",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "[1.2.0, )",
|
||||
"Microsoft.NET.Test.Sdk": "[17.1.0, )",
|
||||
"NSubstitute": "[4.3.0, )",
|
||||
"xunit": "[2.4.1, )"
|
||||
"AutoFixture.AutoNSubstitute": "4.17.0",
|
||||
"AutoFixture.Xunit2": "4.17.0",
|
||||
"Core": "2023.5.1",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "1.2.0",
|
||||
"Microsoft.NET.Test.Sdk": "17.1.0",
|
||||
"NSubstitute": "4.3.0",
|
||||
"xunit": "2.4.1"
|
||||
}
|
||||
},
|
||||
"core": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AWSSDK.SQS": "[3.7.2.47, )",
|
||||
"AWSSDK.SimpleEmail": "[3.7.0.150, )",
|
||||
"AspNetCoreRateLimit": "[4.0.2, )",
|
||||
"AspNetCoreRateLimit.Redis": "[1.0.1, )",
|
||||
"Azure.Extensions.AspNetCore.DataProtection.Blobs": "[1.3.2, )",
|
||||
"Azure.Storage.Blobs": "[12.14.1, )",
|
||||
"Azure.Storage.Queues": "[12.12.0, )",
|
||||
"BitPay.Light": "[1.0.1907, )",
|
||||
"Braintree": "[5.12.0, )",
|
||||
"DnsClient": "[1.7.0, )",
|
||||
"Fido2.AspNet": "[3.0.1, )",
|
||||
"Handlebars.Net": "[2.1.2, )",
|
||||
"IdentityServer4": "[4.1.2, )",
|
||||
"IdentityServer4.AccessTokenValidation": "[3.0.1, )",
|
||||
"LaunchDarkly.ServerSdk": "[7.0.0, )",
|
||||
"MailKit": "[3.2.0, )",
|
||||
"Microsoft.AspNetCore.Authentication.JwtBearer": "[6.0.4, )",
|
||||
"Microsoft.Azure.Cosmos.Table": "[1.0.8, )",
|
||||
"Microsoft.Azure.NotificationHubs": "[4.1.0, )",
|
||||
"Microsoft.Azure.ServiceBus": "[5.2.0, )",
|
||||
"Microsoft.Data.SqlClient": "[5.0.1, )",
|
||||
"Microsoft.Extensions.Caching.StackExchangeRedis": "[6.0.6, )",
|
||||
"Microsoft.Extensions.Configuration.EnvironmentVariables": "[6.0.1, )",
|
||||
"Microsoft.Extensions.Configuration.UserSecrets": "[6.0.1, )",
|
||||
"Microsoft.Extensions.Identity.Stores": "[6.0.4, )",
|
||||
"Newtonsoft.Json": "[13.0.1, )",
|
||||
"Otp.NET": "[1.2.2, )",
|
||||
"Quartz": "[3.4.0, )",
|
||||
"SendGrid": "[9.27.0, )",
|
||||
"Sentry.Serilog": "[3.16.0, )",
|
||||
"Serilog.AspNetCore": "[5.0.0, )",
|
||||
"Serilog.Extensions.Logging": "[3.1.0, )",
|
||||
"Serilog.Extensions.Logging.File": "[2.0.0, )",
|
||||
"Serilog.Sinks.AzureCosmosDB": "[2.0.0, )",
|
||||
"Serilog.Sinks.SyslogMessages": "[2.0.6, )",
|
||||
"Stripe.net": "[40.0.0, )",
|
||||
"YubicoDotNetClient": "[1.2.0, )"
|
||||
"AWSSDK.SQS": "3.7.2.47",
|
||||
"AWSSDK.SimpleEmail": "3.7.0.150",
|
||||
"AspNetCoreRateLimit": "4.0.2",
|
||||
"AspNetCoreRateLimit.Redis": "1.0.1",
|
||||
"Azure.Extensions.AspNetCore.DataProtection.Blobs": "1.3.2",
|
||||
"Azure.Storage.Blobs": "12.14.1",
|
||||
"Azure.Storage.Queues": "12.12.0",
|
||||
"BitPay.Light": "1.0.1907",
|
||||
"Braintree": "5.12.0",
|
||||
"DnsClient": "1.7.0",
|
||||
"Fido2.AspNet": "3.0.1",
|
||||
"Handlebars.Net": "2.1.2",
|
||||
"IdentityServer4": "4.1.2",
|
||||
"IdentityServer4.AccessTokenValidation": "3.0.1",
|
||||
"LaunchDarkly.ServerSdk": "7.0.0",
|
||||
"MailKit": "3.2.0",
|
||||
"Microsoft.AspNetCore.Authentication.JwtBearer": "6.0.4",
|
||||
"Microsoft.Azure.Cosmos.Table": "1.0.8",
|
||||
"Microsoft.Azure.NotificationHubs": "4.1.0",
|
||||
"Microsoft.Azure.ServiceBus": "5.2.0",
|
||||
"Microsoft.Data.SqlClient": "5.0.1",
|
||||
"Microsoft.Extensions.Caching.StackExchangeRedis": "6.0.6",
|
||||
"Microsoft.Extensions.Configuration.EnvironmentVariables": "6.0.1",
|
||||
"Microsoft.Extensions.Configuration.UserSecrets": "6.0.1",
|
||||
"Microsoft.Extensions.Identity.Stores": "6.0.4",
|
||||
"Newtonsoft.Json": "13.0.1",
|
||||
"Otp.NET": "1.2.2",
|
||||
"Quartz": "3.4.0",
|
||||
"SendGrid": "9.27.0",
|
||||
"Sentry.Serilog": "3.16.0",
|
||||
"Serilog.AspNetCore": "5.0.0",
|
||||
"Serilog.Extensions.Logging": "3.1.0",
|
||||
"Serilog.Extensions.Logging.File": "2.0.0",
|
||||
"Serilog.Sinks.AzureCosmosDB": "2.0.0",
|
||||
"Serilog.Sinks.SyslogMessages": "2.0.6",
|
||||
"Stripe.net": "40.0.0",
|
||||
"YubicoDotNetClient": "1.2.0"
|
||||
}
|
||||
},
|
||||
"identity": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "[2023.5.0, )",
|
||||
"SharedWeb": "[2023.5.0, )",
|
||||
"Swashbuckle.AspNetCore.SwaggerGen": "[6.5.0, )"
|
||||
"Core": "2023.5.1",
|
||||
"SharedWeb": "2023.5.1",
|
||||
"Swashbuckle.AspNetCore.SwaggerGen": "6.5.0"
|
||||
}
|
||||
},
|
||||
"infrastructure.dapper": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "[2023.5.0, )",
|
||||
"Dapper": "[2.0.123, )"
|
||||
"Core": "2023.5.1",
|
||||
"Dapper": "2.0.123"
|
||||
}
|
||||
},
|
||||
"infrastructure.entityframework": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
|
||||
"Core": "[2023.5.0, )",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "[6.0.12, )",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "[6.0.12, )",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "[6.0.12, )",
|
||||
"Npgsql.EntityFrameworkCore.PostgreSQL": "[6.0.8, )",
|
||||
"Pomelo.EntityFrameworkCore.MySql": "[6.0.2, )",
|
||||
"linq2db.EntityFrameworkCore": "[6.11.0, )"
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "12.0.1",
|
||||
"Core": "2023.5.1",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "6.0.12",
|
||||
"Npgsql.EntityFrameworkCore.PostgreSQL": "6.0.8",
|
||||
"Pomelo.EntityFrameworkCore.MySql": "6.0.2",
|
||||
"linq2db.EntityFrameworkCore": "6.11.0"
|
||||
}
|
||||
},
|
||||
"integrationtestcommon": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Common": "[2023.5.0, )",
|
||||
"Identity": "[2023.5.0, )",
|
||||
"Microsoft.AspNetCore.Mvc.Testing": "[6.0.5, )",
|
||||
"Microsoft.EntityFrameworkCore.InMemory": "[6.0.5, )",
|
||||
"Microsoft.Extensions.Configuration": "[6.0.1, )"
|
||||
"Common": "2023.5.1",
|
||||
"Identity": "2023.5.1",
|
||||
"Microsoft.AspNetCore.Mvc.Testing": "6.0.5",
|
||||
"Microsoft.EntityFrameworkCore.InMemory": "6.0.5",
|
||||
"Microsoft.Extensions.Configuration": "6.0.1"
|
||||
}
|
||||
},
|
||||
"sharedweb": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "[2023.5.0, )",
|
||||
"Infrastructure.Dapper": "[2023.5.0, )",
|
||||
"Infrastructure.EntityFramework": "[2023.5.0, )"
|
||||
"Core": "2023.5.1",
|
||||
"Infrastructure.Dapper": "2023.5.1",
|
||||
"Infrastructure.EntityFramework": "2023.5.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,12 +114,12 @@ public class ProjectsControllerTests
|
||||
|
||||
var resultProject = data.ToProject(orgId);
|
||||
|
||||
sutProvider.GetDependency<ICreateProjectCommand>().CreateAsync(default, default)
|
||||
sutProvider.GetDependency<ICreateProjectCommand>().CreateAsync(default, default, sutProvider.GetDependency<ICurrentContext>().ClientType)
|
||||
.ReturnsForAnyArgs(resultProject);
|
||||
|
||||
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.CreateAsync(orgId, data));
|
||||
await sutProvider.GetDependency<ICreateProjectCommand>().DidNotReceiveWithAnyArgs()
|
||||
.CreateAsync(Arg.Any<Project>(), Arg.Any<Guid>());
|
||||
.CreateAsync(Arg.Any<Project>(), Arg.Any<Guid>(), sutProvider.GetDependency<ICurrentContext>().ClientType);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -134,13 +134,13 @@ public class ProjectsControllerTests
|
||||
|
||||
var resultProject = data.ToProject(orgId);
|
||||
|
||||
sutProvider.GetDependency<ICreateProjectCommand>().CreateAsync(default, default)
|
||||
sutProvider.GetDependency<ICreateProjectCommand>().CreateAsync(default, default, sutProvider.GetDependency<ICurrentContext>().ClientType)
|
||||
.ReturnsForAnyArgs(resultProject);
|
||||
|
||||
await sutProvider.Sut.CreateAsync(orgId, data);
|
||||
|
||||
await sutProvider.GetDependency<ICreateProjectCommand>().Received(1)
|
||||
.CreateAsync(Arg.Any<Project>(), Arg.Any<Guid>());
|
||||
.CreateAsync(Arg.Any<Project>(), Arg.Any<Guid>(), sutProvider.GetDependency<ICurrentContext>().ClientType);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
||||
@@ -3151,129 +3151,129 @@
|
||||
"api": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AspNetCore.HealthChecks.AzureServiceBus": "[6.1.0, )",
|
||||
"AspNetCore.HealthChecks.AzureStorage": "[6.1.2, )",
|
||||
"AspNetCore.HealthChecks.Network": "[6.0.4, )",
|
||||
"AspNetCore.HealthChecks.Redis": "[6.0.4, )",
|
||||
"AspNetCore.HealthChecks.SendGrid": "[6.0.2, )",
|
||||
"AspNetCore.HealthChecks.SqlServer": "[6.0.2, )",
|
||||
"AspNetCore.HealthChecks.Uris": "[6.0.3, )",
|
||||
"Azure.Messaging.EventGrid": "[4.10.0, )",
|
||||
"Commercial.Core": "[2023.5.0, )",
|
||||
"Commercial.Infrastructure.EntityFramework": "[2023.5.0, )",
|
||||
"Core": "[2023.5.0, )",
|
||||
"SharedWeb": "[2023.5.0, )",
|
||||
"Swashbuckle.AspNetCore": "[6.5.0, )"
|
||||
"AspNetCore.HealthChecks.AzureServiceBus": "6.1.0",
|
||||
"AspNetCore.HealthChecks.AzureStorage": "6.1.2",
|
||||
"AspNetCore.HealthChecks.Network": "6.0.4",
|
||||
"AspNetCore.HealthChecks.Redis": "6.0.4",
|
||||
"AspNetCore.HealthChecks.SendGrid": "6.0.2",
|
||||
"AspNetCore.HealthChecks.SqlServer": "6.0.2",
|
||||
"AspNetCore.HealthChecks.Uris": "6.0.3",
|
||||
"Azure.Messaging.EventGrid": "4.10.0",
|
||||
"Commercial.Core": "2023.5.1",
|
||||
"Commercial.Infrastructure.EntityFramework": "2023.5.1",
|
||||
"Core": "2023.5.1",
|
||||
"SharedWeb": "2023.5.1",
|
||||
"Swashbuckle.AspNetCore": "6.5.0"
|
||||
}
|
||||
},
|
||||
"commercial.core": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "[2023.5.0, )"
|
||||
"Core": "2023.5.1"
|
||||
}
|
||||
},
|
||||
"commercial.infrastructure.entityframework": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
|
||||
"Core": "[2023.5.0, )",
|
||||
"Infrastructure.EntityFramework": "[2023.5.0, )"
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "12.0.1",
|
||||
"Core": "2023.5.1",
|
||||
"Infrastructure.EntityFramework": "2023.5.1"
|
||||
}
|
||||
},
|
||||
"common": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoFixture.AutoNSubstitute": "[4.17.0, )",
|
||||
"AutoFixture.Xunit2": "[4.17.0, )",
|
||||
"Core": "[2023.5.0, )",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "[1.2.0, )",
|
||||
"Microsoft.NET.Test.Sdk": "[17.1.0, )",
|
||||
"NSubstitute": "[4.3.0, )",
|
||||
"xunit": "[2.4.1, )"
|
||||
"AutoFixture.AutoNSubstitute": "4.17.0",
|
||||
"AutoFixture.Xunit2": "4.17.0",
|
||||
"Core": "2023.5.1",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "1.2.0",
|
||||
"Microsoft.NET.Test.Sdk": "17.1.0",
|
||||
"NSubstitute": "4.3.0",
|
||||
"xunit": "2.4.1"
|
||||
}
|
||||
},
|
||||
"core": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AWSSDK.SQS": "[3.7.2.47, )",
|
||||
"AWSSDK.SimpleEmail": "[3.7.0.150, )",
|
||||
"AspNetCoreRateLimit": "[4.0.2, )",
|
||||
"AspNetCoreRateLimit.Redis": "[1.0.1, )",
|
||||
"Azure.Extensions.AspNetCore.DataProtection.Blobs": "[1.3.2, )",
|
||||
"Azure.Storage.Blobs": "[12.14.1, )",
|
||||
"Azure.Storage.Queues": "[12.12.0, )",
|
||||
"BitPay.Light": "[1.0.1907, )",
|
||||
"Braintree": "[5.12.0, )",
|
||||
"DnsClient": "[1.7.0, )",
|
||||
"Fido2.AspNet": "[3.0.1, )",
|
||||
"Handlebars.Net": "[2.1.2, )",
|
||||
"IdentityServer4": "[4.1.2, )",
|
||||
"IdentityServer4.AccessTokenValidation": "[3.0.1, )",
|
||||
"LaunchDarkly.ServerSdk": "[7.0.0, )",
|
||||
"MailKit": "[3.2.0, )",
|
||||
"Microsoft.AspNetCore.Authentication.JwtBearer": "[6.0.4, )",
|
||||
"Microsoft.Azure.Cosmos.Table": "[1.0.8, )",
|
||||
"Microsoft.Azure.NotificationHubs": "[4.1.0, )",
|
||||
"Microsoft.Azure.ServiceBus": "[5.2.0, )",
|
||||
"Microsoft.Data.SqlClient": "[5.0.1, )",
|
||||
"Microsoft.Extensions.Caching.StackExchangeRedis": "[6.0.6, )",
|
||||
"Microsoft.Extensions.Configuration.EnvironmentVariables": "[6.0.1, )",
|
||||
"Microsoft.Extensions.Configuration.UserSecrets": "[6.0.1, )",
|
||||
"Microsoft.Extensions.Identity.Stores": "[6.0.4, )",
|
||||
"Newtonsoft.Json": "[13.0.1, )",
|
||||
"Otp.NET": "[1.2.2, )",
|
||||
"Quartz": "[3.4.0, )",
|
||||
"SendGrid": "[9.27.0, )",
|
||||
"Sentry.Serilog": "[3.16.0, )",
|
||||
"Serilog.AspNetCore": "[5.0.0, )",
|
||||
"Serilog.Extensions.Logging": "[3.1.0, )",
|
||||
"Serilog.Extensions.Logging.File": "[2.0.0, )",
|
||||
"Serilog.Sinks.AzureCosmosDB": "[2.0.0, )",
|
||||
"Serilog.Sinks.SyslogMessages": "[2.0.6, )",
|
||||
"Stripe.net": "[40.0.0, )",
|
||||
"YubicoDotNetClient": "[1.2.0, )"
|
||||
"AWSSDK.SQS": "3.7.2.47",
|
||||
"AWSSDK.SimpleEmail": "3.7.0.150",
|
||||
"AspNetCoreRateLimit": "4.0.2",
|
||||
"AspNetCoreRateLimit.Redis": "1.0.1",
|
||||
"Azure.Extensions.AspNetCore.DataProtection.Blobs": "1.3.2",
|
||||
"Azure.Storage.Blobs": "12.14.1",
|
||||
"Azure.Storage.Queues": "12.12.0",
|
||||
"BitPay.Light": "1.0.1907",
|
||||
"Braintree": "5.12.0",
|
||||
"DnsClient": "1.7.0",
|
||||
"Fido2.AspNet": "3.0.1",
|
||||
"Handlebars.Net": "2.1.2",
|
||||
"IdentityServer4": "4.1.2",
|
||||
"IdentityServer4.AccessTokenValidation": "3.0.1",
|
||||
"LaunchDarkly.ServerSdk": "7.0.0",
|
||||
"MailKit": "3.2.0",
|
||||
"Microsoft.AspNetCore.Authentication.JwtBearer": "6.0.4",
|
||||
"Microsoft.Azure.Cosmos.Table": "1.0.8",
|
||||
"Microsoft.Azure.NotificationHubs": "4.1.0",
|
||||
"Microsoft.Azure.ServiceBus": "5.2.0",
|
||||
"Microsoft.Data.SqlClient": "5.0.1",
|
||||
"Microsoft.Extensions.Caching.StackExchangeRedis": "6.0.6",
|
||||
"Microsoft.Extensions.Configuration.EnvironmentVariables": "6.0.1",
|
||||
"Microsoft.Extensions.Configuration.UserSecrets": "6.0.1",
|
||||
"Microsoft.Extensions.Identity.Stores": "6.0.4",
|
||||
"Newtonsoft.Json": "13.0.1",
|
||||
"Otp.NET": "1.2.2",
|
||||
"Quartz": "3.4.0",
|
||||
"SendGrid": "9.27.0",
|
||||
"Sentry.Serilog": "3.16.0",
|
||||
"Serilog.AspNetCore": "5.0.0",
|
||||
"Serilog.Extensions.Logging": "3.1.0",
|
||||
"Serilog.Extensions.Logging.File": "2.0.0",
|
||||
"Serilog.Sinks.AzureCosmosDB": "2.0.0",
|
||||
"Serilog.Sinks.SyslogMessages": "2.0.6",
|
||||
"Stripe.net": "40.0.0",
|
||||
"YubicoDotNetClient": "1.2.0"
|
||||
}
|
||||
},
|
||||
"core.test": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoFixture.AutoNSubstitute": "[4.17.0, )",
|
||||
"AutoFixture.Xunit2": "[4.17.0, )",
|
||||
"Common": "[2023.5.0, )",
|
||||
"Core": "[2023.5.0, )",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "[1.2.0, )",
|
||||
"Microsoft.NET.Test.Sdk": "[17.1.0, )",
|
||||
"Moq": "[4.17.2, )",
|
||||
"NSubstitute": "[4.3.0, )",
|
||||
"xunit": "[2.4.1, )"
|
||||
"AutoFixture.AutoNSubstitute": "4.17.0",
|
||||
"AutoFixture.Xunit2": "4.17.0",
|
||||
"Common": "2023.5.1",
|
||||
"Core": "2023.5.1",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "1.2.0",
|
||||
"Microsoft.NET.Test.Sdk": "17.1.0",
|
||||
"Moq": "4.17.2",
|
||||
"NSubstitute": "4.3.0",
|
||||
"xunit": "2.4.1"
|
||||
}
|
||||
},
|
||||
"infrastructure.dapper": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "[2023.5.0, )",
|
||||
"Dapper": "[2.0.123, )"
|
||||
"Core": "2023.5.1",
|
||||
"Dapper": "2.0.123"
|
||||
}
|
||||
},
|
||||
"infrastructure.entityframework": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
|
||||
"Core": "[2023.5.0, )",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "[6.0.12, )",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "[6.0.12, )",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "[6.0.12, )",
|
||||
"Npgsql.EntityFrameworkCore.PostgreSQL": "[6.0.8, )",
|
||||
"Pomelo.EntityFrameworkCore.MySql": "[6.0.2, )",
|
||||
"linq2db.EntityFrameworkCore": "[6.11.0, )"
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "12.0.1",
|
||||
"Core": "2023.5.1",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "6.0.12",
|
||||
"Npgsql.EntityFrameworkCore.PostgreSQL": "6.0.8",
|
||||
"Pomelo.EntityFrameworkCore.MySql": "6.0.2",
|
||||
"linq2db.EntityFrameworkCore": "6.11.0"
|
||||
}
|
||||
},
|
||||
"sharedweb": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "[2023.5.0, )",
|
||||
"Infrastructure.Dapper": "[2023.5.0, )",
|
||||
"Infrastructure.EntityFramework": "[2023.5.0, )"
|
||||
"Core": "2023.5.1",
|
||||
"Infrastructure.Dapper": "2023.5.1",
|
||||
"Infrastructure.EntityFramework": "2023.5.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2988,8 +2988,8 @@
|
||||
"billing": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"SharedWeb": "2023.4.3"
|
||||
"Core": "2023.5.1",
|
||||
"SharedWeb": "2023.5.1"
|
||||
}
|
||||
},
|
||||
"common": {
|
||||
@@ -2997,7 +2997,7 @@
|
||||
"dependencies": {
|
||||
"AutoFixture.AutoNSubstitute": "4.17.0",
|
||||
"AutoFixture.Xunit2": "4.17.0",
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "1.2.0",
|
||||
"Microsoft.NET.Test.Sdk": "17.1.0",
|
||||
"NSubstitute": "4.3.0",
|
||||
@@ -3049,7 +3049,7 @@
|
||||
"infrastructure.dapper": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Dapper": "2.0.123"
|
||||
}
|
||||
},
|
||||
@@ -3057,7 +3057,7 @@
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "12.0.1",
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "6.0.12",
|
||||
@@ -3069,9 +3069,9 @@
|
||||
"sharedweb": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"Infrastructure.Dapper": "2023.4.3",
|
||||
"Infrastructure.EntityFramework": "2023.4.3"
|
||||
"Core": "2023.5.1",
|
||||
"Infrastructure.Dapper": "2023.5.1",
|
||||
"Infrastructure.EntityFramework": "2023.5.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.SecretsManager.Commands.EnableAccessSecretsManager;
|
||||
using Bit.Test.Common.AutoFixture;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using Bit.Test.Common.Helpers;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.SecretsManager.Commands.EnableAccessSecretsManager;
|
||||
|
||||
[SutProviderCustomize]
|
||||
public class EnableAccessSecretsManagerCommandTests
|
||||
{
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task EnableUsers_UsersAlreadyEnabled_DoesNotCallRepository(
|
||||
SutProvider<EnableAccessSecretsManagerCommand> sutProvider, ICollection<OrganizationUser> data)
|
||||
{
|
||||
foreach (var item in data)
|
||||
{
|
||||
item.AccessSecretsManager = true;
|
||||
}
|
||||
|
||||
var result = await sutProvider.Sut.EnableUsersAsync(data);
|
||||
|
||||
await sutProvider.GetDependency<IOrganizationUserRepository>().DidNotReceiveWithAnyArgs()
|
||||
.ReplaceManyAsync(default);
|
||||
|
||||
Assert.Equal(data.Count, result.Count);
|
||||
Assert.Equal(data.Count,
|
||||
result.Where(x => x.error == "User already has access to Secrets Manager").ToList().Count);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task EnableUsers_OneUserNotEnabled_CallsRepositoryForOne(
|
||||
SutProvider<EnableAccessSecretsManagerCommand> sutProvider, ICollection<OrganizationUser> data)
|
||||
{
|
||||
var firstUser = new List<OrganizationUser>();
|
||||
foreach (var item in data)
|
||||
{
|
||||
if (item == data.First())
|
||||
{
|
||||
item.AccessSecretsManager = false;
|
||||
firstUser.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.AccessSecretsManager = true;
|
||||
}
|
||||
}
|
||||
|
||||
var result = await sutProvider.Sut.EnableUsersAsync(data);
|
||||
|
||||
await sutProvider.GetDependency<IOrganizationUserRepository>().Received(1)
|
||||
.ReplaceManyAsync(Arg.Is(AssertHelper.AssertPropertyEqual(firstUser)));
|
||||
|
||||
Assert.Equal(data.Count, result.Count);
|
||||
Assert.Equal(data.Count - 1,
|
||||
result.Where(x => x.error == "User already has access to Secrets Manager").ToList().Count);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task EnableUsers_Success(
|
||||
SutProvider<EnableAccessSecretsManagerCommand> sutProvider, ICollection<OrganizationUser> data)
|
||||
{
|
||||
foreach (var item in data)
|
||||
{
|
||||
item.AccessSecretsManager = false;
|
||||
}
|
||||
|
||||
var result = await sutProvider.Sut.EnableUsersAsync(data);
|
||||
|
||||
await sutProvider.GetDependency<IOrganizationUserRepository>().Received(1)
|
||||
.ReplaceManyAsync(Arg.Is(AssertHelper.AssertPropertyEqual(data)));
|
||||
|
||||
Assert.Equal(data.Count, result.Count);
|
||||
}
|
||||
}
|
||||
@@ -2825,7 +2825,7 @@
|
||||
"dependencies": {
|
||||
"AutoFixture.AutoNSubstitute": "4.17.0",
|
||||
"AutoFixture.Xunit2": "4.17.0",
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "1.2.0",
|
||||
"Microsoft.NET.Test.Sdk": "17.1.0",
|
||||
"NSubstitute": "4.3.0",
|
||||
|
||||
@@ -2972,14 +2972,14 @@
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AngleSharp": "0.16.1",
|
||||
"Core": "2023.4.3",
|
||||
"SharedWeb": "2023.4.3"
|
||||
"Core": "2023.5.1",
|
||||
"SharedWeb": "2023.5.1"
|
||||
}
|
||||
},
|
||||
"infrastructure.dapper": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Dapper": "2.0.123"
|
||||
}
|
||||
},
|
||||
@@ -2987,7 +2987,7 @@
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "12.0.1",
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "6.0.12",
|
||||
@@ -2999,9 +2999,9 @@
|
||||
"sharedweb": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"Infrastructure.Dapper": "2023.4.3",
|
||||
"Infrastructure.EntityFramework": "2023.4.3"
|
||||
"Core": "2023.5.1",
|
||||
"Infrastructure.Dapper": "2023.5.1",
|
||||
"Infrastructure.EntityFramework": "2023.5.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3144,7 +3144,7 @@
|
||||
"dependencies": {
|
||||
"AutoFixture.AutoNSubstitute": "4.17.0",
|
||||
"AutoFixture.Xunit2": "4.17.0",
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "1.2.0",
|
||||
"Microsoft.NET.Test.Sdk": "17.1.0",
|
||||
"NSubstitute": "4.3.0",
|
||||
@@ -3196,15 +3196,15 @@
|
||||
"identity": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"SharedWeb": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"SharedWeb": "2023.5.1",
|
||||
"Swashbuckle.AspNetCore.SwaggerGen": "6.5.0"
|
||||
}
|
||||
},
|
||||
"infrastructure.dapper": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Dapper": "2.0.123"
|
||||
}
|
||||
},
|
||||
@@ -3212,7 +3212,7 @@
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "12.0.1",
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "6.0.12",
|
||||
@@ -3224,8 +3224,8 @@
|
||||
"integrationtestcommon": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Common": "2023.4.3",
|
||||
"Identity": "2023.4.3",
|
||||
"Common": "2023.5.1",
|
||||
"Identity": "2023.5.1",
|
||||
"Microsoft.AspNetCore.Mvc.Testing": "6.0.5",
|
||||
"Microsoft.EntityFrameworkCore.InMemory": "6.0.5",
|
||||
"Microsoft.Extensions.Configuration": "6.0.1"
|
||||
@@ -3234,9 +3234,9 @@
|
||||
"sharedweb": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"Infrastructure.Dapper": "2023.4.3",
|
||||
"Infrastructure.EntityFramework": "2023.4.3"
|
||||
"Core": "2023.5.1",
|
||||
"Infrastructure.Dapper": "2023.5.1",
|
||||
"Infrastructure.EntityFramework": "2023.5.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3011,7 +3011,7 @@
|
||||
"dependencies": {
|
||||
"AutoFixture.AutoNSubstitute": "4.17.0",
|
||||
"AutoFixture.Xunit2": "4.17.0",
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "1.2.0",
|
||||
"Microsoft.NET.Test.Sdk": "17.1.0",
|
||||
"NSubstitute": "4.3.0",
|
||||
@@ -3063,15 +3063,15 @@
|
||||
"identity": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"SharedWeb": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"SharedWeb": "2023.5.1",
|
||||
"Swashbuckle.AspNetCore.SwaggerGen": "6.5.0"
|
||||
}
|
||||
},
|
||||
"infrastructure.dapper": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Dapper": "2.0.123"
|
||||
}
|
||||
},
|
||||
@@ -3079,7 +3079,7 @@
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "12.0.1",
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "6.0.12",
|
||||
@@ -3091,9 +3091,9 @@
|
||||
"sharedweb": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"Infrastructure.Dapper": "2023.4.3",
|
||||
"Infrastructure.EntityFramework": "2023.4.3"
|
||||
"Core": "2023.5.1",
|
||||
"Infrastructure.Dapper": "2023.5.1",
|
||||
"Infrastructure.EntityFramework": "2023.5.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3001,7 +3001,7 @@
|
||||
"dependencies": {
|
||||
"AutoFixture.AutoNSubstitute": "4.17.0",
|
||||
"AutoFixture.Xunit2": "4.17.0",
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "1.2.0",
|
||||
"Microsoft.NET.Test.Sdk": "17.1.0",
|
||||
"NSubstitute": "4.3.0",
|
||||
@@ -3055,8 +3055,8 @@
|
||||
"dependencies": {
|
||||
"AutoFixture.AutoNSubstitute": "4.17.0",
|
||||
"AutoFixture.Xunit2": "4.17.0",
|
||||
"Common": "2023.4.3",
|
||||
"Core": "2023.4.3",
|
||||
"Common": "2023.5.1",
|
||||
"Core": "2023.5.1",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "1.2.0",
|
||||
"Microsoft.NET.Test.Sdk": "17.1.0",
|
||||
"Moq": "4.17.2",
|
||||
@@ -3067,7 +3067,7 @@
|
||||
"infrastructure.dapper": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Dapper": "2.0.123"
|
||||
}
|
||||
},
|
||||
@@ -3075,7 +3075,7 @@
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "12.0.1",
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "6.0.12",
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
using Bit.Core.Auth.Entities;
|
||||
using Bit.Core.Auth.Enums;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Repositories;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Infrastructure.IntegrationTest.Auth.Repositories;
|
||||
|
||||
public class AuthRequestRepositoryTests
|
||||
{
|
||||
private readonly static TimeSpan _userRequestExpiration = TimeSpan.FromMinutes(15);
|
||||
private readonly static TimeSpan _adminRequestExpiration = TimeSpan.FromDays(6);
|
||||
private readonly static TimeSpan _afterAdminApprovalExpiration = TimeSpan.FromHours(12);
|
||||
|
||||
[DatabaseTheory, DatabaseData]
|
||||
public async Task DeleteExpiredAsync_Works(
|
||||
IAuthRequestRepository authRequestRepository,
|
||||
IUserRepository userRepository,
|
||||
ITestDatabaseHelper helper)
|
||||
{
|
||||
var user = await userRepository.CreateAsync(new User
|
||||
{
|
||||
Name = "Test User",
|
||||
Email = $"test+{Guid.NewGuid()}@email.com",
|
||||
ApiKey = "TEST",
|
||||
SecurityStamp = "stamp",
|
||||
});
|
||||
|
||||
// A user auth request type that has passed it's expiration time, should be deleted.
|
||||
var userExpiredAuthRequest = await authRequestRepository.CreateAsync(
|
||||
CreateAuthRequest(user.Id, AuthRequestType.AuthenticateAndUnlock, CreateExpiredDate(_userRequestExpiration)));
|
||||
|
||||
// An AdminApproval request that hasn't had any action taken on it and has passed it's expiration time, should be deleted.
|
||||
var adminApprovalExpiredAuthRequest = await authRequestRepository.CreateAsync(
|
||||
CreateAuthRequest(user.Id, AuthRequestType.AdminApproval, CreateExpiredDate(_adminRequestExpiration)));
|
||||
|
||||
// An AdminApproval request that was approved before it expired but the user has been approved for too long, should be deleted.
|
||||
var adminApprovedExpiredAuthRequest = await authRequestRepository.CreateAsync(
|
||||
CreateAuthRequest(user.Id, AuthRequestType.AdminApproval, DateTime.UtcNow.AddDays(-6), true, CreateExpiredDate(_afterAdminApprovalExpiration)));
|
||||
|
||||
// An AdminApproval request that was rejected within it's allowed lifetime but has no gone past it's expiration time, should be deleted.
|
||||
var adminRejectedExpiredAuthRequest = await authRequestRepository.CreateAsync(
|
||||
CreateAuthRequest(user.Id, AuthRequestType.AdminApproval, CreateExpiredDate(_adminRequestExpiration), false, DateTime.UtcNow.AddHours(-1)));
|
||||
|
||||
// A User AuthRequest that was created just a minute ago.
|
||||
var notExpiredUserAuthRequest = await authRequestRepository.CreateAsync(
|
||||
CreateAuthRequest(user.Id, AuthRequestType.Unlock, DateTime.UtcNow.AddMinutes(-1)));
|
||||
|
||||
// An AdminApproval AuthRequest that was create 6 days 23 hours 59 minutes 59 seconds ago which is right on the edge of still being valid
|
||||
var notExpiredAdminApprovalRequest = await authRequestRepository.CreateAsync(
|
||||
CreateAuthRequest(user.Id, AuthRequestType.AdminApproval, DateTime.UtcNow.Add(new TimeSpan(days: 6, hours: 23, minutes: 59, seconds: 59))));
|
||||
|
||||
// An AdminApproval AuthRequest that was created a week ago but just approved 11 hours ago.
|
||||
var notExpiredApprovedAdminApprovalRequest = await authRequestRepository.CreateAsync(
|
||||
CreateAuthRequest(user.Id, AuthRequestType.AdminApproval, DateTime.UtcNow.AddDays(7), true, DateTime.UtcNow.AddHours(11)));
|
||||
|
||||
helper.ClearTracker();
|
||||
|
||||
var numberOfDeleted = await authRequestRepository.DeleteExpiredAsync(_userRequestExpiration, _adminRequestExpiration, _afterAdminApprovalExpiration);
|
||||
|
||||
// Ensure all the AuthRequests that should have been deleted, have been deleted.
|
||||
Assert.Null(await authRequestRepository.GetByIdAsync(userExpiredAuthRequest.Id));
|
||||
Assert.Null(await authRequestRepository.GetByIdAsync(adminApprovalExpiredAuthRequest.Id));
|
||||
Assert.Null(await authRequestRepository.GetByIdAsync(adminApprovedExpiredAuthRequest.Id));
|
||||
Assert.Null(await authRequestRepository.GetByIdAsync(adminRejectedExpiredAuthRequest.Id));
|
||||
|
||||
// Ensure that all the AuthRequests that should have been left alone, were.
|
||||
Assert.NotNull(await authRequestRepository.GetByIdAsync(notExpiredUserAuthRequest.Id));
|
||||
Assert.NotNull(await authRequestRepository.GetByIdAsync(notExpiredAdminApprovalRequest.Id));
|
||||
Assert.NotNull(await authRequestRepository.GetByIdAsync(notExpiredApprovedAdminApprovalRequest.Id));
|
||||
|
||||
// Ensure the repository responds with the amount of items it deleted and it deleted the right amount.
|
||||
// NOTE: On local development this might fail on it's first run because the developer could have expired AuthRequests
|
||||
// on their machine but aren't running the job that would delete them. The second run of this test should succeed.
|
||||
Assert.Equal(4, numberOfDeleted);
|
||||
}
|
||||
|
||||
private static AuthRequest CreateAuthRequest(Guid userId, AuthRequestType authRequestType, DateTime creationDate, bool? approved = null, DateTime? responseDate = null)
|
||||
{
|
||||
return new AuthRequest
|
||||
{
|
||||
UserId = userId,
|
||||
Type = authRequestType,
|
||||
Approved = approved,
|
||||
RequestDeviceIdentifier = "something", // TODO: EF Doesn't enforce this as not null
|
||||
RequestIpAddress = "1.1.1.1", // TODO: EF Doesn't enforce this as not null
|
||||
AccessCode = "test_access_code", // TODO: EF Doesn't enforce this as not null
|
||||
PublicKey = "test_public_key", // TODO: EF Doesn't enforce this as not null
|
||||
CreationDate = creationDate,
|
||||
ResponseDate = responseDate,
|
||||
};
|
||||
}
|
||||
|
||||
private static DateTime CreateExpiredDate(TimeSpan expirationPeriod)
|
||||
{
|
||||
var exp = expirationPeriod + TimeSpan.FromMinutes(1);
|
||||
return DateTime.UtcNow.Add(exp.Negate());
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Bit.Core.Entities;
|
||||
using System.Text.Json;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Repositories;
|
||||
@@ -121,4 +122,84 @@ public class CipherRepositoryTests
|
||||
var collectionCiphers = await collectionCipherRepository.GetManyByOrganizationIdAsync(organization.Id);
|
||||
Assert.NotEmpty(collectionCiphers);
|
||||
}
|
||||
|
||||
[DatabaseTheory, DatabaseData]
|
||||
public async Task ReplaceAsync_SuccessfullyMovesCipherToOrganization(IUserRepository userRepository,
|
||||
ICipherRepository cipherRepository,
|
||||
IOrganizationRepository organizationRepository,
|
||||
IOrganizationUserRepository organizationUserRepository,
|
||||
IFolderRepository folderRepository,
|
||||
ITestDatabaseHelper helper)
|
||||
{
|
||||
// This tests what happens when a cipher is moved into an organizations
|
||||
var user = await userRepository.CreateAsync(new User
|
||||
{
|
||||
Name = "Test User",
|
||||
Email = $"test+{Guid.NewGuid()}@email.com",
|
||||
ApiKey = "TEST",
|
||||
SecurityStamp = "stamp",
|
||||
});
|
||||
|
||||
|
||||
user = await userRepository.GetByIdAsync(user.Id);
|
||||
|
||||
// Create cipher in personal vault
|
||||
var createdCipher = await cipherRepository.CreateAsync(new Cipher
|
||||
{
|
||||
UserId = user.Id,
|
||||
Data = "", // TODO: EF does not enforce this as NOT NULL
|
||||
});
|
||||
|
||||
var organization = await organizationRepository.CreateAsync(new Organization
|
||||
{
|
||||
Name = "Test Organization",
|
||||
BillingEmail = user.Email,
|
||||
Plan = "Test" // TODO: EF does not enforce this as NOT NULL
|
||||
});
|
||||
|
||||
_ = await organizationUserRepository.CreateAsync(new OrganizationUser
|
||||
{
|
||||
UserId = user.Id,
|
||||
OrganizationId = organization.Id,
|
||||
Status = OrganizationUserStatusType.Confirmed,
|
||||
Type = OrganizationUserType.Owner,
|
||||
});
|
||||
|
||||
var folder = await folderRepository.CreateAsync(new Folder
|
||||
{
|
||||
Name = "FolderName",
|
||||
UserId = user.Id,
|
||||
});
|
||||
|
||||
helper.ClearTracker();
|
||||
|
||||
// Move cipher to organization vault
|
||||
await cipherRepository.ReplaceAsync(new CipherDetails
|
||||
{
|
||||
Id = createdCipher.Id,
|
||||
UserId = user.Id,
|
||||
OrganizationId = organization.Id,
|
||||
FolderId = folder.Id,
|
||||
Data = "", // TODO: EF does not enforce this as NOT NULL
|
||||
});
|
||||
|
||||
var updatedCipher = await cipherRepository.GetByIdAsync(createdCipher.Id);
|
||||
|
||||
Assert.Null(updatedCipher.UserId);
|
||||
Assert.Equal(organization.Id, updatedCipher.OrganizationId);
|
||||
Assert.NotNull(updatedCipher.Folders);
|
||||
|
||||
using var foldersJsonDocument = JsonDocument.Parse(updatedCipher.Folders);
|
||||
var foldersJsonElement = foldersJsonDocument.RootElement;
|
||||
Assert.Equal(JsonValueKind.Object, foldersJsonElement.ValueKind);
|
||||
|
||||
// TODO: Should we force similar casing for guids across DB's
|
||||
// I'd rather we only interact with them as the actual Guid type
|
||||
var userProperty = foldersJsonElement
|
||||
.EnumerateObject()
|
||||
.FirstOrDefault(jp => string.Equals(jp.Name, user.Id.ToString(), StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
Assert.NotEqual(default, userProperty);
|
||||
Assert.Equal(folder.Id, userProperty.Value.GetGuid());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2901,7 +2901,7 @@
|
||||
"infrastructure.dapper": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Dapper": "2.0.123"
|
||||
}
|
||||
},
|
||||
@@ -2909,7 +2909,7 @@
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "12.0.1",
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "6.0.12",
|
||||
|
||||
@@ -3130,7 +3130,7 @@
|
||||
"dependencies": {
|
||||
"AutoFixture.AutoNSubstitute": "4.17.0",
|
||||
"AutoFixture.Xunit2": "4.17.0",
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "1.2.0",
|
||||
"Microsoft.NET.Test.Sdk": "17.1.0",
|
||||
"NSubstitute": "4.3.0",
|
||||
@@ -3182,15 +3182,15 @@
|
||||
"identity": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"SharedWeb": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"SharedWeb": "2023.5.1",
|
||||
"Swashbuckle.AspNetCore.SwaggerGen": "6.5.0"
|
||||
}
|
||||
},
|
||||
"infrastructure.dapper": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Dapper": "2.0.123"
|
||||
}
|
||||
},
|
||||
@@ -3198,7 +3198,7 @@
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "12.0.1",
|
||||
"Core": "2023.4.3",
|
||||
"Core": "2023.5.1",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "6.0.12",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "6.0.12",
|
||||
@@ -3210,9 +3210,9 @@
|
||||
"sharedweb": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.4.3",
|
||||
"Infrastructure.Dapper": "2023.4.3",
|
||||
"Infrastructure.EntityFramework": "2023.4.3"
|
||||
"Core": "2023.5.1",
|
||||
"Infrastructure.Dapper": "2023.5.1",
|
||||
"Infrastructure.EntityFramework": "2023.5.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user