mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
http: make TestServer public
This commit is contained in:
25
http/testing.go
Normal file
25
http/testing.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/vault"
|
||||
)
|
||||
|
||||
func TestServer(t *testing.T, core *vault.Core) (net.Listener, string) {
|
||||
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
addr := "http://" + ln.Addr().String()
|
||||
|
||||
server := &http.Server{
|
||||
Addr: ln.Addr().String(),
|
||||
Handler: Handler(core),
|
||||
}
|
||||
go server.Serve(ln)
|
||||
|
||||
return ln, addr
|
||||
}
|
||||
Reference in New Issue
Block a user