fup: add test for disabled TokenAuthMiddleware
This commit is contained in:
parent
affe252f73
commit
7b5ac688b8
1 changed files with 25 additions and 0 deletions
|
@ -10,6 +10,31 @@ import (
|
||||||
"hg.lukegb.com/lukegb/depot/web/fup/fuphttp"
|
"hg.lukegb.com/lukegb/depot/web/fup/fuphttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestTokenAuthMiddlewareNoToken(t *testing.T) {
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
t.Cleanup(cancel)
|
||||||
|
|
||||||
|
ccfg := *cfg
|
||||||
|
ccfg.AuthMiddleware = fuphttp.TokenAuthMiddleware("", "realm")
|
||||||
|
|
||||||
|
a, err := fuphttp.New(ctx, &ccfg)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("fuphttp.New: %v", err)
|
||||||
|
}
|
||||||
|
s := httptest.NewServer(a.Handler())
|
||||||
|
t.Cleanup(s.Close)
|
||||||
|
|
||||||
|
resp, err := s.Client().Get(s.URL)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Get(%q): %v", s.URL, err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
t.Errorf("status code was %v; want %v", resp.StatusCode, http.StatusOK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestTokenAuthMiddleware(t *testing.T) {
|
func TestTokenAuthMiddleware(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
t.Cleanup(cancel)
|
t.Cleanup(cancel)
|
||||||
|
|
Loading…
Reference in a new issue