mirror of
https://github.com/outbackdingo/databunker.git
synced 2026-01-27 10:18:45 +00:00
refactor test code
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
uuid "github.com/hashicorp/go-uuid"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/securitybunker/databunker/src/storage"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -83,41 +82,6 @@ func helpConfigurationDump(token string) ([]byte, error) {
|
||||
return helpServe0(request)
|
||||
}
|
||||
|
||||
func init() {
|
||||
log.Printf("**INIT*TEST*CODE***\n")
|
||||
testDBFile := storage.CreateTestDB()
|
||||
db, myRootToken, err := setupDB(&testDBFile, nil, "")
|
||||
if err != nil {
|
||||
log.Printf("Init error %s", err.Error())
|
||||
}
|
||||
rootToken = myRootToken
|
||||
var cfg Config
|
||||
cfile := "../databunker.yaml"
|
||||
err = readConfFile(&cfg, &cfile)
|
||||
cfg.SelfService.AppRecordChange = []string{"testapp", "super"}
|
||||
if err != nil {
|
||||
cfg.SelfService.ForgetMe = false
|
||||
cfg.SelfService.UserRecordChange = true
|
||||
cfg.Generic.CreateUserWithoutAccessToken = true
|
||||
//cfg.Generic.UseSeparateAppTables = true
|
||||
cfg.Policy.MaxUserRetentionPeriod = "1m"
|
||||
cfg.Policy.MaxAuditRetentionPeriod = "12m"
|
||||
cfg.Policy.MaxSessionRetentionPeriod = "1h"
|
||||
cfg.Policy.MaxShareableRecordRetentionPeriod = "1m"
|
||||
}
|
||||
e = mainEnv{db, cfg, make(chan struct{})}
|
||||
rootToken2, err := e.db.getRootXtoken()
|
||||
if err != nil {
|
||||
log.Printf("Failed to retrieve root token: %s\n", err)
|
||||
}
|
||||
log.Printf("Hashed root token: %s\n", rootToken2)
|
||||
router = e.setupRouter()
|
||||
router = e.setupConfRouter(router)
|
||||
//test1 := &testEnv{e, rootToken, router}
|
||||
e.dbCleanupDo()
|
||||
log.Printf("**INIT*DONE***\n")
|
||||
}
|
||||
|
||||
/*
|
||||
func TestBackupOK(t *testing.T) {
|
||||
log.Printf("root token: %s\n", rootToken)
|
||||
|
||||
42
src/init_test.go
Normal file
42
src/init_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/securitybunker/databunker/src/storage"
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.Printf("**INIT*TEST*CODE***\n")
|
||||
testDBFile := storage.CreateTestDB()
|
||||
db, myRootToken, err := setupDB(&testDBFile, nil, "")
|
||||
if err != nil {
|
||||
log.Printf("Init error %s", err.Error())
|
||||
}
|
||||
rootToken = myRootToken
|
||||
var cfg Config
|
||||
cfile := "../databunker.yaml"
|
||||
err = readConfFile(&cfg, &cfile)
|
||||
cfg.SelfService.AppRecordChange = []string{"testapp", "super"}
|
||||
if err != nil {
|
||||
cfg.SelfService.ForgetMe = false
|
||||
cfg.SelfService.UserRecordChange = true
|
||||
cfg.Generic.CreateUserWithoutAccessToken = true
|
||||
//cfg.Generic.UseSeparateAppTables = true
|
||||
cfg.Policy.MaxUserRetentionPeriod = "1m"
|
||||
cfg.Policy.MaxAuditRetentionPeriod = "12m"
|
||||
cfg.Policy.MaxSessionRetentionPeriod = "1h"
|
||||
cfg.Policy.MaxShareableRecordRetentionPeriod = "1m"
|
||||
}
|
||||
e = mainEnv{db, cfg, make(chan struct{})}
|
||||
rootToken2, err := e.db.getRootXtoken()
|
||||
if err != nil {
|
||||
log.Printf("Failed to retrieve root token: %s\n", err)
|
||||
}
|
||||
log.Printf("Hashed root token: %s\n", rootToken2)
|
||||
router = e.setupRouter()
|
||||
router = e.setupConfRouter(router)
|
||||
//test1 := &testEnv{e, rootToken, router}
|
||||
e.dbCleanupDo()
|
||||
log.Printf("**INIT*DONE***\n")
|
||||
}
|
||||
Reference in New Issue
Block a user