public void testInvalidAndValidCredentials() throws Exception {
CredentialProperties credentials = getTestFixture().getCredentials();
String invalidUsername = "invalid username";
CloudFoundryOperations client = createClient(new CloudCredentials(invalidUsername, credentials.password),
CloudFoundryTestFixture.CF_PIVOTAL_SERVER_URL_HTTP);
CloudFoundryLoginHandler operationsHandler = new CloudFoundryLoginHandler(client);
CoreException error = null;
try {
operationsHandler.login(new NullProgressMonitor());
}
catch (CoreException e) {
error = e;
}
assertError(error);
// CREATE a separate client to test valid connection. the purpose here
// is to ensure that the server does not retain the incorrect
// credentials
client = createClient(new CloudCredentials(credentials.userEmail, credentials.password),
CloudFoundryTestFixture.CF_PIVOTAL_SERVER_URL_HTTP);
operationsHandler = new CloudFoundryLoginHandler(client);
try {