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

removed func main

This commit is contained in:
postmannen 2022-05-10 11:32:02 +02:00
parent 55e2a4a0e0
commit 5102b7c3a2

View file

@ -522,155 +522,3 @@ func (c *centralAuth) printMaps() {
fmt.Println("-----------------END OF PRINTING OUT MAPS------------------------")
fmt.Println()
}
func main() {
// c := newCentralAuth()
// -----------General testing and creation of some data----------------
// // Start concurrent updating of the schema.
// var wg sync.WaitGroup
// for i := 0; i < 1; i++ {
// wg.Add(1)
// go func() {
// defer wg.Done()
// c.authorization.authSchema.aclNodeFromnodeCommandAdd("ship1", "operator2", "rm -rf")
// c.authorization.authSchema.aclNodeFromnodeCommandAdd("ship1", "operator1", "ls -lt")
// c.authorization.authSchema.aclNodeFromnodeCommandAdd("ship1", "operator1", "ls -lt")
// c.authorization.authSchema.aclNodeFromnodeCommandAdd("ship1", "operator2", "ls -l")
// c.authorization.authSchema.aclNodeFromnodeCommandAdd("ship3", "operator3", "ls -lt")
// c.authorization.authSchema.aclNodeFromnodeCommandAdd("ship3", "operator3", "vi /etc/hostname")
// c.authorization.authSchema.aclNodeFromNodeCommandDelete("ship3", "operator2", "ls -lt")
// c.authorization.authSchema.aclNodeFromnodeDelete("ship3", "operator3")
// }()
//
// wg.Add(1)
// go func() {
// defer wg.Done()
// fmt.Println("----schemaMain------")
// c.authorization.authSchema.schemaMain.mu.Lock()
// for _, v := range c.authorization.authSchema.schemaMain.NodeMap {
// fmt.Printf("%+v\n", v)
// }
// c.authorization.authSchema.schemaMain.mu.Unlock()
//
// fmt.Println("----schemaGenerated------")
// c.authorization.authSchema.schemaGenerated.mu.Lock()
// for k, v := range c.authorization.authSchema.schemaGenerated.NodeMap {
// fmt.Printf("node: %v, NodeDataSerialized: %v\n", k, string(v.Data))
// fmt.Printf("node: %v, Hash: %v\n", k, v.Hash)
// }
// c.authorization.authSchema.schemaGenerated.mu.Unlock()
// }()
// }
// wg.Wait()
// c.printMaps()
// // --------- Testing as needed for request types--------------
// fmt.Println("--------- Testing as needed for request types--------------")
//
// // Get the hash for a node schema
// {
// c.authorization.authSchema.schemaGenerated.mu.Lock()
// h := c.authorization.authSchema.schemaGenerated.NodeMap["ship1"].Hash
// c.authorization.authSchema.schemaGenerated.mu.Unlock()
//
// fmt.Printf("testing: hash for ship1 = %v\n", h)
// }
// // Generate json to send to node in message with nodeMap and hash
// {
// var tmpData map[string]map[string]struct{}
// nodeName := node("ship1")
// err := json.Unmarshal(c.authorization.authSchema.schemaGenerated.NodeMap[nodeName].Data, &tmpData)
// if err != nil {
// log.Printf("error: failed to unmarshal schemaGenerated.NodeMap: %v\n", err)
// os.Exit(1)
// }
//
// fmt.Printf("\n * Data for %v: %#v\n", nodeName, tmpData)
//
// }
// // Test node group.
// {
// fmt.Println("\n--------------Group testing----------------")
// fmt.Println(" * ADDING NODES TO GROUPS")
// c.authorization.authSchema.groupNodesAddNode("grp_nodes_GROUP_A", "ship1")
// c.authorization.authSchema.groupNodesAddNode("grp_nodes_GROUP_A", "ship2")
// c.authorization.authSchema.groupNodesAddNode("grp_nodes_GROUP_A", "ship3")
// c.authorization.authSchema.groupNodesAddNode("grp_nodes_GROUP_B", "ship2")
// c.authorization.authSchema.groupNodesAddNode("grp_nodes_GROUP_C", "ship3")
//
// fmt.Println("\n * Deleting NODES FROM GROUPS")
// c.authorization.authSchema.groupNodesDeleteNode("grp_nodes_GROUP_A", "ship2")
//
// fmt.Println("\n * Deleting NODE GROUPS")
// c.authorization.authSchema.groupNodesDeleteGroup("grp_nodes_GROUP_B")
//
// // -----
//
// fmt.Println("\n * ADDING COMMANDS TO COMMAND GROUPS")
// c.authorization.authSchema.groupCommandsAddCommand("grp_cmds_C_GROUP_A", "echo apekatt")
// c.authorization.authSchema.groupCommandsAddCommand("grp_cmds_C_GROUP_A", "ls -lt")
// c.authorization.authSchema.groupCommandsAddCommand("grp_cmds_C_GROUP_A", "rm -rf")
// c.authorization.authSchema.groupCommandsAddCommand("grp_cmds_C_GROUP_B", "df -ah")
// c.authorization.authSchema.groupCommandsAddCommand("grp_cmds_C_GROUP_C", "cat /etc/hosts")
//
// fmt.Println("\n * Deleting COMMANDS FROM GROUPS")
// c.authorization.authSchema.groupCommandsDeleteCommand("grp_cmds_C_GROUP_A", "ls -lt")
//
// fmt.Println("\n * Deleting COMMAND GROUP")
// c.authorization.authSchema.groupCommandDeleteGroup("grp_cmds_C_GROUP_B")
// }
//{
// fmt.Println("\n --------- GROUP, add nodes to a group, and apply acl's --------")
// c.authorization.authSchema.groupNodesAddNode("grp_nodes_operators", "operator1")
// c.authorization.authSchema.groupNodesAddNode("grp_nodes_operators", "operator2")
//
// c.authorization.authSchema.groupNodesAddNode("grp_nodes_group100", "ship100")
// c.authorization.authSchema.groupNodesAddNode("grp_nodes_group100", "ship101")
// c.authorization.authSchema.groupNodesAddNode("grp_nodes_group100", "ship102")
//
// c.authorization.authSchema.groupCommandsAddCommand("grp_cmds_1", "dmesg")
//
// // Also add a non group user
// c.authorization.authSchema.aclCommandAdd("grp_nodes_group100", "admin", "useradd -m kongen")
// // c.authorization.authSchema.aclNodeFromnodeCommandAdd("grp_nodes_group100", "operator1", "useradd -m dmesg")
// // c.authorization.authSchema.aclNodeFromnodeCommandAdd("grp_nodes_group100", "grp_nodes_operators", "dmesg")
// c.authorization.authSchema.aclCommandAdd("grp_nodes_group100", "grp_nodes_operators", "grp_cmds_1")
// fmt.Println("\n --------- END OF GROUP NODES ADD NODE TESTING ----------")
//}
//c.printMaps()
// {
// fmt.Println("\n --------- GROUP, on all nodes, delete the command for operator1 --------")
// c.authorization.authSchema.aclNodeFromNodeCommandDelete("grp_nodes_group100", "operator1", "useradd -m operator")
//
// fmt.Println("\n --------- END ----------")
// }
//
// c.printMaps()
// {
// fmt.Println("\n --------- GROUP, on all nodes, delete fromnode operator1 --------")
// c.authorization.authSchema.aclNodeFromnodeDelete("grp_nodes_group100", "operator1")
//
// fmt.Println("\n --------- END OF DELETE A FROMNODE ----------")
// }
//
// c.printMaps()
//{
// fmt.Println("\n --------- GROUP, delete node from group --------")
// c.authorization.authSchema.groupNodesDeleteNode("grp_nodes_group100", "ship100")
// c.authorization.authSchema.generateJSONForAllNodes()
//
// fmt.Println("\n --------- END OF DELETE A FROMNODE ----------")
//}
//
//c.printMaps()
}