mirror of
https://github.com/bitwarden/server
synced 2026-02-20 19:33:32 +00:00
Add cipher seeding with Rust SDK encryption to enable cryptographically correct test data generation (#6896)
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using AutoMapper;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Bit.RustSDK;
|
||||
using Bit.Seeder.Recipes;
|
||||
using CommandDotNet;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Bit.DbSeederUtility;
|
||||
@@ -36,4 +40,25 @@ public class Program
|
||||
var recipe = new OrganizationWithUsersRecipe(db);
|
||||
recipe.Seed(name: name, domain: domain, users: users);
|
||||
}
|
||||
|
||||
[Command("vault-organization", Description = "Seed an organization with users and encrypted vault data (ciphers, collections, groups)")]
|
||||
public void VaultOrganization(VaultOrganizationArgs args)
|
||||
{
|
||||
args.Validate();
|
||||
|
||||
var services = new ServiceCollection();
|
||||
ServiceCollectionExtension.ConfigureServices(services);
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
using var scope = serviceProvider.CreateScope();
|
||||
var scopedServices = scope.ServiceProvider;
|
||||
|
||||
var recipe = new OrganizationWithVaultRecipe(
|
||||
scopedServices.GetRequiredService<DatabaseContext>(),
|
||||
scopedServices.GetRequiredService<IMapper>(),
|
||||
scopedServices.GetRequiredService<RustSdkService>(),
|
||||
scopedServices.GetRequiredService<IPasswordHasher<User>>());
|
||||
|
||||
recipe.Seed(args.ToOptions());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user