fix test files
This commit is contained in:
+8
-4
@@ -42,12 +42,16 @@ func getRSAPublicKey() (*rsa.PublicKey, error) {
|
||||
rsaPublicKeyOnce.Do(func() {
|
||||
log.Print("Loading RSA public key from PEM certificate file")
|
||||
|
||||
// Read PEM file
|
||||
// Read PEM file - use path relative to executable or try both common paths
|
||||
pemData, err := os.ReadFile("rsa/ServerCertificate.pem")
|
||||
if err != nil {
|
||||
rsaPublicKeyError = fmt.Errorf("failed to read PEM file: %w", err)
|
||||
log.Printf("Error reading PEM file: %v", rsaPublicKeyError)
|
||||
return
|
||||
// Try alternate path when running tests from subdirectory
|
||||
pemData, err = os.ReadFile("../rsa/ServerCertificate.pem")
|
||||
if err != nil {
|
||||
rsaPublicKeyError = fmt.Errorf("failed to read PEM file: %w", err)
|
||||
log.Printf("Error reading PEM file: %v", rsaPublicKeyError)
|
||||
return
|
||||
}
|
||||
}
|
||||
log.Print("PEM file successfully read")
|
||||
|
||||
|
||||
@@ -19,6 +19,13 @@ import (
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
os.Setenv("GO_ENV", "development")
|
||||
code := m.Run()
|
||||
os.Unsetenv("GO_ENV")
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
// Test helper to generate RSA key pair and certificate
|
||||
func generateTestRSACertificate(t *testing.T) (privateKey *rsa.PrivateKey, certPEM []byte) {
|
||||
t.Helper()
|
||||
|
||||
Reference in New Issue
Block a user