diff --git a/central_auth_acl_handling.go b/central_auth_acl_handling.go index 055705c..7bc5137 100644 --- a/central_auth_acl_handling.go +++ b/central_auth_acl_handling.go @@ -40,15 +40,17 @@ type accessLists struct { validator *validator.Validate errorKernel *errorKernel configuration *Configuration + pki *pki } -func newAccessLists(errorKernel *errorKernel, configuration *Configuration) *accessLists { +func newAccessLists(pki *pki, errorKernel *errorKernel, configuration *Configuration) *accessLists { a := accessLists{ schemaMain: newSchemaMain(configuration), schemaGenerated: newSchemaGenerated(), validator: validator.New(), errorKernel: errorKernel, configuration: configuration, + pki: pki, } // The main acl map gets loaded from disk in the newSchemaMain function, but since that diff --git a/central_auth_key_handling.go b/central_auth_key_handling.go index 49e14e8..9779b38 100644 --- a/central_auth_key_handling.go +++ b/central_auth_key_handling.go @@ -24,10 +24,9 @@ type centralAuth struct { // newCentralAuth will return a new and prepared *centralAuth func newCentralAuth(configuration *Configuration, errorKernel *errorKernel) *centralAuth { - c := centralAuth{ - accessLists: newAccessLists(errorKernel, configuration), - pki: newPKI(configuration, errorKernel), - } + c := centralAuth{} + c.pki = newPKI(configuration, errorKernel) + c.accessLists = newAccessLists(c.pki, errorKernel, configuration) return &c } diff --git a/central_auth_test.go b/central_auth_test.go index d0c4623..f88b17a 100644 --- a/central_auth_test.go +++ b/central_auth_test.go @@ -15,7 +15,7 @@ func TestACLSingleNode(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists(&errorKernel{}, &Configuration{}) + a := newAccessLists(&pki{}, &errorKernel{}, &Configuration{}) a.aclAddCommand("ship101", "admin", "HORSE") a.aclAddCommand("ship101", "admin", "PIG") @@ -43,7 +43,7 @@ func TestACLWithGroups(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists(&errorKernel{}, &Configuration{}) + a := newAccessLists(&pki{}, &errorKernel{}, &Configuration{}) const ( grp_nodes_operators = "grp_nodes_operators" @@ -104,7 +104,7 @@ func TestACLNodesGroupDeleteNode(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists(&errorKernel{}, &Configuration{}) + a := newAccessLists(&pki{}, &errorKernel{}, &Configuration{}) const ( grp_nodes_operators = "grp_nodes_operators" @@ -163,7 +163,7 @@ func TestGroupNodesDeleteGroup(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists(&errorKernel{}, &Configuration{}) + a := newAccessLists(&pki{}, &errorKernel{}, &Configuration{}) const ( grp_nodes_operators = "grp_nodes_operators" @@ -222,7 +222,7 @@ func TestGroupCommandDeleteGroup(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists(&errorKernel{}, &Configuration{}) + a := newAccessLists(&pki{}, &errorKernel{}, &Configuration{}) const ( grp_nodes_operators = "grp_nodes_operators" @@ -281,7 +281,7 @@ func TestACLGenerated(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists(&errorKernel{}, &Configuration{}) + a := newAccessLists(&pki{}, &errorKernel{}, &Configuration{}) a.aclAddCommand("ship101", "admin", "HORSE") @@ -332,7 +332,7 @@ func TestACLSchemaMainACLMap(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists(&errorKernel{}, &Configuration{}) + a := newAccessLists(&pki{}, &errorKernel{}, &Configuration{}) //a.aclNodeFromnodeCommandAdd("ship101", "admin", "PIG") // fmt.Printf("---------------ADDING COMMAND-------------\n") @@ -434,7 +434,7 @@ func TestACLSchemaMainACLMap(t *testing.T) { // } func TestACLConcurrent(t *testing.T) { - a := newAccessLists(&errorKernel{}, &Configuration{}) + a := newAccessLists(&pki{}, &errorKernel{}, &Configuration{}) // -----------General testing and creation of some data---------------- @@ -529,7 +529,7 @@ func TestImportACLs(t *testing.T) { want := `map[grp_nodes_ships:map[admin:map[useradd -m kongen:{}] grp_nodes_operators:map[grp_commands_commandset1:{}]] ship101:map[admin:map[HORSE:{}]]]` - a := newAccessLists(&errorKernel{}, &Configuration{}) + a := newAccessLists(&pki{}, &errorKernel{}, &Configuration{}) err := a.importACLs(js) if err != nil {