1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00

imported pki into accessLists

This commit is contained in:
postmannen 2022-06-01 13:04:34 +02:00
parent c32e9a673a
commit 4bfc4f3f03
3 changed files with 15 additions and 14 deletions

View file

@ -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

View file

@ -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
}

View file

@ -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 {