fixing unit test

This commit is contained in:
Roland Osborne 2024-05-23 22:05:51 -07:00
parent 459732df1d
commit 5bd9d80258
2 changed files with 19 additions and 3 deletions

View File

@ -53,16 +53,24 @@ func TestMain(m *testing.M) {
panic("failed to configure account limit") panic("failed to configure account limit")
} }
// admin login
r, w, _ = NewRequest("PUT", "/admin/access?token=pass", nil);
SetAdminAccess(w, r)
var session string
if ReadResponse(w, &session) != nil {
panic("failed to login as admin")
}
// config server // config server
config := NodeConfig{Domain: "databag.coredb.org", AccountStorage: 4096, KeyType: "RSA2048"} config := NodeConfig{Domain: "databag.coredb.org", AccountStorage: 4096, KeyType: "RSA2048"}
r, w, _ = NewRequest("PUT", "/admin/config?token=pass", &config) r, w, _ = NewRequest("PUT", "/admin/config?token=" + session, &config)
SetNodeConfig(w, r) SetNodeConfig(w, r)
if ReadResponse(w, nil) != nil { if ReadResponse(w, nil) != nil {
panic("failed to set config") panic("failed to set config")
} }
// check config // check config
r, w, _ = NewRequest("GET", "/admin/config?token=pass", nil) r, w, _ = NewRequest("GET", "/admin/config?token=" + session, nil)
GetNodeConfig(w, r) GetNodeConfig(w, r)
var check NodeConfig var check NodeConfig
if ReadResponse(w, &check) != nil { if ReadResponse(w, &check) != nil {

View File

@ -618,8 +618,16 @@ func addTestAccount(username string) (guid string, token string, err error) {
var profile Profile var profile Profile
var login = username + ":pass" var login = username + ":pass"
// admin login
r, w, _ = NewRequest("PUT", "/admin/access?token=pass", nil);
SetAdminAccess(w, r)
var session string
if ReadResponse(w, &session) != nil {
panic("failed to login as admin")
}
// get account token // get account token
if r, w, err = NewRequest("POST", "/admin/accounts?token=pass", nil); err != nil { if r, w, err = NewRequest("POST", "/admin/accounts?token=" + session, nil); err != nil {
return return
} }
AddNodeAccount(w, r) AddNodeAccount(w, r)