Add a library.RandHex() test helper.
Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
parent
4088793cc5
commit
ad5e257600
@ -234,7 +234,7 @@ func CreateTestOIDCProvider(ctx context.Context, t *testing.T, issuer string, ce
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
if issuer == "" {
|
if issuer == "" {
|
||||||
issuer = randomIssuer(t)
|
issuer = fmt.Sprintf("http://test-issuer-%s.pinniped.dev", RandHex(t, 8))
|
||||||
}
|
}
|
||||||
|
|
||||||
opcs := NewSupervisorClientset(t).ConfigV1alpha1().OIDCProviders(testEnv.SupervisorNamespace)
|
opcs := NewSupervisorClientset(t).ConfigV1alpha1().OIDCProviders(testEnv.SupervisorNamespace)
|
||||||
@ -279,11 +279,11 @@ func CreateTestOIDCProvider(ctx context.Context, t *testing.T, issuer string, ce
|
|||||||
return opc
|
return opc
|
||||||
}
|
}
|
||||||
|
|
||||||
func randomIssuer(t *testing.T) string {
|
func RandHex(t *testing.T, numBytes int) string {
|
||||||
var buf [8]byte
|
buf := make([]byte, numBytes)
|
||||||
_, err := io.ReadFull(rand.Reader, buf[:])
|
_, err := io.ReadFull(rand.Reader, buf)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
return fmt.Sprintf("http://test-issuer-%s.pinniped.dev", hex.EncodeToString(buf[:]))
|
return hex.EncodeToString(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateTestSecret(t *testing.T, namespace string, baseName string, secretType string, stringData map[string]string) *corev1.Secret {
|
func CreateTestSecret(t *testing.T, namespace string, baseName string, secretType string, stringData map[string]string) *corev1.Secret {
|
||||||
|
Loading…
Reference in New Issue
Block a user