@@ -34,10 +34,10 @@ func duplexOf(ids ...graph.ID) cardinality.Duplex[uint64] {
3434 return bitmap
3535}
3636
37- // newForestFilterCache builds an ADCSCache where the CA has a valid cert chain to
38- // both domains, so only forest scoping can distinguish them. Each test sets the
39- // forest-scoping fields itself .
40- func newForestFilterCache (eca , inForestDomain , foreignDomain * graph.Node ) * ADCSCache {
37+ // newForestHostingCache builds an ADCSCache where the CA has a valid cert chain
38+ // to both domains, so only the hosting-computer gate can distinguish whether the
39+ // CA should be processed .
40+ func newForestHostingCache (eca , inForestDomain , foreignDomain * graph.Node ) * ADCSCache {
4141 cache := NewADCSCache ()
4242
4343 cache .enterpriseCertAuthorities = []* graph.Node {eca }
@@ -51,50 +51,48 @@ func newForestFilterCache(eca, inForestDomain, foreignDomain *graph.Node) *ADCSC
5151 return cache
5252}
5353
54- func adcsForestFilterNodes () (eca , inForestDomain , foreignDomain * graph.Node ) {
54+ func adcsForestHostingNodes () (eca , inForestDomain , foreignDomain * graph.Node ) {
5555 eca = graph .NewNode (10 , graph .NewProperties (), ad .EnterpriseCA )
5656 inForestDomain = graph .NewNode (1 , graph .NewProperties (), ad .Domain )
5757 foreignDomain = graph .NewNode (2 , graph .NewProperties (), ad .Domain )
5858 return eca , inForestDomain , foreignDomain
5959}
6060
61- func TestGetECAHostedChainedDomains_ForestScoping (t * testing.T ) {
62- t .Run ("forest known: keeps in- forest domain, drops foreign-forest domain " , func (t * testing.T ) {
63- eca , inForestDomain , foreignDomain := adcsForestFilterNodes ()
64- cache := newForestFilterCache (eca , inForestDomain , foreignDomain )
61+ func TestGetECAHostedChainedDomains_ForestHosting (t * testing.T ) {
62+ t .Run ("forest known and host in forest: keeps all chained domains " , func (t * testing.T ) {
63+ eca , inForestDomain , foreignDomain := adcsForestHostingNodes ()
64+ cache := newForestHostingCache (eca , inForestDomain , foreignDomain )
6565
6666 cache .hasHostingComputer [eca .ID ] = true
6767 cache .hasInForestHostingComputer [eca .ID ] = true
68- cache .ecaForestDomains [eca .ID ] = duplexOf (inForestDomain .ID )
6968
7069 result := cache .GetECAHostedChainedDomains ()
7170
7271 require .Contains (t , result , eca .ID .Uint64 ())
7372 chains := result [eca .ID .Uint64 ()]
7473 assert .True (t , chains .Domains .Contains (inForestDomain .ID .Uint64 ()), "in-forest domain should survive" )
75- assert .False (t , chains .Domains .Contains (foreignDomain .ID .Uint64 ()), "foreign-forest domain should be filtered out " )
76- assert .Equal (t , uint64 (1 ), chains .Domains .Cardinality ())
74+ assert .True (t , chains .Domains .Contains (foreignDomain .ID .Uint64 ()), "foreign-forest chained domain should survive " )
75+ assert .Equal (t , uint64 (2 ), chains .Domains .Cardinality ())
7776 })
7877
7978 t .Run ("forest known but only a cross-forest hosting computer: CA is dropped entirely" , func (t * testing.T ) {
80- eca , inForestDomain , foreignDomain := adcsForestFilterNodes ()
81- cache := newForestFilterCache (eca , inForestDomain , foreignDomain )
79+ eca , inForestDomain , foreignDomain := adcsForestHostingNodes ()
80+ cache := newForestHostingCache (eca , inForestDomain , foreignDomain )
8281
8382 // A hosting computer exists, but it lives outside the CA's forest.
8483 cache .hasHostingComputer [eca .ID ] = true
8584 cache .hasInForestHostingComputer [eca .ID ] = false
86- cache .ecaForestDomains [eca .ID ] = duplexOf (inForestDomain .ID )
8785
8886 result := cache .GetECAHostedChainedDomains ()
8987
9088 assert .NotContains (t , result , eca .ID .Uint64 (), "CA with no in-forest host should be skipped" )
9189 })
9290
9391 t .Run ("forest unknown: falls back to host-only gating with no domain filtering" , func (t * testing.T ) {
94- eca , inForestDomain , foreignDomain := adcsForestFilterNodes ()
95- cache := newForestFilterCache (eca , inForestDomain , foreignDomain )
92+ eca , inForestDomain , foreignDomain := adcsForestHostingNodes ()
93+ cache := newForestHostingCache (eca , inForestDomain , foreignDomain )
9694
97- // No ecaForestDomains / hasInForestHostingComputer entry => forest unknown.
95+ // No hasInForestHostingComputer entry => forest unknown.
9896 cache .hasHostingComputer [eca .ID ] = true
9997
10098 result := cache .GetECAHostedChainedDomains ()
@@ -107,8 +105,8 @@ func TestGetECAHostedChainedDomains_ForestScoping(t *testing.T) {
107105 })
108106
109107 t .Run ("forest unknown and no hosting computer: CA is dropped" , func (t * testing.T ) {
110- eca , inForestDomain , foreignDomain := adcsForestFilterNodes ()
111- cache := newForestFilterCache (eca , inForestDomain , foreignDomain )
108+ eca , inForestDomain , foreignDomain := adcsForestHostingNodes ()
109+ cache := newForestHostingCache (eca , inForestDomain , foreignDomain )
112110
113111 // hasHostingComputer absent/false and forest unknown.
114112
@@ -118,26 +116,23 @@ func TestGetECAHostedChainedDomains_ForestScoping(t *testing.T) {
118116 })
119117}
120118
121- func TestGetChainedDomains_ForestScoping (t * testing.T ) {
122- t .Run ("forest filter applies without the hosting-computer guard" , func (t * testing.T ) {
123- eca , inForestDomain , foreignDomain := adcsForestFilterNodes ()
124- cache := newForestFilterCache (eca , inForestDomain , foreignDomain )
125-
126- // GetChainedDomains intentionally ignores hosting computers, so leave them
127- // unset to prove the forest filter alone scopes the EnrollOnBehalfOf linkage.
128- cache .ecaForestDomains [eca .ID ] = duplexOf (inForestDomain .ID )
119+ func TestGetChainedDomains_IgnoresForestHosting (t * testing.T ) {
120+ t .Run ("does not apply the hosting-computer guard" , func (t * testing.T ) {
121+ eca , inForestDomain , foreignDomain := adcsForestHostingNodes ()
122+ cache := newForestHostingCache (eca , inForestDomain , foreignDomain )
123+ cache .hasInForestHostingComputer [eca .ID ] = false
129124
130125 result := cache .GetChainedDomains ()
131126
132127 require .Contains (t , result , eca .ID .Uint64 ())
133128 chains := result [eca .ID .Uint64 ()]
134129 assert .True (t , chains .Domains .Contains (inForestDomain .ID .Uint64 ()))
135- assert .False (t , chains .Domains .Contains (foreignDomain .ID .Uint64 ()), "foreign-forest domain should be filtered out" )
130+ assert .True (t , chains .Domains .Contains (foreignDomain .ID .Uint64 ()))
136131 })
137132
138133 t .Run ("forest unknown: keeps every chained domain" , func (t * testing.T ) {
139- eca , inForestDomain , foreignDomain := adcsForestFilterNodes ()
140- cache := newForestFilterCache (eca , inForestDomain , foreignDomain )
134+ eca , inForestDomain , foreignDomain := adcsForestHostingNodes ()
135+ cache := newForestHostingCache (eca , inForestDomain , foreignDomain )
141136
142137 result := cache .GetChainedDomains ()
143138
0 commit comments