mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
+7![github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)





![dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)



Kanika Rana
GitHub
Alexandre Gaudreault
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Pasha Kostohrys
pasha
Regina Voloshin
Shubham Singh
shubham singh mahar
github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
CI
Josh Soref
argoproj-renovate[bot] <161757507+argoproj-renovate[bot]@users.noreply.github.com>
Jakub Rudnik
Illia Oleksiuk
Aya Hosni
Nitish Kumar
7e0f8b86ac
Signed-off-by: Alexandre Gaudreault <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: reggie-k <[email protected]> Signed-off-by: shubham singh mahar <[email protected]> Signed-off-by: CI <[email protected]> Signed-off-by: Josh Soref <[email protected]> Signed-off-by: renovate[bot] <renovate[bot]@users.noreply.github.com> Signed-off-by: Jakub Rudnik <[email protected]> Signed-off-by: ioleksiuk <[email protected]> Signed-off-by: Illia Oleksiuk <[email protected]> Signed-off-by: Aya <[email protected]> Co-authored-by: Alexandre Gaudreault <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Pasha Kostohrys <[email protected]> Co-authored-by: pasha <[email protected]> Co-authored-by: Regina Voloshin <[email protected]> Co-authored-by: Shubham Singh <[email protected]> Co-authored-by: shubham singh mahar <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: CI <[email protected]> Co-authored-by: Josh Soref <[email protected]> Co-authored-by: argoproj-renovate[bot] <161757507+argoproj-renovate[bot]@users.noreply.github.com> Co-authored-by: Jakub Rudnik <[email protected]> Co-authored-by: Illia Oleksiuk <[email protected]> Co-authored-by: Aya Hosni <[email protected]> Co-authored-by: Nitish Kumar <[email protected]>
68 lines
2.6 KiB
Go
68 lines
2.6 KiB
Go
package certs
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/argoproj/argo-cd/v3/test/e2e/fixture"
|
|
"github.com/argoproj/argo-cd/v3/util/errors"
|
|
)
|
|
|
|
// Add a custom CA certificate to the test and also create the certificate file
|
|
// on the file system, so argocd-server and argocd-repo-server can use it.
|
|
// TODO: Should be moved to the EnsureCleanState since this acts on the controller
|
|
// globally https://github.com/argoproj/argo-cd/issues/24307
|
|
func AddCustomCACert(t *testing.T) {
|
|
t.Helper()
|
|
caCertPath, err := filepath.Abs("../fixture/certs/argocd-test-ca.crt")
|
|
require.NoError(t, err)
|
|
// We need to setup TLS certs according to whether we are running tests
|
|
// against a local workload (repositories available as localhost) and
|
|
// against remote workloads (repositories available as argocd-e2e-server)
|
|
if fixture.IsLocal() {
|
|
args := []string{"cert", "add-tls", "localhost", "--upsert", "--from", caCertPath}
|
|
errors.NewHandler(t).FailOnErr(fixture.RunCli(args...))
|
|
args = []string{"cert", "add-tls", "127.0.0.1", "--upsert", "--from", caCertPath}
|
|
errors.NewHandler(t).FailOnErr(fixture.RunCli(args...))
|
|
certData, err := os.ReadFile(caCertPath)
|
|
require.NoError(t, err)
|
|
err = os.WriteFile(fixture.TmpDir()+"/app/config/tls/localhost", certData, 0o644)
|
|
require.NoError(t, err)
|
|
err = os.WriteFile(fixture.TmpDir()+"/app/config/tls/127.0.0.1", certData, 0o644)
|
|
require.NoError(t, err)
|
|
} else {
|
|
args := []string{"cert", "add-tls", "argocd-e2e-server", "--upsert", "--from", caCertPath}
|
|
errors.NewHandler(t).FailOnErr(fixture.RunCli(args...))
|
|
fixture.RestartAPIServer(t)
|
|
fixture.RestartRepoServer(t)
|
|
}
|
|
}
|
|
|
|
// AddCustomSSHKnownHostsKeys adds SSH known hosts data to the Argo CD server
|
|
// being tested against. The env ARGOCD_E2E_SSH_KNOWN_HOSTS lets you specify
|
|
// an optional path to the known hosts file, instead of using the default one.
|
|
func AddCustomSSHKnownHostsKeys(t *testing.T) {
|
|
t.Helper()
|
|
source := os.Getenv("ARGOCD_E2E_SSH_KNOWN_HOSTS")
|
|
if source == "" {
|
|
source = "../fixture/testrepos/ssh_known_hosts"
|
|
}
|
|
knownHostsPath, err := filepath.Abs(source)
|
|
require.NoError(t, err)
|
|
args := []string{"cert", "add-ssh", "--upsert", "--batch", "--from", knownHostsPath}
|
|
errors.NewHandler(t).FailOnErr(fixture.RunCli(args...))
|
|
|
|
if fixture.IsLocal() {
|
|
knownHostsData, err := os.ReadFile(knownHostsPath)
|
|
require.NoError(t, err)
|
|
err = os.WriteFile(fixture.TmpDir()+"/app/config/ssh/ssh_known_hosts", knownHostsData, 0o644)
|
|
require.NoError(t, err)
|
|
} else {
|
|
fixture.RestartAPIServer(t)
|
|
fixture.RestartRepoServer(t)
|
|
}
|
|
}
|