use of org.apache.maven.scm.command.login.LoginScmResult in project maven-scm by apache.
the class AccuRevLoginCommandTest method testWhenNoUserSuppliedAndAlreadyLoggedIn.
@Test
public void testWhenNoUserSuppliedAndAlreadyLoggedIn() throws Exception {
repo.setUser(null);
info.setUser("anyUser");
when(accurev.info(any(File.class))).thenReturn(info);
AccuRevLoginCommand command = new AccuRevLoginCommand(getLogger());
LoginScmResult result = command.login(repo, new ScmFileSet(basedir), new CommandParameters());
assertThat(result.isSuccess(), is(true));
verify(accurev, never()).login(anyString(), anyString());
}
use of org.apache.maven.scm.command.login.LoginScmResult in project maven-scm by apache.
the class AccuRevLoginCommandTest method testFailsWhenNoUserSuppliedAndNotLoggedIn.
@Test
public void testFailsWhenNoUserSuppliedAndNotLoggedIn() throws Exception {
repo.setUser(null);
info.setUser("(not logged in)");
when(accurev.info(any(File.class))).thenReturn(info);
AccuRevLoginCommand command = new AccuRevLoginCommand(getLogger());
LoginScmResult result = command.login(repo, new ScmFileSet(basedir), new CommandParameters());
assertThat(result.isSuccess(), is(false));
verify(accurev, never()).login(anyString(), anyString());
}
use of org.apache.maven.scm.command.login.LoginScmResult in project maven-scm by apache.
the class CvsLoginCommand method executeLoginCommand.
/**
* {@inheritDoc}
*/
public LoginScmResult executeLoginCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
CvsScmProviderRepository repo = (CvsScmProviderRepository) repository;
if (!"pserver".equals(repo.getTransport())) {
return new LoginScmResult(null, "The cvs login ignored for " + repo.getTransport() + ".", "", true);
} else if (isCvsNT()) {
// We don't continue becauseCVSNT doesn't use .cvspass
return new LoginScmResult(null, "The cvs login ignored for CVSNT.", "", true);
}
CvsPass passGenerator = new CvsPass(getLogger());
passGenerator.setCvsroot(repo.getCvsRootForCvsPass());
passGenerator.setPassword(repo.getPassword());
try {
passGenerator.execute();
} catch (IOException e) {
throw new ScmException("Error while executing cvs login command.", e);
}
return new LoginScmResult(null, "The cvs command succeed.", "", true);
}
use of org.apache.maven.scm.command.login.LoginScmResult in project maven-scm by apache.
the class IntegrityLoginCommand method executeLoginCommand.
/**
* {@inheritDoc}
*/
@Override
public LoginScmResult executeLoginCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
getLogger().info("Attempting to connect with the MKS Integrity Server");
LoginScmResult result;
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
APISession api = iRepo.getAPISession();
try {
// First we will establish a connection to the MKS Integrity Server
Response res = api.connect(iRepo.getHost(), iRepo.getPort(), iRepo.getUser(), iRepo.getPassword());
int exitCode = res.getExitCode();
boolean success = (exitCode == 0 ? true : false);
result = new LoginScmResult(res.getCommandString(), "", "Exit Code: " + exitCode, success);
// Next we will prepare the Project and Sandbox for the other commands
Project siProject = new Project(api, iRepo.getConfigruationPath());
Sandbox siSandbox = new Sandbox(api, siProject, fileSet.getBasedir().getAbsolutePath());
iRepo.setProject(siProject);
iRepo.setSandbox(siSandbox);
} catch (APIException aex) {
ExceptionHandler eh = new ExceptionHandler(aex);
getLogger().error("MKS API Exception: " + eh.getMessage());
getLogger().info(eh.getCommand() + " exited with return code " + eh.getExitCode());
result = new LoginScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
}
return result;
}
use of org.apache.maven.scm.command.login.LoginScmResult in project maven-scm by apache.
the class AccuRevLoginCommand method executeAccurevCommand.
@Override
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
boolean result = false;
AccuRev accurev = repository.getAccuRev();
AccuRevInfo info = accurev.info(null);
String providerMessage = "";
if (info == null) {
providerMessage = "Unable to retrieve accurev info";
} else if (repository.getUser() != null) {
// Check if we've already logged in as this user
result = repository.getUser().equals(info.getUser());
if (result) {
providerMessage = "Skipping login - already logged in as " + repository.getUser();
} else {
result = accurev.login(repository.getUser(), repository.getPassword());
providerMessage = (result ? "Success" : "Failure") + " logging in as " + repository.getUser();
}
} else {
result = info.isLoggedIn();
providerMessage = result ? ("Logged in externally as " + info.getUser()) : "Not logged in";
}
getLogger().debug(providerMessage);
return new LoginScmResult(accurev.getCommandLines(), providerMessage, accurev.getErrorOutput(), result);
}
Aggregations