use of org.eclipse.ceylon.common.config.Authentication.UsernamePassword in project ceylon by eclipse.
the class AuthenticationTest method testRepoWithFooAndEntryStorePass.
@Test
public void testRepoWithFooAndEntryStorePass() throws Exception {
String keystoreSectionName = null;
String storeFilename = "foofile";
File storeFile = new File(testDir, storeFilename);
String repoPass = "foopassword";
String alias = "fooalias";
String storePass = "foostorepass";
String entryPass = "fooentry";
createStore(testConfig, keystoreSectionName, storeFilename, storeFile, repoPass, alias, storePass, entryPass);
mockPrompt.prompts.put("Password for default keystore (foofile):", storePass);
Authentication.setPasswordPrompt(mockPrompt);
Repository repository = repos.getRepository("repo-with-keystorefoo");
Assert.assertNull(repository.getCredentials().getPassword());
Assert.assertEquals(alias, repository.getCredentials().getAlias());
UsernamePassword up = Authentication.fromConfig(testConfig).getUsernameAndPassword(repository.getCredentials());
Assert.assertNotNull(up);
mockPrompt.assertSeenPrompts();
try {
up.getPassword();
Assert.fail();
} catch (RuntimeException e) {
Assert.assertTrue(e.getMessage(), e.getMessage().contains("The given password cannot be used to access the alias fooalias in the default keystore (foofile)"));
}
mockPrompt.assertSeenPrompts("Password for default keystore (foofile):");
Assert.assertEquals(repository.getCredentials().getUser(), up.getUser());
}
Aggregations