Skip to content

Commit 55984d4

Browse files
committed
[FAB-10307] Function test for block ACL
This CR adds function tests for the block event ACL policy. Change-Id: Ic51c5fdfd9af85b9facf526c96a4fbb1da4ecea0 Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
1 parent b4d4fd7 commit 55984d4

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

integration/e2e/acl_test.go

+60
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,66 @@ var _ = Describe("EndToEndACL", func() {
119119
execute(adminRunner)
120120
Eventually(adminRunner.Err()).Should(gbytes.Say(`\Qdeliver completed with status (FORBIDDEN)\E`))
121121
})
122+
123+
Context("when the ACL policy for Deliver is satisfied", func() {
124+
By("setting the block event ACL policy to Org1/Admins")
125+
policyName := resources.Event_Block
126+
policy := "/Channel/Application/Org1/Admins"
127+
SetACLPolicy(&w, policyName, policy)
128+
129+
By("setting the log level for deliver to debug")
130+
logRun := w.Components.Peer()
131+
logRun.ConfigDir = filepath.Join(w.Rootpath, "org1.example.com_0")
132+
logRun.MSPConfigPath = filepath.Join(w.Rootpath, "crypto", "peerOrganizations", "org1.example.com", "users", "Admin@org1.example.com", "msp")
133+
lRunner := logRun.SetLogLevel("common/deliver", "debug")
134+
execute(lRunner)
135+
Expect(lRunner.Err()).To(gbytes.Say("Log level set for peer modules matching regular expression 'common/deliver': DEBUG"))
136+
137+
By("fetching the latest block from the peer")
138+
fetchRun := w.Components.Peer()
139+
fetchRun.ConfigDir = filepath.Join(w.Rootpath, "org1.example.com_0")
140+
fetchRun.MSPConfigPath = filepath.Join(w.Rootpath, "crypto", "peerOrganizations", "org1.example.com", "users", "Admin@org1.example.com", "msp")
141+
fRunner := fetchRun.FetchChannel(w.Deployment.Channel, filepath.Join(testDir, "newest_block.pb"), "newest", "")
142+
execute(fRunner)
143+
Expect(fRunner.Err()).To(gbytes.Say("Received block: "))
144+
// TODO - enable this once the peer's logs are available here
145+
// Expect(peerRunner.Err()).To(gbytes.Say(`\Q[channel: testchannel] Done delivering \E`))
146+
147+
By("setting the log level for deliver to back to info")
148+
lRunner = logRun.SetLogLevel("common/deliver", "info")
149+
execute(lRunner)
150+
Expect(lRunner.Err()).To(gbytes.Say("Log level set for peer modules matching regular expression 'common/deliver': INFO"))
151+
})
152+
153+
Context("tests when the ACL policy for Deliver is not satisifed", func() {
154+
By("setting the block event ACL policy to Org2/Admins")
155+
policyName := resources.Event_Block
156+
policy := "/Channel/Application/Org2/Admins"
157+
SetACLPolicy(&w, policyName, policy)
158+
159+
By("setting the log level for deliver to debug")
160+
logRun := w.Components.Peer()
161+
logRun.ConfigDir = filepath.Join(w.Rootpath, "org1.example.com_0")
162+
logRun.MSPConfigPath = filepath.Join(w.Rootpath, "crypto", "peerOrganizations", "org1.example.com", "users", "Admin@org1.example.com", "msp")
163+
lRunner := logRun.SetLogLevel("common/deliver", "debug")
164+
execute(lRunner)
165+
Expect(lRunner.Err()).To(gbytes.Say("Log level set for peer modules matching regular expression 'common/deliver': DEBUG"))
166+
167+
By("fetching the latest block from the peer")
168+
fetchRun := w.Components.Peer()
169+
fetchRun.ConfigDir = filepath.Join(w.Rootpath, "org1.example.com_0")
170+
fetchRun.MSPConfigPath = filepath.Join(w.Rootpath, "crypto", "peerOrganizations", "org1.example.com", "users", "Admin@org1.example.com", "msp")
171+
fRunner := fetchRun.FetchChannel(w.Deployment.Channel, filepath.Join(testDir, "newest_block.pb"), "newest", "")
172+
execute(fRunner)
173+
Expect(fRunner.Err()).To(gbytes.Say("can't read the block: &{FORBIDDEN}"))
174+
// TODO - enable this once the peer's logs are available here
175+
// Expect(peerRunner.Err()).To(gbytes.Say(`\Q[channel: testchannel] Done delivering \Q`))
176+
177+
By("setting the log level for deliver to back to info")
178+
lRunner = logRun.SetLogLevel("common/deliver", "info")
179+
execute(lRunner)
180+
Expect(lRunner.Err()).To(gbytes.Say("Log level set for peer modules matching regular expression 'common/deliver': INFO"))
181+
})
122182
})
123183
})
124184

0 commit comments

Comments
 (0)