Skip to content

[BUG] TestGenerateRandomBytes panics #183

@NightTsarina

Description

@NightTsarina

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

=== RUN   TestGenerateRandomBytes
fatal error: crypto/rand: failed to read random data (see https://go.dev/issue/66821): unexpected EOF

goroutine 7 [running]:
crypto/rand.fatal({0xc000018120?, 0x85a223?})
        /usr/lib/go-1.24/src/runtime/panic.go:1043 +0x18
crypto/rand.Read({0xc000020320?, 0x20, 0xad91a8?})
        /usr/lib/go-1.24/src/crypto/rand/rand.go:79 +0xfb
github.com/gorilla/csrf.generateRandomBytes(0x20)
        /tmp/buildd/golang-github-gorilla-csrf-1.7.2/_build/src/github.com/gorilla/csrf/helpers.go:145 +0x37
github.com/gorilla/csrf.TestGenerateRandomBytes(0xc0000f8380)
        /tmp/buildd/golang-github-gorilla-csrf-1.7.2/_build/src/github.com/gorilla/csrf/helpers_test.go:224 +0x94
testing.tRunner(0xc0000f8380, 0x861ac0)
        /usr/lib/go-1.24/src/testing/testing.go:1792 +0xf4
created by testing.(*T).Run in goroutine 1
        /usr/lib/go-1.24/src/testing/testing.go:1851 +0x413

goroutine 1 [chan receive]:
testing.(*T).Run(0xc0000f81c0, {0x8478cc?, 0xc0000cfb30?}, 0x861ac0)
        /usr/lib/go-1.24/src/testing/testing.go:1859 +0x431
testing.runTests.func1(0xc0000f81c0)
        /usr/lib/go-1.24/src/testing/testing.go:2279 +0x37
testing.tRunner(0xc0000f81c0, 0xc0000cfc70)
        /usr/lib/go-1.24/src/testing/testing.go:1792 +0xf4
testing.runTests(0xc0000104c8, {0xb94b60, 0x1c, 0x1c}, {0xb9d200?, 0x7?, 0xb9bbc0?})
        /usr/lib/go-1.24/src/testing/testing.go:2277 +0x4b4
testing.(*M).Run(0xc0000d6aa0)
        /usr/lib/go-1.24/src/testing/testing.go:2142 +0x64a
main.main()
        _testmain.go:99 +0x9b
FAIL    github.com/gorilla/csrf 0.005s
FAIL

Expected Behavior

No response

Steps To Reproduce

No response

Anything else?

Since go 1.24 crypto/rand throws a non-recoverable fatal error when it fails to read random data, so this test needs to be disabled.
See https://go.dev/issue/66821

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions