use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class ManagedRepositoryHandlerTest method putWithConfiguration.
@Test
void putWithConfiguration() throws RepositoryException {
String id = "test-repo-05";
try {
ManagedRepositoryHandler repoHandler = createHandler();
ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration();
configuration.setId(id);
configuration.setName("n-" + id);
repoHandler.put(configuration);
ManagedRepository repo = repoHandler.get(id);
assertNotNull(repo);
assertEquals(id, repo.getId());
assertEquals("n-" + id, repo.getName());
assertTrue(hasRepositoryInConfig(id));
} finally {
removeRepositoryFromConfig(id);
}
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class ManagedRepositoryHandlerTest method putWithCheck_invalid.
@Test
void putWithCheck_invalid() throws RepositoryException {
final String id = "test-repo-07";
final String name = "n-" + id;
try {
ManagedRepositoryHandler repoHandler = createHandler();
BasicManagedRepositoryValidator checker = new BasicManagedRepositoryValidator(configurationHandler);
checker.setRepositoryRegistry(repositoryRegistry);
ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration();
configuration.setId("");
configuration.setName(name);
CheckedResult<ManagedRepository, Map<String, List<ValidationError>>> result = repoHandler.putWithCheck(configuration, checker);
assertNull(repoHandler.get(id));
assertNotNull(result.getResult());
assertNotNull(result.getResult().get("id"));
assertEquals(2, result.getResult().get("id").size());
assertEquals(ISEMPTY, result.getResult().get("id").get(0).getType());
assertFalse(hasRepositoryInConfig(id));
assertFalse(hasRepositoryInConfig(""));
} finally {
removeRepositoryFromConfig(id);
}
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class ManagedRepositoryHandlerTest method removeWithoutSave.
@Test
void removeWithoutSave() throws RepositoryException {
final String id = "test-repo-09";
ManagedRepositoryHandler repoHandler = createHandler();
Configuration aCfg = new Configuration();
ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration();
configuration.setId(id);
configuration.setName("n-" + id);
repoHandler.put(configuration, aCfg);
assertTrue(aCfg.getManagedRepositories().stream().anyMatch(g -> g != null && id.equals(g.getId())));
repoHandler.remove(id, aCfg);
assertNull(repoHandler.get(id));
assertTrue(aCfg.getManagedRepositories().stream().noneMatch(g -> g != null && id.equals(g.getId())));
assertNull(repoHandler.get(id));
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class SecuritySynchronization method assignRepositoryObserverToGuestUser.
private void assignRepositoryObserverToGuestUser(List<ManagedRepositoryConfiguration> repos) {
for (ManagedRepositoryConfiguration repoConfig : repos) {
String repoId = repoConfig.getId();
String principal = UserManager.GUEST_USERNAME;
try {
UserAssignment ua;
if (rbacManager.userAssignmentExists(principal)) {
ua = rbacManager.getUserAssignment(principal);
} else {
ua = rbacManager.createUserAssignment(principal);
}
ua.addRoleId(ArchivaRoleConstants.toRepositoryObserverRoleId(repoId));
rbacManager.saveUserAssignment(ua);
} catch (RbacManagerException e) {
log.warn("Unable to add role [{}] to {} user.", ArchivaRoleConstants.toRepositoryObserverRoleId(repoId), principal, e);
}
}
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class ArchivaConfigurationTest method testConfigurationUpgradeFrom13.
@Test
public void testConfigurationUpgradeFrom13() throws Exception {
ArchivaConfiguration archivaConfiguration = lookup(ArchivaConfiguration.class, "test-upgrade-1.3");
// we just use the defaults when upgrading from 1.3 at this point.
Configuration configuration = archivaConfiguration.getConfiguration();
assertConfiguration(configuration, 2, 2, 2);
assertEquals("check network proxies", 0, configuration.getNetworkProxies().size());
ManagedRepositoryConfiguration repository = configuration.getManagedRepositories().get(0);
assertEquals("check managed repositories", "${appserver.base}/data/repositories/internal", repository.getLocation());
assertEquals("check managed repositories", "Archiva Managed Internal Repository", repository.getName());
assertEquals("check managed repositories", "internal", repository.getId());
assertEquals("check managed repositories", "default", repository.getLayout());
assertTrue("check managed repositories", repository.isScanned());
log.info("knowContentConsumers {}", configuration.getRepositoryScanning().getKnownContentConsumers());
assertFalse(configuration.getRepositoryScanning().getKnownContentConsumers().contains("update-db-artifact"));
assertFalse(configuration.getRepositoryScanning().getKnownContentConsumers().contains("update-db-repository-metadata"));
assertTrue(configuration.getRepositoryScanning().getKnownContentConsumers().contains("create-archiva-metadata"));
assertTrue(configuration.getRepositoryScanning().getKnownContentConsumers().contains("duplicate-artifacts"));
}
Aggregations