use of com.google.copybara.git.GitCredential.UserPassword in project copybara by google.
the class GitOriginTest method testCredentials.
@Test
public void testCredentials() throws Exception {
Path credentialsFile = Files.createTempFile("credentials", "test");
Files.write(credentialsFile, "https://user:SECRET@somehost.com".getBytes(UTF_8));
options.git.credentialHelperStorePath = credentialsFile.toString();
GitRepository repository = origin().getRepository();
UserPassword result = repository.credentialFill("https://somehost.com/foo/bar");
assertThat(result.getUsername()).isEqualTo("user");
assertThat(result.getPassword_BeCareful()).isEqualTo("SECRET");
}
use of com.google.copybara.git.GitCredential.UserPassword in project copybara by google.
the class GitCredentialTest method testSuccess.
@Test
public void testSuccess() throws Exception {
Files.write(credentialsFile, "https://user:SECRET@somehost.com".getBytes(UTF_8));
TestLogHandler handler = new TestLogHandler();
Logger.getGlobal().getParent().addHandler(handler);
UserPassword result;
try {
result = credential.fill(repoGitDir, "https://somehost.com/foo/bar");
} finally {
Logger.getGlobal().getParent().removeHandler(handler);
}
assertThat(result.getUsername()).isEqualTo("user");
assertThat(result.getPassword_BeCareful()).isEqualTo("SECRET");
assertThat(result.toString()).doesNotContain("SECRET");
assertThat(Iterables.transform(handler.getStoredLogRecords(), LogRecord::getMessage)).doesNotContain("SECRET");
}
use of com.google.copybara.git.GitCredential.UserPassword in project copybara by google.
the class GitDestinationTest method checkCredentials.
private GitRepository checkCredentials() throws IOException, RepoException, ValidationException {
Path credentialsFile = Files.createTempFile("credentials", "test");
Files.write(credentialsFile, "https://user:SECRET@somehost.com".getBytes(UTF_8));
options.git.credentialHelperStorePath = credentialsFile.toString();
GitRepository repository = destinationFirstCommit().getLocalRepo().load(console);
UserPassword result = repository.credentialFill("https://somehost.com/foo/bar");
assertThat(result.getUsername()).isEqualTo("user");
assertThat(result.getPassword_BeCareful()).isEqualTo("SECRET");
return repository;
}
use of com.google.copybara.git.GitCredential.UserPassword in project copybara by google.
the class GitMirrorTest method testMirrorCredentials.
@Test
public void testMirrorCredentials() throws Exception {
Path credentialsFile = Files.createTempFile("credentials", "test");
Files.write(credentialsFile, "https://user:SECRET@somehost.com".getBytes(UTF_8));
options.git.credentialHelperStorePath = credentialsFile.toString();
String cfg = "" + "git.mirror(" + " name = 'default'," + " origin = 'file://" + originRepo.getGitDir().toAbsolutePath() + "'," + " destination = 'file://" + destRepo.getGitDir().toAbsolutePath() + "'," + ")\n" + "";
GitRepository repository = ((Mirror) loadMigration(cfg, "default")).getLocalRepo();
UserPassword result = repository.credentialFill("https://somehost.com/foo/bar");
assertThat(result.getUsername()).isEqualTo("user");
assertThat(result.getPassword_BeCareful()).isEqualTo("SECRET");
}
Aggregations