auth_test.go (AdGuardHome-0.104.1) | : | auth_test.go (AdGuardHome-0.104.3) | ||
---|---|---|---|---|
skipping to change at line 12 | skipping to change at line 12 | |||
import ( | import ( | |||
"encoding/hex" | "encoding/hex" | |||
"net/http" | "net/http" | |||
"net/url" | "net/url" | |||
"os" | "os" | |||
"path/filepath" | "path/filepath" | |||
"testing" | "testing" | |||
"time" | "time" | |||
"github.com/AdguardTeam/AdGuardHome/internal/testutil" | ||||
"github.com/stretchr/testify/assert" | "github.com/stretchr/testify/assert" | |||
) | ) | |||
func TestMain(m *testing.M) { | ||||
testutil.DiscardLogOutput(m) | ||||
} | ||||
func prepareTestDir() string { | func prepareTestDir() string { | |||
const dir = "./agh-test" | const dir = "./agh-test" | |||
_ = os.RemoveAll(dir) | _ = os.RemoveAll(dir) | |||
_ = os.MkdirAll(dir, 0755) | _ = os.MkdirAll(dir, 0755) | |||
return dir | return dir | |||
} | } | |||
func TestAuth(t *testing.T) { | func TestAuth(t *testing.T) { | |||
dir := prepareTestDir() | dir := prepareTestDir() | |||
defer func() { _ = os.RemoveAll(dir) }() | defer func() { _ = os.RemoveAll(dir) }() | |||
skipping to change at line 88 | skipping to change at line 93 | |||
// implements http.ResponseWriter | // implements http.ResponseWriter | |||
type testResponseWriter struct { | type testResponseWriter struct { | |||
hdr http.Header | hdr http.Header | |||
statusCode int | statusCode int | |||
} | } | |||
func (w *testResponseWriter) Header() http.Header { | func (w *testResponseWriter) Header() http.Header { | |||
return w.hdr | return w.hdr | |||
} | } | |||
func (w *testResponseWriter) Write([]byte) (int, error) { | func (w *testResponseWriter) Write([]byte) (int, error) { | |||
return 0, nil | return 0, nil | |||
} | } | |||
func (w *testResponseWriter) WriteHeader(statusCode int) { | func (w *testResponseWriter) WriteHeader(statusCode int) { | |||
w.statusCode = statusCode | w.statusCode = statusCode | |||
} | } | |||
func TestAuthHTTP(t *testing.T) { | func TestAuthHTTP(t *testing.T) { | |||
dir := prepareTestDir() | dir := prepareTestDir() | |||
defer func() { _ = os.RemoveAll(dir) }() | defer func() { _ = os.RemoveAll(dir) }() | |||
fn := filepath.Join(dir, "sessions.db") | fn := filepath.Join(dir, "sessions.db") | |||
users := []User{ | users := []User{ | |||
End of changes. 4 change blocks. | ||||
0 lines changed or deleted | 7 lines changed or added |