From 3c0cba0ed52968fe47a659b9af725a5f1db97ff4 Mon Sep 17 00:00:00 2001 From: Joe Bowbeer Date: Sun, 9 May 2021 22:14:25 -0700 Subject: [PATCH 1/2] fix: copy github app key from repocreds Fixes #6196 Signed-off-by: Joe Bowbeer --- util/db/repository.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/util/db/repository.go b/util/db/repository.go index 0676af9713f53..b191e01fd7ead 100644 --- a/util/db/repository.go +++ b/util/db/repository.go @@ -205,11 +205,12 @@ func (db *db) credentialsToRepositoryCredentials(repoInfo settings.RepositoryCre EnableOCI: repoInfo.EnableOCI, } err := db.unmarshalFromSecretsStr(map[*SecretMaperValidation]*apiv1.SecretKeySelector{ - &SecretMaperValidation{Dest: &creds.Username}: repoInfo.UsernameSecret, - &SecretMaperValidation{Dest: &creds.Password}: repoInfo.PasswordSecret, - &SecretMaperValidation{Dest: &creds.SSHPrivateKey}: repoInfo.SSHPrivateKeySecret, - &SecretMaperValidation{Dest: &creds.TLSClientCertData}: repoInfo.TLSClientCertDataSecret, - &SecretMaperValidation{Dest: &creds.TLSClientCertKey}: repoInfo.TLSClientCertKeySecret, + &SecretMaperValidation{Dest: &creds.Username}: repoInfo.UsernameSecret, + &SecretMaperValidation{Dest: &creds.Password}: repoInfo.PasswordSecret, + &SecretMaperValidation{Dest: &creds.SSHPrivateKey}: repoInfo.SSHPrivateKeySecret, + &SecretMaperValidation{Dest: &creds.TLSClientCertData}: repoInfo.TLSClientCertDataSecret, + &SecretMaperValidation{Dest: &creds.TLSClientCertKey}: repoInfo.TLSClientCertKeySecret, + &SecretMaperValidation{Dest: &creds.GithubAppPrivateKey}: repoInfo.GithubAppPrivateKeySecret, }, make(map[string]*apiv1.Secret)) return creds, err } From daca7e6b93e8abea1ae07de10d1688b5d9a53da5 Mon Sep 17 00:00:00 2001 From: Joe Bowbeer Date: Mon, 10 May 2021 19:36:01 -0700 Subject: [PATCH 2/2] Add GitHub App to unit test Signed-off-by: Joe Bowbeer --- util/db/db_test.go | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/util/db/db_test.go b/util/db/db_test.go index 0a13e0245d16a..904d451bf0159 100644 --- a/util/db/db_test.go +++ b/util/db/db_test.go @@ -381,6 +381,15 @@ func TestRepositorySecretsTrim(t *testing.T) { sshPrivateKeySecret: name: managed-secret key: sshPrivateKey + tlsClientCertDataSecret: + name: managed-secret + key: tlsClientCertData + tlsClientCertKeySecret: + name: managed-secret + key: tlsClientCertKey + githubAppPrivateKeySecret: + name: managed-secret + key: githubAppPrivateKey `} clientset := getClientset(config, &v1.Secret{ ObjectMeta: metav1.ObjectMeta{ @@ -391,9 +400,12 @@ func TestRepositorySecretsTrim(t *testing.T) { }, }, Data: map[string][]byte{ - username: []byte("test-username\n\n"), - password: []byte("test-password\r\r"), - sshPrivateKey: []byte("test-ssh-private-key\n\r"), + username: []byte("test-username\n\n"), + password: []byte("test-password\r\r"), + sshPrivateKey: []byte("test-ssh-private-key\n\r"), + tlsClientCertData: []byte("test-tls-client-cert-data\n\r"), + tlsClientCertKey: []byte("test-tls-client-cert-key\n\r"), + githubAppPrivateKey: []byte("test-github-app-private-key\n\r"), }, }) db := NewDB(testNamespace, settings.NewSettingsManager(context.Background(), clientset, testNamespace), clientset) @@ -416,6 +428,18 @@ func TestRepositorySecretsTrim(t *testing.T) { "test-ssh-private-key", repo.SSHPrivateKey, }, + { + "test-tls-client-cert-data", + repo.TLSClientCertData, + }, + { + "test-tls-client-cert-key", + repo.TLSClientCertKey, + }, + { + "test-github-app-private-key", + repo.GithubAppPrivateKey, + }, } for _, tt := range teststruct { assert.Equal(t, tt.expectedSecret, tt.retrievedSecret)