1
0
mirror of https://github.com/bitwarden/server synced 2026-02-18 02:19:06 +00:00

Removing useless Claude generated tests. (#7016)

This commit is contained in:
Mick Letofsky
2026-02-17 17:12:09 +01:00
committed by GitHub
parent 3ae04026b3
commit 67f704d5d1
3 changed files with 0 additions and 214 deletions

View File

@@ -1,51 +0,0 @@
using Bit.Seeder.Recipes;
using Xunit;
namespace Bit.SeederApi.IntegrationTest;
public class OrganizationFromPresetRecipeTests
{
// NOTE: Issue #1 (SeedResult counts) is verified by the implementation fix.
// The Recipe now captures counts BEFORE BulkCommitter.Commit() clears the lists.
// Full database integration tests will verify the counts match actual seeded entities.
// This fix ensures context.Users.Count etc. are captured before being cleared to zero.
[Fact]
public void ListAvailable_HandlesPresetWithPresetInMiddle()
{
// Issue #3: String.Replace bug - should only remove prefix, not all occurrences
var available = OrganizationFromPresetRecipe.ListAvailable();
// Verify presets don't have "presets." prefix removed from middle
// If we had a preset named "my-presets-collection", it should become "my-presets-collection"
// not "my--collection" (which would happen with Replace)
Assert.NotNull(available);
Assert.NotNull(available.Presets);
// All preset names should not start with "presets."
Assert.All(available.Presets, name => Assert.DoesNotContain("presets.", name.Substring(0, Math.Min(8, name.Length))));
// Verify known presets are listed correctly
Assert.Contains("dunder-mifflin-full", available.Presets);
Assert.Contains("large-enterprise", available.Presets);
}
[Fact]
public void ListAvailable_GroupsFixturesByCategory()
{
var available = OrganizationFromPresetRecipe.ListAvailable();
// Verify fixtures are grouped by category
Assert.NotNull(available.Fixtures);
Assert.True(available.Fixtures.ContainsKey("ciphers"));
Assert.True(available.Fixtures.ContainsKey("organizations"));
Assert.True(available.Fixtures.ContainsKey("rosters"));
// Verify ciphers category has expected fixtures
Assert.Contains("ciphers.autofill-testing", available.Fixtures["ciphers"]);
Assert.Contains("ciphers.public-site-logins", available.Fixtures["ciphers"]);
}
}

View File

@@ -1,35 +0,0 @@
using Bit.Seeder;
using Bit.Seeder.Pipeline;
using Xunit;
namespace Bit.SeederApi.IntegrationTest;
public class PresetLoaderTests
{
[Fact]
public void Load_FixtureOrgWithGeneratedCiphers_InitializesGenerator()
{
// Issue #2: Fixture-based org + generated ciphers should resolve domain from fixture
// This test verifies that when a preset uses a fixture org (no explicit domain)
// but wants to generate ciphers (needs domain for generator), the domain is
// automatically resolved by reading the org fixture.
var services = new ServiceCollection();
var builder = services.AddRecipe("fixture-org-test");
builder
.UseOrganization("dunder-mifflin") // Fixture org (domain in fixture)
.AddOwner()
.WithGenerator("dundermifflin.com") // Generator needs domain
.AddCiphers(50);
// This should NOT throw "Generated ciphers require a generator"
builder.Validate();
using var provider = services.BuildServiceProvider();
var steps = provider.GetKeyedServices<IStep>("fixture-org-test").ToList();
Assert.NotNull(steps);
Assert.NotEmpty(steps);
}
}

View File

@@ -1,128 +0,0 @@
using Bit.Seeder.Models;
using Bit.Seeder.Services;
using Xunit;
namespace Bit.SeederApi.IntegrationTest;
public class SeedReaderTests
{
private readonly SeedReader _reader = new();
[Fact]
public void ListAvailable_ReturnsAllSeedFiles()
{
var available = _reader.ListAvailable();
Assert.Contains("ciphers.autofill-testing", available);
Assert.Contains("ciphers.public-site-logins", available);
Assert.Contains("organizations.dunder-mifflin", available);
Assert.Contains("rosters.dunder-mifflin", available);
Assert.Contains("presets.dunder-mifflin-full", available);
Assert.Contains("presets.large-enterprise", available);
Assert.Equal(6, available.Count);
}
[Fact]
public void Read_AutofillTesting_DeserializesAllItems()
{
var seedFile = _reader.Read<SeedFile>("ciphers.autofill-testing");
Assert.Equal(18, seedFile.Items.Count);
var types = seedFile.Items.Select(i => i.Type).Distinct().OrderBy(t => t).ToList();
Assert.Contains("login", types);
Assert.Contains("card", types);
Assert.Contains("identity", types);
var logins = seedFile.Items.Where(i => i.Type == "login").ToList();
Assert.All(logins, l => Assert.NotEmpty(l.Login!.Uris!));
}
[Fact]
public void Read_PublicSiteLogins_DeserializesAllItems()
{
var seedFile = _reader.Read<SeedFile>("ciphers.public-site-logins");
Assert.True(seedFile.Items.Count >= 90,
$"Expected at least 90 public site logins, got {seedFile.Items.Count}");
}
[Fact]
public void Read_NonExistentSeed_ThrowsWithAvailableList()
{
var ex = Assert.Throws<InvalidOperationException>(
() => _reader.Read<SeedFile>("does-not-exist"));
Assert.Contains("does-not-exist", ex.Message);
Assert.Contains("ciphers.autofill-testing", ex.Message);
}
[Fact]
public void Read_CipherSeeds_ItemNamesAreUnique()
{
var cipherSeeds = _reader.ListAvailable()
.Where(n => n.StartsWith("ciphers."));
foreach (var seedName in cipherSeeds)
{
var seedFile = _reader.Read<SeedFile>(seedName);
var duplicates = seedFile.Items
.GroupBy(i => i.Name)
.Where(g => g.Count() > 1)
.Select(g => g.Key)
.ToList();
Assert.True(duplicates.Count == 0,
$"Seed '{seedName}' has duplicate item names: {string.Join(", ", duplicates)}");
}
}
[Fact]
public void Read_DunderMifflin_DeserializesOrganization()
{
var org = _reader.Read<SeedOrganization>("organizations.dunder-mifflin");
Assert.Equal("Dunder Mifflin", org.Name);
Assert.Equal("dundermifflin.com", org.Domain);
Assert.Equal(70, org.Seats);
}
[Fact]
public void Read_DunderMifflinRoster_DeserializesRoster()
{
var roster = _reader.Read<SeedRoster>("rosters.dunder-mifflin");
Assert.Equal(58, roster.Users.Count);
Assert.NotNull(roster.Groups);
Assert.Equal(14, roster.Groups.Count);
Assert.NotNull(roster.Collections);
Assert.Equal(15, roster.Collections.Count);
// Verify no duplicate email prefixes
var prefixes = roster.Users
.Select(u => $"{u.FirstName}.{u.LastName}".ToLowerInvariant())
.ToList();
Assert.Equal(prefixes.Count, prefixes.Distinct().Count());
// Verify all group members reference valid users
var prefixSet = new HashSet<string>(prefixes, StringComparer.OrdinalIgnoreCase);
foreach (var group in roster.Groups)
{
Assert.All(group.Members, m => Assert.Contains(m, prefixSet));
}
// Verify all collection user/group refs are valid
var groupNames = new HashSet<string>(roster.Groups.Select(g => g.Name), StringComparer.OrdinalIgnoreCase);
foreach (var collection in roster.Collections)
{
if (collection.Groups is not null)
{
Assert.All(collection.Groups, cg => Assert.Contains(cg.Group, groupNames));
}
if (collection.Users is not null)
{
Assert.All(collection.Users, cu => Assert.Contains(cu.User, prefixSet));
}
}
}
}