Skip to content

Commit 6262b1e

Browse files
committed
Restore Peer_Propose ACL resource and remove ACL capability gates
Commit c948ab2 removed all ACL resource constants and default policy mappings, but fabric-smart-client's fabricx membership service still depends on: - resources.Peer_Propose constant ("peer/Propose") - default ACL mapping Peer_Propose → CHANNELWRITERS - aclmgmt.ACLProvider interface Changes: - core/aclmgmt/resources/resources.go: restore Peer_Propose constant - core/aclmgmt/defaultaclprovider.go: restore Peer_Propose → CHANNELWRITERS mapping - common/capabilities/application.go: ACLs() always returns true (no capability gating needed) - common/channelconfig/application.go: remove ACL capability check - Test updates for parallel test compliance -e Signed-off-by: Senthilnathan <cendhu@gmail.com>
1 parent c948ab2 commit 6262b1e

6 files changed

Lines changed: 24 additions & 10 deletions

File tree

common/capabilities/application.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ func (ap *ApplicationProvider) Type() string {
6969
return applicationTypeName
7070
}
7171

72-
// ACLs returns whether ACLs may be specified in the channel application config
72+
// ACLs returns whether ACLs may be specified in the channel application config.
73+
// In Fabric-X, ACLs are always allowed regardless of capability version.
7374
func (ap *ApplicationProvider) ACLs() bool {
74-
return ap.v12 || ap.v13 || ap.v142 || ap.v20 || ap.v25
75+
return true
7576
}
7677

7778
// ForbidDuplicateTXIdInBlock specifies whether two transactions with the same TXId are permitted

common/capabilities/application_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
func TestApplicationV10(t *testing.T) {
1717
ap := NewApplicationProvider(map[string]*cb.Capability{})
1818
require.NoError(t, ap.Supported())
19+
// ACLs are always enabled in Fabric-X, regardless of capability version
20+
require.True(t, ap.ACLs())
1921
}
2022

2123
func TestApplicationV11(t *testing.T) {
@@ -25,6 +27,8 @@ func TestApplicationV11(t *testing.T) {
2527
require.NoError(t, ap.Supported())
2628
require.True(t, ap.ForbidDuplicateTXIdInBlock())
2729
require.True(t, ap.V1_1Validation())
30+
// ACLs are always enabled in Fabric-X, regardless of capability version
31+
require.True(t, ap.ACLs())
2832
}
2933

3034
func TestApplicationV12(t *testing.T) {

common/channelconfig/application.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ func NewApplicationConfig(appGroup *cb.ConfigGroup, mspConfig *MSPConfigHandler)
4545
return nil, errors.Wrap(err, "failed to deserialize values")
4646
}
4747

48-
if !ac.Capabilities().ACLs() {
49-
if _, ok := appGroup.Values[ACLsKey]; ok {
50-
return nil, errors.New("ACLs may not be specified without the required capability")
51-
}
52-
}
53-
5448
var err error
5549
for orgName, orgGroup := range appGroup.Groups {
5650
ac.applicationOrgs[orgName], err = NewApplicationOrgConfig(orgName, orgGroup, mspConfig)

common/channelconfig/application_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ import (
1818
)
1919

2020
func TestApplicationInterface(t *testing.T) {
21+
t.Parallel()
2122
_ = Application((*ApplicationConfig)(nil))
2223
}
2324

2425
func TestACL(t *testing.T) {
26+
t.Parallel()
2527
g := NewGomegaWithT(t)
2628
cgt := &cb.ConfigGroup{
2729
Values: map[string]*cb.ConfigValue{
@@ -41,15 +43,17 @@ func TestACL(t *testing.T) {
4143
}
4244

4345
t.Run("Success", func(t *testing.T) {
46+
t.Parallel()
4447
cg := proto.Clone(cgt).(*cb.ConfigGroup)
4548
_, err := NewApplicationConfig(proto.Clone(cg).(*cb.ConfigGroup), nil)
4649
g.Expect(err).NotTo(HaveOccurred())
4750
})
4851

49-
t.Run("MissingCapability", func(t *testing.T) {
52+
t.Run("ACLsAllowedWithoutCapability", func(t *testing.T) {
53+
t.Parallel()
5054
cg := proto.Clone(cgt).(*cb.ConfigGroup)
5155
delete(cg.Values, CapabilitiesKey)
5256
_, err := NewApplicationConfig(cg, nil)
53-
g.Expect(err).To(MatchError("ACLs may not be specified without the required capability"))
57+
g.Expect(err).NotTo(HaveOccurred())
5458
})
5559
}

core/aclmgmt/defaultaclprovider.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
pb "github.com/hyperledger/fabric-protos-go-apiv2/peer"
1414

1515
"github.com/hyperledger/fabric-x-common/common/policies"
16+
"github.com/hyperledger/fabric-x-common/core/aclmgmt/resources"
1617
"github.com/hyperledger/fabric-x-common/core/policy"
1718
"github.com/hyperledger/fabric-x-common/protoutil"
1819
)
@@ -46,6 +47,9 @@ func newDefaultACLProvider(policyChecker policy.PolicyChecker) defaultACLProvide
4647
cResourcePolicyMap: map[string]string{},
4748
}
4849

50+
// Peer resources
51+
d.cResourcePolicyMap[resources.Peer_Propose] = CHANNELWRITERS
52+
4953
return d
5054
}
5155

core/aclmgmt/resources/resources.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@ SPDX-License-Identifier: Apache-2.0
66

77
// Package resources contains resource names used in fabric for ACL checks.
88
package resources
9+
10+
const (
11+
// Peer_Propose is the ACL resource for the peer Propose API.
12+
// The underscore naming is intentional to preserve compatibility with
13+
// downstream consumers (e.g., fabric-smart-client) that reference this constant.
14+
Peer_Propose = "peer/Propose" //nolint:revive,staticcheck
15+
)

0 commit comments

Comments
 (0)