2023-03-15 16:00:52 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2015-04-20 18:59:24 +00:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
2018-08-27 17:01:07 +00:00
|
|
|
"encoding/json"
|
2015-04-20 18:59:24 +00:00
|
|
|
"net/http"
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
2020-12-12 00:50:19 +00:00
|
|
|
"time"
|
2015-04-20 18:59:24 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/vault/vault"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSysLeader_get(t *testing.T) {
|
|
|
|
core, _, _ := vault.TestCoreUnsealed(t)
|
|
|
|
ln, addr := TestServer(t, core)
|
|
|
|
defer ln.Close()
|
|
|
|
|
|
|
|
resp, err := http.Get(addr + "/v1/sys/leader")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var actual map[string]interface{}
|
|
|
|
expected := map[string]interface{}{
|
2018-08-27 17:01:07 +00:00
|
|
|
"ha_enabled": false,
|
|
|
|
"is_self": false,
|
|
|
|
"leader_address": "",
|
|
|
|
"leader_cluster_address": "",
|
|
|
|
"performance_standby": false,
|
|
|
|
"performance_standby_last_remote_wal": json.Number("0"),
|
2020-12-12 00:50:19 +00:00
|
|
|
"active_time": time.Time{}.UTC().Format(time.RFC3339),
|
2015-04-20 18:59:24 +00:00
|
|
|
}
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
testResponseBody(t, resp, &actual)
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
2020-12-12 00:50:19 +00:00
|
|
|
t.Fatalf("bad: %#v \n%#v", actual, expected)
|
2015-04-20 18:59:24 +00:00
|
|
|
}
|
|
|
|
}
|