@@ -3,6 +3,8 @@ package auth_test
33import (
44 "context"
55 "crypto/ed25519"
6+ "crypto/rand"
7+ "encoding/hex"
68 "encoding/json"
79 "fmt"
810 "net/http"
@@ -26,11 +28,12 @@ const (
2628
2729func TestGitHubHandler_ExchangeToken (t * testing.T ) {
2830 // Create test handler with mock config
29- _ , testPrivateKey , err := ed25519 .GenerateKey (nil )
31+ testSeed := make ([]byte , ed25519 .SeedSize )
32+ _ , err := rand .Read (testSeed )
3033 require .NoError (t , err )
3134
3235 cfg := & config.Config {
33- JWTPrivateKey : string ( testPrivateKey ),
36+ JWTPrivateKey : hex . EncodeToString ( testSeed ),
3437 }
3538
3639 t .Run ("successful token exchange with user only" , func (t * testing.T ) {
@@ -316,11 +319,12 @@ func TestGitHubHandler_ExchangeToken(t *testing.T) {
316319}
317320
318321func TestJWTTokenValidation (t * testing.T ) {
319- _ , testPrivateKey , err := ed25519 .GenerateKey (nil )
322+ testSeed := make ([]byte , ed25519 .SeedSize )
323+ _ , err := rand .Read (testSeed )
320324 require .NoError (t , err )
321325
322326 cfg := & config.Config {
323- JWTPrivateKey : string ( testPrivateKey ),
327+ JWTPrivateKey : hex . EncodeToString ( testSeed ),
324328 }
325329
326330 jwtManager := auth .NewJWTManager (cfg )
@@ -395,11 +399,12 @@ func TestJWTTokenValidation(t *testing.T) {
395399}
396400
397401func TestPermissionResourceMatching (t * testing.T ) {
398- _ , testPrivateKey , err := ed25519 .GenerateKey (nil )
402+ testSeed := make ([]byte , ed25519 .SeedSize )
403+ _ , err := rand .Read (testSeed )
399404 require .NoError (t , err )
400405
401406 cfg := & config.Config {
402- JWTPrivateKey : string ( testPrivateKey ),
407+ JWTPrivateKey : hex . EncodeToString ( testSeed ),
403408 }
404409
405410 jwtManager := auth .NewJWTManager (cfg )
@@ -465,11 +470,12 @@ func TestPermissionResourceMatching(t *testing.T) {
465470
466471func TestValidGitHubNames (t * testing.T ) {
467472 // Create a minimal handler to test name validation
468- _ , testPrivateKey , err := ed25519 .GenerateKey (nil )
473+ testSeed := make ([]byte , ed25519 .SeedSize )
474+ _ , err := rand .Read (testSeed )
469475 require .NoError (t , err )
470476
471477 cfg := & config.Config {
472- JWTPrivateKey : string ( testPrivateKey ),
478+ JWTPrivateKey : hex . EncodeToString ( testSeed ),
473479 }
474480
475481 validNameTests := []struct {
@@ -558,11 +564,12 @@ func TestValidGitHubNames(t *testing.T) {
558564}
559565
560566func TestGitHubHandler_Creation (t * testing.T ) {
561- _ , testPrivateKey , err := ed25519 .GenerateKey (nil )
567+ testSeed := make ([]byte , ed25519 .SeedSize )
568+ _ , err := rand .Read (testSeed )
562569 require .NoError (t , err )
563570
564571 cfg := & config.Config {
565- JWTPrivateKey : string ( testPrivateKey ),
572+ JWTPrivateKey : hex . EncodeToString ( testSeed ),
566573 }
567574
568575 handler := v0auth .NewGitHubHandler (cfg )
@@ -571,11 +578,12 @@ func TestGitHubHandler_Creation(t *testing.T) {
571578
572579func TestConcurrentTokenExchange (t * testing.T ) {
573580 // Test that the handler is thread-safe
574- _ , testPrivateKey , err := ed25519 .GenerateKey (nil )
581+ testSeed := make ([]byte , ed25519 .SeedSize )
582+ _ , err := rand .Read (testSeed )
575583 require .NoError (t , err )
576584
577585 cfg := & config.Config {
578- JWTPrivateKey : string ( testPrivateKey ),
586+ JWTPrivateKey : hex . EncodeToString ( testSeed ),
579587 }
580588
581589 // Create mock GitHub API server
0 commit comments