// Copyright 2020-2025 The NATS Authors
// Licensed under the Apache License, Version 2.0
namespace ZB.MOM.NatsNet.Server.IntegrationTests.Helpers;
///
/// Provides configuration templates and file helpers for integration tests.
/// Mirrors Go's jsClusterTempl, jsClusterAccountsTempl, etc.
///
public static class ConfigHelper
{
///
/// Standard JetStream cluster configuration template.
/// Use %s placeholders for server_name, store_dir, cluster_name, port, and routes.
///
public const string JsClusterTemplate = @"
listen: 127.0.0.1:-1
server_name: %s
jetstream: {max_mem_store: 256MB, max_file_store: 2GB, store_dir: '%s'}
cluster {
name: %s
listen: 127.0.0.1:%d
routes = [%s]
}
";
///
/// JetStream cluster template with accounts.
///
public const string JsClusterAccountsTemplate = @"
listen: 127.0.0.1:-1
server_name: %s
jetstream: {max_mem_store: 256MB, max_file_store: 2GB, store_dir: '%s'}
accounts {
$SYS {
users: [{user: admin, password: s3cr3t!}]
}
ONE {
jetstream: enabled
users: [{user: one, password: p}]
}
TWO {
jetstream: enabled
users: [{user: two, password: p}]
}
}
cluster {
name: %s
listen: 127.0.0.1:%d
routes = [%s]
}
";
///
/// Creates a temporary config file with the given content and returns its path.
///
public static string CreateConfigFile(string content)
{
var path = Path.Combine(Path.GetTempPath(), $"nats-test-{Guid.NewGuid():N}.conf");
File.WriteAllText(path, content);
return path;
}
}