S8TenantIsolationContractTests.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Admin.NET.Plugin.AiDOP.Dto.S8;
  2. using Admin.NET.Plugin.AiDOP.Job;
  3. using Admin.NET.Plugin.AiDOP.Service.S8;
  4. using Admin.NET.Plugin.AiDOP.Service.S8.Rules;
  5. using Xunit;
  6. namespace Admin.NET.Plugin.AiDOP.Tests.S8;
  7. public class S8TenantIsolationContractTests
  8. {
  9. [Fact]
  10. public void AutoExceptionCreation_RequiresExplicitTenantAndFactory()
  11. {
  12. Assert.NotNull(typeof(S8ManualReportService).GetMethod(
  13. nameof(S8ManualReportService.CreateFromWatchAsync),
  14. [typeof(long), typeof(long), typeof(S8WatchHitResult)]));
  15. Assert.NotNull(typeof(S8ManualReportService).GetMethod(
  16. nameof(S8ManualReportService.CreateFromHitAsync),
  17. [typeof(long), typeof(long), typeof(S8RuleHit)]));
  18. }
  19. [Fact]
  20. public void SchedulerServices_DiscoverValidTenantScopes()
  21. {
  22. Assert.NotNull(typeof(S8WatchSchedulerService).GetMethod(
  23. nameof(S8WatchSchedulerService.ListEnabledScopesAsync)));
  24. Assert.NotNull(typeof(S8ActiveFlowWatchService).GetMethod(
  25. nameof(S8ActiveFlowWatchService.ListActiveScopesAsync)));
  26. }
  27. [Fact]
  28. public void ManualReport_ResolvesTenantAndFactoryFromServerContext()
  29. {
  30. const System.Reflection.BindingFlags flags =
  31. System.Reflection.BindingFlags.Instance |
  32. System.Reflection.BindingFlags.NonPublic;
  33. Assert.NotNull(typeof(S8ManualReportService).GetMethod(
  34. "ResolveTrustedScopeAsync", flags));
  35. }
  36. [Fact]
  37. public void BackgroundJobs_DoNotKeepLegacyDefaultTenantConstants()
  38. {
  39. const System.Reflection.BindingFlags flags =
  40. System.Reflection.BindingFlags.Static |
  41. System.Reflection.BindingFlags.NonPublic |
  42. System.Reflection.BindingFlags.Public;
  43. Assert.Null(typeof(S8WatchSchedulerJob).GetField("DefaultTenantId", flags));
  44. Assert.Null(typeof(S8ActiveFlowStuckScanJob).GetField("DefaultTenantId", flags));
  45. }
  46. }