using System.Reflection; using ZB.MOM.WW.OtOpcUa.AdminUI.Acls; using ZB.MOM.WW.OtOpcUa.AdminUI.ApiKeyAck; using ZB.MOM.WW.OtOpcUa.AdminUI.Certificates; using ZB.MOM.WW.OtOpcUa.Configuration.Entities; using ZB.MOM.WW.OtOpcUa.Configuration.Services; using ZB.MOM.WW.OtOpcUa.ControlPlane.Redundancy; using ZB.MOM.WW.OtOpcUa.Core.Authorization; using ZB.MOM.WW.Secrets.Abstractions; using ZB.MOM.WW.Audit; // Disposable read adapters: only explicitly listed reads succeed; all mutations/value reads reject. internal static class FinalGrammarFixtures { internal static void Register(WebApplicationBuilder builder) { var services=builder.Services; services.AddSingleton(RejectingFixture.WithRead("ListAsync",Task.FromResult>([]))); services.AddSingleton(RejectingFixture.WithRead("ListAsync",Task.FromResult>(new Dictionary()))); services.AddSingleton(RejectingFixture.WithRead("ListAllAsync",Task.FromResult>([]))); services.Configure(_=>{}); services.AddSingleton(RejectingFixture.WithReads(new() { ["LoadKnownPrincipalsAsync"]=Task.FromResult>(["fixture-principal"]), ["CheckPrincipalAsync"]=Task.FromResult(new PrincipalUsage(false,0,0)), ["CheckScopeAsync"]=Task.FromResult(new AclScopeCheck(true,"Synthetic local cluster scope")) })); services.AddSingleton(RejectingFixture.WithRead("GetSnapshot",new ManualFailoverSnapshot(null,[]))); services.AddSingleton(DispatchProxy.Create()); builder.Configuration["OpcUa:PkiStoreRoot"]=Path.Combine(Path.GetTempPath(),"ot-ui-empty-pki-"+Guid.NewGuid().ToString("N")); services.AddSingleton(); IReadOnlyList metadata=[new(){Name=new SecretName("fixture/metadata-only"),Description="Synthetic local metadata; value reads reject",ContentType=SecretContentType.Text,KekId="fixture-key",Revision=1,CreatedUtc=DateTimeOffset.Parse("2026-11-14T00:00:00Z"),UpdatedUtc=DateTimeOffset.Parse("2026-11-14T00:00:00Z"),UpdatedBy="fixture"}]; services.AddSingleton(RejectingFixture.WithRead("ListAsync",Task.FromResult(metadata))); services.AddSingleton(DispatchProxy.Create()); } }