diff --git a/lns.go b/lns.go index 45f4029..7e2d84e 100644 --- a/lns.go +++ b/lns.go @@ -2624,6 +2624,20 @@ func (s *Service) GetDefaultReservedCatalog() *covenant.ReservedCatalog { return s.DefaultReservedCatalog() } +// HasReservedCatalog reports whether the service has a reserved-name catalog. +// +// ok := svc.HasReservedCatalog() +func (s *Service) HasReservedCatalog() bool { + return s.ReservedCatalog() != nil +} + +// GetHasReservedCatalog is an alias for HasReservedCatalog. +// +// ok := svc.GetHasReservedCatalog() +func (s *Service) GetHasReservedCatalog() bool { + return s.HasReservedCatalog() +} + // DefaultReservedCatalog exposes the reserved-name catalog used by LNS. // // This returns the canonical covenant-backed catalog, independent of the @@ -2820,6 +2834,20 @@ func (s *Service) GetLockedCatalog() *covenant.LockedCatalog { return s.LockedCatalog() } +// HasLockedCatalog reports whether the service has a locked-name catalog. +// +// ok := svc.HasLockedCatalog() +func (s *Service) HasLockedCatalog() bool { + return s.LockedCatalog() != nil +} + +// GetHasLockedCatalog is an alias for HasLockedCatalog. +// +// ok := svc.GetHasLockedCatalog() +func (s *Service) GetHasLockedCatalog() bool { + return s.HasLockedCatalog() +} + // DefaultLockedCatalog returns the package default locked-name catalog. // // This ignores any service-specific override so callers can always recover @@ -2854,6 +2882,34 @@ func GetLockedCatalog() *covenant.LockedCatalog { return DefaultLockedCatalog() } +// HasReservedCatalog reports whether the package has a reserved-name catalog. +// +// ok := lns.HasReservedCatalog() +func HasReservedCatalog() bool { + return ReservedCatalog() != nil +} + +// GetHasReservedCatalog is an alias for HasReservedCatalog. +// +// ok := lns.GetHasReservedCatalog() +func GetHasReservedCatalog() bool { + return HasReservedCatalog() +} + +// HasLockedCatalog reports whether the package has a locked-name catalog. +// +// ok := lns.HasLockedCatalog() +func HasLockedCatalog() bool { + return LockedCatalog() != nil +} + +// GetHasLockedCatalog is an alias for HasLockedCatalog. +// +// ok := lns.GetHasLockedCatalog() +func GetHasLockedCatalog() bool { + return HasLockedCatalog() +} + // GetDefaultLockedCatalog is an alias for DefaultLockedCatalog. // // catalog := lns.GetDefaultLockedCatalog() diff --git a/lns_package_test.go b/lns_package_test.go index 2ecea6d..2526bcd 100644 --- a/lns_package_test.go +++ b/lns_package_test.go @@ -444,6 +444,14 @@ func TestPackageDefaultCatalogAliases(t *testing.T) { if GetDefaultLockedCatalog() != DefaultLockedCatalog() { t.Fatal("GetDefaultLockedCatalog should alias DefaultLockedCatalog") } + + if !HasReservedCatalog() || !GetHasReservedCatalog() { + t.Fatal("HasReservedCatalog aliases should report the package reserved catalog") + } + + if !HasLockedCatalog() || !GetHasLockedCatalog() { + t.Fatal("HasLockedCatalog aliases should report the package locked catalog") + } } func TestPackageDefaultCatalogsIgnoreOverrides(t *testing.T) { @@ -493,6 +501,14 @@ func TestPackageCatalogFallbacksWhenNil(t *testing.T) { t.Fatal("LockedCatalog should fall back to the canonical catalog when nil") } + if !HasReservedCatalog() || !GetHasReservedCatalog() { + t.Fatal("HasReservedCatalog aliases should keep working when Reserved is nil") + } + + if !HasLockedCatalog() || !GetHasLockedCatalog() { + t.Fatal("HasLockedCatalog aliases should keep working when Locked is nil") + } + if _, ok := GetReservedName("RESERVED"); !ok { t.Fatal("GetReservedName should keep working when Reserved is nil") } diff --git a/lns_test.go b/lns_test.go index d86cf10..e2dc9cb 100644 --- a/lns_test.go +++ b/lns_test.go @@ -1822,6 +1822,10 @@ func TestServiceReservedCatalog(t *testing.T) { t.Fatal("GetReservedCatalog should alias DefaultReservedCatalog") } + if !svc.HasReservedCatalog() || !svc.GetHasReservedCatalog() { + t.Fatal("HasReservedCatalog aliases should report the service reserved catalog") + } + if got := svc.ReservedSize(); got != catalog.Size() { t.Fatalf("ReservedSize() = %d, want %d", got, catalog.Size()) } @@ -1970,6 +1974,10 @@ func TestServiceLockedCatalog(t *testing.T) { t.Fatal("GetLockedCatalog should alias DefaultLockedCatalog") } + if !svc.HasLockedCatalog() || !svc.GetHasLockedCatalog() { + t.Fatal("HasLockedCatalog aliases should report the service locked catalog") + } + if got := svc.LockedSize(); got != catalog.Size() { t.Fatalf("LockedSize() = %d, want %d", got, catalog.Size()) }