using Newtonsoft.Json.Linq;
using XFEWarframe.Core;
using Xunit;
namespace XFEWarframe.Tests;
public sealed partial class EngineTests
{
[Fact] public async Task ServerNameIsAdminOnlyPersistsAndAppearsInPublicStatusAndGameNews()
{
const string name = "星际测试服";
Assert.Equal(401, (await Call("/control/v1/config", new { serverName = name })).Status);
Assert.Equal(200, (await Call("/control/v1/config", new { serverName = name }, admin: true)).Status);
Assert.Equal(400, (await Call("/control/v1/config", new { serverName = "bad\nname" }, admin: true)).Status);
Assert.Equal(400, (await Call("/control/v1/config", new { serverName = "<b>" }, admin: true)).Status);
await store.DisposeAsync(); store = new(root); engine = new(store, options);
var health = JObject.Parse((await Call("/health")).Body);
Assert.Equal(3, health.Value<int>("apiVersion")); Assert.Equal(name, health.Value<string>("serverName"));
Assert.Equal(options.GamePublicUrl, health.Value<string>("gameUrl"));
Assert.DoesNotContain(options.AdminToken, health.ToString());
Assert.Equal(name, JObject.Parse((await Portal("info")).Body).Value<string>("serverName"));
Assert.Contains(JObject.Parse((await Call("/dynamic/worldState.php")).Body)["Events"]!, x => x.Value<string>("Msg") == "XFEWarframe · " + name);
}
}
using Newtonsoft.Json.Linq;
using XFEWarframe.Core;
using Xunit;
namespace XFEWarframe.Tests;
public sealed partial class EngineTests
{
[Fact] public async Task ServerNameIsAdminOnlyPersistsAndAppearsInPublicStatusAndGameNews()
{
const string name = "星际测试服";
Assert.Equal(401, (await Call("/control/v1/config", new { serverName = name })).Status);
Assert.Equal(200, (await Call("/control/v1/config", new { serverName = name }, admin: true)).Status);
Assert.Equal(400, (await Call("/control/v1/config", new { serverName = "bad\nname" }, admin: true)).Status);
Assert.Equal(400, (await Call("/control/v1/config", new { serverName = "<b>" }, admin: true)).Status);
await store.DisposeAsync(); store = new(root); engine = new(store, options);
var health = JObject.Parse((await Call("/health")).Body);
Assert.Equal(3, health.Value<int>("apiVersion")); Assert.Equal(name, health.Value<string>("serverName"));
Assert.Equal(options.GamePublicUrl, health.Value<string>("gameUrl"));
Assert.DoesNotContain(options.AdminToken, health.ToString());
Assert.Equal(name, JObject.Parse((await Portal("info")).Body).Value<string>("serverName"));
Assert.Contains(JObject.Parse((await Call("/dynamic/worldState.php")).Body)["Events"]!, x => x.Value<string>("Msg") == "XFEWarframe · " + name);
}
}