From 9eb088daec94eca021adcc8c9cb08cb51771d632 Mon Sep 17 00:00:00 2001 From: Taylor Bantle Date: Tue, 21 Mar 2023 13:03:34 -0700 Subject: [PATCH] Add auth to dolt pull --- go/cmd/dolt/cli/arg_parser_helpers.go | 1 + go/cmd/dolt/commands/pull.go | 2 ++ integration-tests/bats/sql-server-remotesrv.bats | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/go/cmd/dolt/cli/arg_parser_helpers.go b/go/cmd/dolt/cli/arg_parser_helpers.go index 2470cd331e..2bdeac559d 100644 --- a/go/cmd/dolt/cli/arg_parser_helpers.go +++ b/go/cmd/dolt/cli/arg_parser_helpers.go @@ -256,6 +256,7 @@ func CreatePullArgParser() *argparser.ArgParser { ap.SupportsFlag(CommitFlag, "", "Perform the merge and commit the result. This is the default option, but can be overridden with the --no-commit flag. Note that this option does not affect fast-forward merges, which don't create a new merge commit, and if any merge conflicts or constraint violations are detected, no commit will be attempted.") ap.SupportsFlag(NoCommitFlag, "", "Perform the merge and stop just before creating a merge commit. Note this will not prevent a fast-forward merge; use the --no-ff arg together with the --no-commit arg to prevent both fast-forwards and merge commits.") ap.SupportsFlag(NoEditFlag, "", "Use an auto-generated commit message when creating a merge commit. The default for interactive CLI sessions is to open an editor.") + ap.SupportsString(UserParam, "u", "user", "User name to use when authenticating with the remote. Gets password from the environment variable {{.EmphasisLeft}}DOLT_REMOTE_PASSWORD{{.EmphasisRight}}.") return ap } diff --git a/go/cmd/dolt/commands/pull.go b/go/cmd/dolt/commands/pull.go index 8404f6c60d..8b5cb8ee9f 100644 --- a/go/cmd/dolt/commands/pull.go +++ b/go/cmd/dolt/commands/pull.go @@ -91,6 +91,8 @@ func (cmd PullCmd) Exec(ctx context.Context, commandStr string, args []string, d return HandleVErrAndExitCode(errhand.VerboseErrorFromError(env.ErrActiveServerLock.New(dEnv.LockFile())), help) } + dEnv.UserPassConfig = getUserAndPassConfig(apr) + pullSpec, err := env.NewPullSpec(ctx, dEnv.RepoStateReader(), remoteName, remoteRefName, apr.Contains(cli.SquashParam), apr.Contains(cli.NoFFParam), apr.Contains(cli.NoCommitFlag), apr.Contains(cli.NoEditFlag), apr.Contains(cli.ForceFlag), apr.NArg() == 1) if err != nil { return HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage) diff --git a/integration-tests/bats/sql-server-remotesrv.bats b/integration-tests/bats/sql-server-remotesrv.bats index 26cb3bf351..0f6cc014c5 100644 --- a/integration-tests/bats/sql-server-remotesrv.bats +++ b/integration-tests/bats/sql-server-remotesrv.bats @@ -186,10 +186,16 @@ insert into vals (i) values (6), (7), (8), (9), (10); call dolt_commit('-am', 'add some vals'); SQL - # TODO: Add auth to dolt pull + # No auth run dolt pull [[ "$status" != 0 ]] || false [[ "$output" =~ "Unauthenticated" ]] || false + + # With auth + run dolt pull -u $DOLT_REMOTE_USER + [[ "$status" -eq 0 ]] || false + run dolt sql -q 'select count(*) from vals;' + [[ "$output" =~ "10" ]] || false } @test "sql-server-remotesrv: dolt clone without authentication errors" {