github.com/argoproj/argo-cd/v3@v3.2.1/test/e2e/repo_creds_test.go (about)

     1  package e2e
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/argoproj/argo-cd/v3/test/e2e/fixture"
     7  	. "github.com/argoproj/argo-cd/v3/test/e2e/fixture/app"
     8  	"github.com/argoproj/argo-cd/v3/util/errors"
     9  )
    10  
    11  // make sure you cannot create an app from a private repo without set-up
    12  func TestCannotAddAppFromPrivateRepoWithoutCfg(t *testing.T) {
    13  	Given(t).
    14  		RepoURLType(fixture.RepoURLTypeHTTPS).
    15  		Path(fixture.GuestbookPath).
    16  		When().
    17  		IgnoreErrors().
    18  		CreateApp().
    19  		Then().
    20  		Expect(Error("", "repository not accessible"))
    21  }
    22  
    23  // make sure you cannot create an app from a private repo without set-up
    24  func TestCannotAddAppFromClientCertRepoWithoutCfg(t *testing.T) {
    25  	Given(t).
    26  		RepoURLType(fixture.RepoURLTypeHTTPSClientCert).
    27  		Path(fixture.GuestbookPath).
    28  		When().
    29  		IgnoreErrors().
    30  		CreateApp().
    31  		Then().
    32  		Expect(Error("", "repository not accessible"))
    33  }
    34  
    35  // make sure you can create an app from a private repo, if the repo is set-up
    36  func TestCanAddAppFromPrivateRepoWithRepoCfg(t *testing.T) {
    37  	Given(t).
    38  		RepoURLType(fixture.RepoURLTypeHTTPS).
    39  		Path(fixture.LocalOrRemotePath("https-kustomize-base")).
    40  		And(func() {
    41  			// I use CLI, but you could also modify the settings, we get a free test of the CLI here
    42  			errors.NewHandler(t).FailOnErr(fixture.RunCli("repo", "add", fixture.RepoURL(fixture.RepoURLTypeHTTPS), "--username", fixture.GitUsername, "--password", fixture.GitPassword, "--insecure-skip-server-verification"))
    43  		}).
    44  		When().
    45  		CreateApp().
    46  		Then().
    47  		Expect(Success(""))
    48  }
    49  
    50  // make sure we can create an app from a private repo, in a secure manner using
    51  // a custom CA certificate bundle
    52  func TestCanAddAppFromPrivateRepoWithCredCfg(t *testing.T) {
    53  	Given(t).
    54  		CustomCACertAdded().
    55  		HTTPSCredentialsUserPassAdded().
    56  		HTTPSRepoURLAdded(false).
    57  		RepoURLType(fixture.RepoURLTypeHTTPS).
    58  		Path(fixture.LocalOrRemotePath("https-kustomize-base")).
    59  		When().
    60  		CreateApp().
    61  		Then().
    62  		Expect(Success(""))
    63  }