diff --git a/helpers_test.go b/helpers_test.go index f40c996..69dfbce 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -2,10 +2,8 @@ package csrf import ( "bytes" - "crypto/rand" "encoding/base64" "fmt" - "io" "log" "mime/multipart" "net/http" @@ -201,29 +199,6 @@ func TestXOR(t *testing.T) { } } -// shortReader provides a broken implementation of io.Reader for testing. -type shortReader struct{} - -func (sr shortReader) Read(p []byte) (int, error) { - return len(p) % 2, io.ErrUnexpectedEOF -} - -// TestGenerateRandomBytes tests the (extremely rare) case that crypto/rand does -// not return the expected number of bytes. -func TestGenerateRandomBytes(t *testing.T) { - // Pioneered from https://github.com/justinas/nosurf - original := rand.Reader - rand.Reader = shortReader{} - defer func() { - rand.Reader = original - }() - - b, err := generateRandomBytes(tokenLength) - if err == nil { - t.Fatalf("generateRandomBytes did not report a short read: only read %d bytes", len(b)) - } -} - func TestTemplateField(t *testing.T) { s := http.NewServeMux()