From 99baa47c99a51862bbcdbf345b69994a06d227ae Mon Sep 17 00:00:00 2001 From: Jiri Podivin Date: Wed, 4 Oct 2023 14:09:39 +0200 Subject: [PATCH] Adding specialized utility function for genereting mock ssh secrets These secrets are used in a considerable number of tests. Implementing separate function for generating them in each repo is suboptimal. Signed-off-by: Jiri Podivin --- modules/common/test/helpers/secret.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/common/test/helpers/secret.go b/modules/common/test/helpers/secret.go index 04e24495..de0b9fa4 100644 --- a/modules/common/test/helpers/secret.go +++ b/modules/common/test/helpers/secret.go @@ -65,6 +65,15 @@ func (tc *TestHelper) CreateEmptySecret(name types.NamespacedName) *corev1.Secre return tc.CreateSecret(name, map[string][]byte{}) } +// CreateSSHSecret creates new secret containing mock "ssh-privatekey" +// +// Example usage: +// +// sshSecret := th.CreateSSHSecret(types.NamespacedName{Name: "test-ssh-secret", Namespace: "test-namespace"}) +func (tc *TestHelper) CreateSSHSecret(name types.NamespacedName) *corev1.Secret { + return tc.CreateSecret(name, map[string][]byte{"ssh-privatekey": []byte("foo")}) +} + // DeleteSecret deletes a Secret resource // // Example usage: