mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 11:39:17 +00:00
29 lines
572 B
Go
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);
|
||
|
}
|