1
0
mirror of https://github.com/bitwarden/server synced 2026-01-15 06:53:26 +00:00
Files
server/util/Seeder/MangleId.cs
2026-01-14 09:02:49 -05:00

22 lines
674 B
C#

using System.Globalization;
namespace Bit.Seeder;
/// <summary>
/// Helper for generating unique identifier suffixes to prevent collisions in test data.
/// "Mangling" adds a random suffix to test data identifiers (usernames, emails, org names, etc.)
/// to ensure uniqueness across multiple test runs and parallel test executions.
/// </summary>
public class MangleId
{
public readonly string Value;
public MangleId()
{
// Generate a short random string (6 char) to use as the mangle ID
Value = Random.Shared.NextInt64().ToString("x", CultureInfo.InvariantCulture).Substring(0, 8);
}
public override string ToString() => Value;
}