Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-7893] Prevent unforced delete of sub-affiliations
This patch adds a couple of unit tests and change code on removal of an affiliation with sub-affiliations to check that this only happens when the force flag is specified. Before the bug fix the new tests fail: $ go test -v -run=TestAffiliationCmd github.com/hyperledger/fabric-ca/cmd/ fabric-ca-client ... Successfully added affiliation: org4.dept1.team Successfully removed affiliation: &{AffiliationInfo:{Name:org3 Affiliation s:[] Identities:[]} CAName:} Successfully modified affiliation: &{AffiliationInfo:{Name:org3 Affiliatio ns:[] Identities:[]} CAName:} Successfully removed affiliation: &{AffiliationInfo:{Name:org4 Affiliation s:[{Name:org4.dept1 Affiliations:[{Name:org4.dept1.team Affiliations:[] Id entities:[]}] Identities:[]}] Identities:[]} CAName:} 2018/01/30 11:31:21 [ERROR] Server has stopped serving: accept tcp [::]:70 90: use of closed network connection --- FAIL: TestAffiliationCmd (4.13s) Error Trace: main_test.go:858 Error: An error is expected but got nil. Messages: Should have failed, no force argument provided and affiliation being deleted had sub-affiliations FAIL exit status 1 FAIL github.com/hyperledger/fabric-ca/cmd/fabric-ca-client 4.147s After the bug fix the new tests pass: $ go test -v -run=TestAffiliationCmd github.com/hyperledger/fabric-ca/cmd/ fabric-ca-client ... Successfully added affiliation: org4.dept1.team Successfully removed affiliation: &{AffiliationInfo:{Name:org3 Affiliation s:[] Identities:[]} CAName:} Successfully modified affiliation: &{AffiliationInfo:{Name:org3 Affiliatio ns:[] Identities:[]} CAName:} Error: Response from server: Error Code: 20 - Authorization failure Successfully removed affiliation: &{AffiliationInfo:{Name:org4 Affiliation s:[{Name:org4.dept1 Affiliations:[{Name:org4.dept1.team Affiliations:[] Id entities:[]}] Identities:[]}] Identities:[]} CAName:} 2018/01/30 11:33:06 [ERROR] Server has stopped serving: accept tcp [::]:70 90: use of closed network connection --- PASS: TestAffiliationCmd (4.12s) PASS ok github.com/hyperledger/fabric-ca/cmd/fabric-ca-client 4.129s Patch-set #2: Improve error messages. Change-Id: Ib5a7acb68a42f251970cce6735173ea296ef5d54 Signed-off-by: Arnaud J Le Hors <[email protected]>
- Loading branch information