1
0
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:
Mick Letofsky
2026-01-30 13:53:24 +01:00
committed by GitHub
parent 93a28eed40
commit bfc645e1c1
40 changed files with 3245 additions and 48 deletions

View File

@@ -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());
}
}