TestTransitImport: Generate Transit wrapping key with a longer context (#24212)

- Instead of relying on the initial call to import to generate the
   wrapping key, generate it within the test setup with a longer
   dedicated timeout.
 - This hopefully is enough of a timeout for the 32 bit nightly runner
This commit is contained in:
Steven Clark 2023-11-21 10:58:44 -05:00 committed by GitHub
parent 66b3e439d8
commit 68fbb17b9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,11 +5,13 @@ package command
import (
"bytes"
"context"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/base64"
"testing"
"time"
"github.com/hashicorp/vault/api"
@ -29,6 +31,15 @@ func TestTransitImport(t *testing.T) {
t.Fatalf("transit mount error: %#v", err)
}
// Force the generation of the Transit wrapping key now with a longer context
// to help the 32bit nightly tests. This creates a 4096-bit RSA key which can take
// a while on an overloaded system
genWrappingKeyCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
if _, err := client.Logical().ReadWithContext(genWrappingKeyCtx, "transit/wrapping_key"); err != nil {
t.Fatalf("transit failed generating wrapping key: %#v", err)
}
rsa1, rsa2, aes128, aes256 := generateKeys(t)
type testCase struct {