mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
api: store token cookie, tests
This commit is contained in:
26
api/api_test.go
Normal file
26
api/api_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// testHTTPServer creates a test HTTP server that handles requests until
|
||||
// the listener returned is closed.
|
||||
func testHTTPServer(
|
||||
t *testing.T, handler http.Handler) (Config, net.Listener) {
|
||||
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
server := &http.Server{Handler: handler}
|
||||
go server.Serve(ln)
|
||||
|
||||
config := DefaultConfig()
|
||||
config.Address = fmt.Sprintf("http://%s", ln.Addr())
|
||||
|
||||
return config, ln
|
||||
}
|
||||
Reference in New Issue
Block a user