Add testlib.RandBytes() helper.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer 2021-06-30 10:50:22 -05:00
parent 674cd4a88c
commit 6b801056b5
No known key found for this signature in database
GPG Key ID: EAE88AD172C5AE2D

View File

@ -311,11 +311,15 @@ func CreateTestFederationDomain(ctx context.Context, t *testing.T, issuer string
return federationDomain
}
func RandHex(t *testing.T, numBytes int) string {
func RandBytes(t *testing.T, numBytes int) []byte {
buf := make([]byte, numBytes)
_, err := io.ReadFull(rand.Reader, buf)
require.NoError(t, err)
return hex.EncodeToString(buf)
return buf
}
func RandHex(t *testing.T, numBytes int) string {
return hex.EncodeToString(RandBytes(t, numBytes))
}
func CreateTestSecret(t *testing.T, namespace string, baseName string, secretType corev1.SecretType, stringData map[string]string) *corev1.Secret {