private MockGVFSEnlistment CreateEnlistment(string newConfigValue = null, string oldConfigValue = null) { MockGitProcess gitProcess = new MockGitProcess(); gitProcess.SetExpectedCommandResult( "config --local gvfs.cache-server", () => new GitProcess.Result(newConfigValue ?? string.Empty, string.Empty, newConfigValue != null ? GitProcess.Result.SuccessCode : GitProcess.Result.GenericFailureCode)); gitProcess.SetExpectedCommandResult( "config gvfs.mock:..repourl.cache-server-url", () => new GitProcess.Result(oldConfigValue ?? string.Empty, string.Empty, oldConfigValue != null ? GitProcess.Result.SuccessCode : GitProcess.Result.GenericFailureCode)); return(new MockGVFSEnlistment(gitProcess)); }
public void TryLoadConfigEnforcesMinimumValuesOnTimeout() { MockTracer tracer = new MockTracer(); MockGitProcess gitProcess = new MockGitProcess(); gitProcess.SetExpectedCommandResult("config gvfs.max-retries", () => new GitProcess.Result("3", string.Empty, GitProcess.Result.SuccessCode)); gitProcess.SetExpectedCommandResult("config gvfs.timeout-seconds", () => new GitProcess.Result("-1", string.Empty, GitProcess.Result.SuccessCode)); RetryConfig config; string error; RetryConfig.TryLoadFromGitConfig(tracer, gitProcess, out config, out error).ShouldEqual(false); error.ShouldContain("Invalid value -1 for setting gvfs.timeout-seconds, value must be greater than or equal to 0"); }
public void TryLoadConfigFailsWhenGitFailsToReadConfig() { MockTracer tracer = new MockTracer(); MockGitProcess gitProcess = new MockGitProcess(); gitProcess.SetExpectedCommandResult("config gvfs.max-retries", () => new GitProcess.Result(string.Empty, ReadConfigFailureMessage, GitProcess.Result.GenericFailureCode)); gitProcess.SetExpectedCommandResult("config gvfs.timeout-seconds", () => new GitProcess.Result(string.Empty, ReadConfigFailureMessage, GitProcess.Result.GenericFailureCode)); RetryConfig config; string error; RetryConfig.TryLoadFromGitConfig(tracer, gitProcess, out config, out error).ShouldEqual(false); error.ShouldContain(ReadConfigFailureMessage); }
public void TryLoadConfigUsesDefaultValuesWhenEntriesAreBlank() { MockTracer tracer = new MockTracer(); MockGitProcess gitProcess = new MockGitProcess(); gitProcess.SetExpectedCommandResult("config gvfs.max-retries", () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.SuccessCode)); gitProcess.SetExpectedCommandResult("config gvfs.timeout-seconds", () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.SuccessCode)); RetryConfig config; string error; RetryConfig.TryLoadFromGitConfig(tracer, gitProcess, out config, out error).ShouldEqual(true); error.ShouldEqual(string.Empty); config.MaxRetries.ShouldEqual(RetryConfig.DefaultMaxRetries); config.MaxAttempts.ShouldEqual(config.MaxRetries + 1); config.Timeout.ShouldEqual(TimeSpan.FromSeconds(RetryConfig.DefaultTimeoutSeconds)); }
public void FallsBackToDeprecatedConfigSetting() { MockGitProcess git = new MockGitProcess(); git.SetExpectedCommandResult(@"config gvfs.mock:\repourl.cache-server-url", () => new GitProcess.Result(UserSuppliedUrl, string.Empty, GitProcess.Result.SuccessCode)); git.SetExpectedCommandResult(@"config --local gvfs.cache-server " + UserSuppliedUrl, () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.SuccessCode)); string error; CacheServerInfo output; CacheServerInfo.TryDetermineCacheServer( userUrlish: null, gitProcess: git, enlistment: this.enlistment, knownCaches: null, output: out output, error: out error).ShouldBeTrue(error); output.Url.ShouldEqual(UserSuppliedUrl); }
public void TryLoadConfigUsesConfiguredValues() { int maxRetries = RetryConfig.DefaultMaxRetries + 1; int timeoutSeconds = RetryConfig.DefaultTimeoutSeconds + 1; MockTracer tracer = new MockTracer(); MockGitProcess gitProcess = new MockGitProcess(); gitProcess.SetExpectedCommandResult("config scalar.max-retries", () => new GitProcess.Result(maxRetries.ToString(), string.Empty, GitProcess.Result.SuccessCode)); gitProcess.SetExpectedCommandResult("config scalar.timeout-seconds", () => new GitProcess.Result(timeoutSeconds.ToString(), string.Empty, GitProcess.Result.SuccessCode)); RetryConfig config; string error; RetryConfig.TryLoadFromGitConfig(tracer, gitProcess, out config, out error).ShouldEqual(true); error.ShouldEqual(string.Empty); config.MaxRetries.ShouldEqual(maxRetries); config.MaxAttempts.ShouldEqual(config.MaxRetries + 1); config.Timeout.ShouldEqual(TimeSpan.FromSeconds(timeoutSeconds)); }
private MockGitProcess GetGitProcess() { MockGitProcess gitProcess = new MockGitProcess(); gitProcess.SetExpectedCommandResult("config gvfs.FunctionalTests.UserName", () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.GenericFailureCode)); gitProcess.SetExpectedCommandResult("config gvfs.FunctionalTests.Password", () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.GenericFailureCode)); int revocations = 0; gitProcess.SetExpectedCommandResult( "credential fill", () => new GitProcess.Result("username=username\r\npassword=password" + revocations + "\r\n", string.Empty, GitProcess.Result.SuccessCode)); gitProcess.SetExpectedCommandResult( "credential reject", () => { revocations++; return new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.SuccessCode); }); return gitProcess; }
public void DetectsFailuresInLsTree() { MockTracer tracer = new MockTracer(); MockGitProcess gitProcess = new MockGitProcess(new ConfigurableFileSystem()); gitProcess.SetExpectedCommandResult("ls-tree -r -t sha1", () => new GitProcess.Result(string.Empty, string.Empty, 1)); DiffHelper diffBackwards = new DiffHelper(tracer, new MockEnlistment(), gitProcess, new List <string>(), new List <string>()); diffBackwards.PerformDiff(null, "sha1"); diffBackwards.HasFailures.ShouldEqual(true); }
public void DetectsFailuresInDiffTree() { MockTracer tracer = new MockTracer(); MockGitProcess gitProcess = new MockGitProcess(); gitProcess.SetExpectedCommandResult("diff-tree -r -t sha1 sha2", () => new GitProcess.Result(string.Empty, string.Empty, 1)); DiffHelper diffBackwards = new DiffHelper(tracer, new Mock.Common.MockGVFSEnlistment(), gitProcess, new List <string>(), new List <string>()); diffBackwards.PerformDiff("sha1", "sha2"); diffBackwards.HasFailures.ShouldEqual(true); }
public void DetectsFailuresInLsTree() { MockTracer tracer = new MockTracer(); MockGitProcess gitProcess = new MockGitProcess(); gitProcess.SetExpectedCommandResult("ls-tree -r -t sha1", () => new GitProcess.Result(string.Empty, string.Empty, 1)); DiffHelper diffBackwards = new DiffHelper(tracer, new Mock.Common.MockGSDEnlistment(), gitProcess, new List <string>(), new List <string>(), includeSymLinks: this.IncludeSymLinks); diffBackwards.PerformDiff(null, "sha1"); diffBackwards.HasFailures.ShouldEqual(true); }
private MockGitProcess GetGitProcess() { MockGitProcess gitProcess = new MockGitProcess(); gitProcess.SetExpectedCommandResult("config gvfs.FunctionalTests.UserName", () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.GenericFailureCode)); gitProcess.SetExpectedCommandResult("config gvfs.FunctionalTests.Password", () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.GenericFailureCode)); if (this.sslSettingsPresent) { gitProcess.SetExpectedCommandResult("config --get-urlmatch http mock://repoUrl", () => new GitProcess.Result($"http.sslCert {CertificatePath}\nhttp.sslCertPasswordProtected true\n\n", string.Empty, GitProcess.Result.SuccessCode)); } else { gitProcess.SetExpectedCommandResult("config --get-urlmatch http mock://repoUrl", () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.SuccessCode)); } int revocations = 0; gitProcess.SetExpectedCommandResult( "-c credential.useHttpPath=true credential fill", () => new GitProcess.Result("username=username\r\npassword=password" + revocations + "\r\n", string.Empty, GitProcess.Result.SuccessCode)); gitProcess.SetExpectedCommandResult( "credential reject", () => { revocations++; return(new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.SuccessCode)); }); return(gitProcess); }
public void ParsesConfiguredCacheName() { MockGitProcess git = new MockGitProcess(); git.SetExpectedCommandResult("config gvfs.cache-server", () => new GitProcess.Result(UserSuppliedCacheName, string.Empty, GitProcess.Result.SuccessCode)); string error; CacheServerInfo output; CacheServerInfo.TryDetermineCacheServer( userUrlish: null, gitProcess: git, enlistment: this.enlistment, knownCaches: KnownCaches, output: out output, error: out error).ShouldBeTrue(error); output.Url.ShouldEqual(UserSuppliedUrl); }
public void FallsBackToDefaultCache() { MockGitProcess git = new MockGitProcess(); git.SetExpectedCommandResult(@"config gvfs.mock:\repourl.cache-server-url", () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.GenericFailureCode)); string error; CacheServerInfo output; CacheServerInfo.TryDetermineCacheServer( userUrlish: null, gitProcess: git, enlistment: this.enlistment, knownCaches: KnownCaches, output: out output, error: out error).ShouldBeTrue(error); output.Name.ShouldEqual(DefaultCacheName); }