databag/net/server/internal/new_account_test.go
2022-01-15 00:07:00 -08:00

29 lines
572 B
Go

package databag
import (
"fmt"
"testing"
"net/http/httptest"
"encoding/base64"
"encoding/json"
)
func TestAccount(t *testing.T) {
auth := base64.StdEncoding.EncodeToString([]byte("admin:pass"))
r := httptest.NewRequest("POST", "/admin/accounts", nil)
r.Header.Add("Authorization","Basic " + auth)
w := httptest.NewRecorder()
AddNodeAccount(w, r);
resp := w.Result();
dec := json.NewDecoder(resp.Body);
var token string;
dec.Decode(&token);
if resp.StatusCode != 200 {
t.Errorf("failed to create account")
}
fmt.Println(token);
}