Skip to content

Commit 15cd090

Browse files
Remove TestGenerateRandomBytes as it's no longer applicable #183
1 parent 9dd6af1 commit 15cd090

File tree

1 file changed

+0
-25
lines changed

1 file changed

+0
-25
lines changed

helpers_test.go

-25
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ package csrf
22

33
import (
44
"bytes"
5-
"crypto/rand"
65
"encoding/base64"
76
"fmt"
8-
"io"
97
"log"
108
"mime/multipart"
119
"net/http"
@@ -201,29 +199,6 @@ func TestXOR(t *testing.T) {
201199
}
202200
}
203201

204-
// shortReader provides a broken implementation of io.Reader for testing.
205-
type shortReader struct{}
206-
207-
func (sr shortReader) Read(p []byte) (int, error) {
208-
return len(p) % 2, io.ErrUnexpectedEOF
209-
}
210-
211-
// TestGenerateRandomBytes tests the (extremely rare) case that crypto/rand does
212-
// not return the expected number of bytes.
213-
func TestGenerateRandomBytes(t *testing.T) {
214-
// Pioneered from https://github.com/justinas/nosurf
215-
original := rand.Reader
216-
rand.Reader = shortReader{}
217-
defer func() {
218-
rand.Reader = original
219-
}()
220-
221-
b, err := generateRandomBytes(tokenLength)
222-
if err == nil {
223-
t.Fatalf("generateRandomBytes did not report a short read: only read %d bytes", len(b))
224-
}
225-
}
226-
227202
func TestTemplateField(t *testing.T) {
228203
s := http.NewServeMux()
229204

0 commit comments

Comments
 (0)