use of org.eclipse.ceylon.common.config.Repositories.Repository in project ceylon by eclipse.
the class RepositoriesTest method testSetRepositoriesByType.
@Test
public void testSetRepositoriesByType() {
CeylonConfig configCopy = testConfig.copy();
Repositories testRepos = Repositories.withConfig(configCopy);
Repository[] reps = testRepos.getRepositoriesByType(Repositories.REPO_TYPE_LOCAL_LOOKUP);
reps = new Repositories.SimpleRepository[] { new Repositories.SimpleRepository("", "./mods", null) };
testRepos.setRepositoriesByType(Repositories.REPO_TYPE_LOCAL_LOOKUP, reps);
Repository[] lookup = testRepos.getLocalLookupRepositories();
Assert.assertTrue(lookup.length == 1);
assertRepository(lookup[0], "%lookup-1", "./mods", null, null);
}
use of org.eclipse.ceylon.common.config.Repositories.Repository in project ceylon by eclipse.
the class RepositoriesTest method testGetDefaultGlobalLookupRepositories.
@Test
public void testGetDefaultGlobalLookupRepositories() {
Repository[] lookup = defaultRepos.getGlobalLookupRepositories();
Assert.assertTrue(lookup.length == 1);
File userDir = defaultRepos.getUserRepoDir();
assertRepository(lookup[0], "USER", userDir.getAbsolutePath(), null, null);
}
use of org.eclipse.ceylon.common.config.Repositories.Repository in project ceylon by eclipse.
the class AuthenticationTest method testRepoWithFooAndBadStorePass.
@Test
public void testRepoWithFooAndBadStorePass() throws Exception {
String keystoreSectionName = null;
String storeFilename = "foofile";
File storeFile = new File(testDir, storeFilename);
String repoPass = "foopassword";
String alias = "fooalias";
String storePass = "foostorepass";
createStore(testConfig, keystoreSectionName, storeFilename, storeFile, repoPass, alias, storePass, storePass);
mockPrompt.prompts.put("Password for default keystore (foofile):", storePass + " whoops");
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.assertSeenNoPrompts();
try {
up.getPassword();
Assert.fail();
} catch (RuntimeException e) {
// Annoyingly the Keystore provider (well the jecks one at least)
// throws an IOException in this case
Assert.assertTrue(e.getMessage(), e.getMessage().contains("Keystore was tampered with, or password was incorrect"));
}
mockPrompt.assertSeenOnlyGivenPrompts();
Assert.assertEquals(repository.getCredentials().getUser(), up.getUser());
}
use of org.eclipse.ceylon.common.config.Repositories.Repository in project ceylon by eclipse.
the class AuthenticationTest method testRepoWithPlaintext.
@Test
public void testRepoWithPlaintext() {
Repository repository = repos.getRepository("repo-with-plaintext");
Assert.assertNotNull(repository);
UsernamePassword up = Authentication.fromConfig(testConfig).getUsernameAndPassword(repository.getCredentials());
Assert.assertNotNull(up);
Assert.assertEquals("plaintext", new String(up.getPassword()));
mockPrompt.assertSeenNoPrompts();
Assert.assertEquals(repository.getCredentials().getUser(), up.getUser());
}
use of org.eclipse.ceylon.common.config.Repositories.Repository 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