Skip to content

Commit

Permalink
[FAB-6991] Fix max enrollments for bootstrap user
Browse files Browse the repository at this point in the history
The max enrollments for the bootstrap user should use the
max enrollments setting of the server.  This is needed in order
to allow starting the server to enforce one-time passwords and
also use the default bootstrap user settings.

The additional test case failed prior to this change set,
but now succeeds.

Change-Id: Ibbad7c9e0efd4679138c41277b1f69ebe360132d
Signed-off-by: Keith Smith <bksmith@us.ibm.com>
  • Loading branch information
Keith Smith committed Nov 16, 2017
1 parent f07eee9 commit cd74c8a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 0 additions & 1 deletion cmd/fabric-ca-server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ registry:
pass: <<<ADMINPW>>>
type: client
affiliation: ""
maxenrollments: -1
attrs:
hf.Registrar.Roles: "client,user,peer,validator,auditor"
hf.Registrar.DelegateRoles: "client,user,validator,auditor"
Expand Down
11 changes: 11 additions & 0 deletions cmd/fabric-ca-server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ func TestErrors(t *testing.T) {
}
}

func TestOneTimePass(t *testing.T) {
testDir := "oneTimePass"
os.RemoveAll(testDir)
defer os.RemoveAll(testDir)
// Test with "-b" option
err := RunMain([]string{cmdName, "init", "-b", "admin:adminpw", "--registry.maxenrollments", "1", "-H", testDir})
if err != nil {
t.Fatalf("Failed to init server with one time passwords: %s", err)
}
}

func TestLDAP(t *testing.T) {
os.RemoveAll(ldapTestDir)
defer os.RemoveAll(ldapTestDir)
Expand Down
2 changes: 1 addition & 1 deletion lib/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (s *Server) RegisterBootstrapUser(user, pass, affiliation string) error {
Pass: pass,
Type: "user",
Affiliation: affiliation,
MaxEnrollments: s.CA.Config.Registry.MaxEnrollments,
MaxEnrollments: 0, // 0 means to use the server's max enrollment setting
Attrs: map[string]string{
attrRoles: allRoles,
attrDelegateRoles: allRoles,
Expand Down

0 comments on commit cd74c8a

Please sign in to comment.