36 lines
2.5 KiB
C#
36 lines
2.5 KiB
C#
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<IApiKeyAdminService>("ListAsync",Task.FromResult<IReadOnlyList<ApiKey>>([])));
|
|
services.AddSingleton(RejectingFixture.WithRead<IApiKeyGalaxyAckIdentityService>("ListAsync",Task.FromResult<IReadOnlyDictionary<string,string>>(new Dictionary<string,string>())));
|
|
services.AddSingleton(RejectingFixture.WithRead<ILdapGroupRoleMappingService>("ListAllAsync",Task.FromResult<IReadOnlyList<LdapGroupRoleMapping>>([])));
|
|
services.Configure<ZB.MOM.WW.OtOpcUa.Security.Ldap.LdapOptions>(_=>{});
|
|
services.AddSingleton(RejectingFixture.WithReads<IAclScopeService>(new()
|
|
{
|
|
["LoadKnownPrincipalsAsync"]=Task.FromResult<IReadOnlyList<string>>(["fixture-principal"]),
|
|
["CheckPrincipalAsync"]=Task.FromResult(new PrincipalUsage(false,0,0)),
|
|
["CheckScopeAsync"]=Task.FromResult(new AclScopeCheck(true,"Synthetic local cluster scope"))
|
|
}));
|
|
services.AddSingleton(RejectingFixture.WithRead<IManualFailoverService>("GetSnapshot",new ManualFailoverSnapshot(null,[])));
|
|
services.AddSingleton(DispatchProxy.Create<IAuditWriter,RejectingFixture>());
|
|
builder.Configuration["OpcUa:PkiStoreRoot"]=Path.Combine(Path.GetTempPath(),"ot-ui-empty-pki-"+Guid.NewGuid().ToString("N"));
|
|
services.AddSingleton<CertificateStoreManager>();
|
|
IReadOnlyList<SecretMetadata> 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<ISecretStore>("ListAsync",Task.FromResult(metadata)));
|
|
services.AddSingleton(DispatchProxy.Create<ISecretCipher,RejectingFixture>());
|
|
}
|
|
}
|