Files
opengenesislinkserver/tools/ci/HGForeignPresenceRegression/Program.cs
T

32 lines
1.6 KiB
C#

// SPDX-License-Identifier: MPL-2.0
using System;
using System.Reflection;
using OpenSim.Services.UserAccountService;
static string Identity(string value)
{
MethodInfo? cacheKey = typeof(GridUserService).GetMethod(
"GridUserCacheKey", BindingFlags.Static | BindingFlags.NonPublic);
if (cacheKey is null)
throw new Exception("GridUserCacheKey not available");
return (string)cacheKey.Invoke(null, new object[] { value })!;
}
static void Check(bool condition, string reason)
{
if (!condition) throw new Exception(reason);
}
const string id = "d1844e28-095c-4f9c-8e05-9412b5996336";
string bare = id;
string original = id + ";https://home.example.test:8002/;Visitor Example";
string missingSlash = id + ";https://home.example.test:8002;Visitor Example";
string extraSlash = id + ";https://home.example.test:8002///;Visitor Example";
string differentGrid = id + ";https://another.example.test:8002/;Visitor Example";
string differentName = id + ";https://home.example.test:8002/;Visitor Changed";
Check(Identity(bare) == bare, "Local UUID must remain unchanged");
Check(Identity(original) == Identity(missingSlash), "HG login and logout UUI slash mismatch");
Check(Identity(original) == Identity(extraSlash), "HG home URI slash normalization failed");
Check(Identity(original) != Identity(differentGrid), "Distinct home grids must not share cache keys");
Check(Identity(original) != Identity(differentName), "Different UUI display identities must not be collapsed");
Check(Identity(original).EndsWith("/;Visitor Example"), "Expected canonical trailing slash");
Console.WriteLine("HG foreign GridUser canonical UUI and cross-grid isolation: PASS");