use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class MavenRepositoryProviderTest method getManagedConfiguration.
@Test
public void getManagedConfiguration() throws Exception {
MavenManagedRepository repo = MavenManagedRepository.newLocalInstance("test01", "My Test repo", Paths.get("target/repositories"));
repo.setLocation(new URI("target/this.is/a/test"));
repo.setScanned(true);
repo.setDescription(repo.getPrimaryLocale(), "This is a description");
repo.setLayout("maven2");
repo.setBlocksRedeployment(true);
repo.setName(repo.getPrimaryLocale(), "test0002");
repo.setSchedulingDefinition("0 0 05 ? * WED");
repo.addActiveReleaseScheme(ReleaseScheme.RELEASE);
repo.addActiveReleaseScheme(ReleaseScheme.SNAPSHOT);
StagingRepositoryFeature stagingFeat = repo.getFeature(StagingRepositoryFeature.class);
stagingFeat.setStageRepoNeeded(true);
IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class);
indexCreationFeature.setIndexPath(new URI("test/.indexes"));
indexCreationFeature.setSkipPackedIndexCreation(true);
ArtifactCleanupFeature artifactCleanupFeature = repo.getFeature(ArtifactCleanupFeature.class);
artifactCleanupFeature.setRetentionPeriod(Period.ofDays(5));
artifactCleanupFeature.setRetentionCount(7);
artifactCleanupFeature.setDeleteReleasedSnapshots(true);
ManagedRepositoryConfiguration cfg = provider.getManagedConfiguration(repo);
assertEquals("target/this.is/a/test", cfg.getLocation());
assertTrue(cfg.isScanned());
assertEquals("This is a description", cfg.getDescription());
assertEquals("maven2", cfg.getLayout());
assertTrue(cfg.isBlockRedeployments());
assertEquals("test0002", cfg.getName());
assertEquals("0 0 05 ? * WED", cfg.getRefreshCronExpression());
assertTrue(cfg.isStageRepoNeeded());
assertEquals("test/.indexes", cfg.getIndexDir());
assertTrue(cfg.isSkipPackedIndexCreation());
assertEquals(5, cfg.getRetentionPeriod());
assertEquals(7, cfg.getRetentionCount());
assertTrue(cfg.isDeleteReleasedSnapshots());
assertTrue(cfg.isReleases());
assertTrue(cfg.isSnapshots());
assertTrue(cfg.isScanned());
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class AbstractSecurityTest method setupRepository.
protected void setupRepository(String repoId) throws Exception {
// Add repo to configuration.
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
repoConfig.setId(repoId);
repoConfig.setName("Testable repo <" + repoId + ">");
repoConfig.setLocation(Paths.get("target/test-repo/" + repoId).toString());
if (!archivaConfiguration.getConfiguration().getManagedRepositoriesAsMap().containsKey(repoId)) {
repositoryRegistry.putRepository(repoConfig);
}
// Add repo roles to security.
userRepos.createMissingRepositoryRoles(repoId);
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class RepositoryServletRepositoryGroupTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
String appserverBase = getAppserverBase().toAbsolutePath().toString();
log.debug("Appserver Base {}", appserverBase);
Configuration configuration = archivaConfiguration.getConfiguration();
repoRootFirst = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_FIRST);
repoRootLast = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_LAST);
configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true));
configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true));
List<String> managedRepoIds = new ArrayList<>();
managedRepoIds.add(MANAGED_REPO_FIRST);
managedRepoIds.add(MANAGED_REPO_LAST);
configuration.addRepositoryGroup(createRepositoryGroup(REPO_GROUP_WITH_VALID_REPOS, managedRepoIds));
// Create the repository group with an invalid managed repository
repoRootInvalid = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_INVALID);
ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepository(MANAGED_REPO_INVALID, "Invalid Test Repo", repoRootInvalid, true);
configuration.addManagedRepository(managedRepositoryConfiguration);
List<String> invalidManagedRepoIds = new ArrayList<>();
invalidManagedRepoIds.add(MANAGED_REPO_FIRST);
invalidManagedRepoIds.add(MANAGED_REPO_INVALID);
invalidManagedRepoIds.add(MANAGED_REPO_LAST);
configuration.addRepositoryGroup(createRepositoryGroup(REPO_GROUP_WITH_INVALID_REPOS, invalidManagedRepoIds));
configuration.removeManagedRepository(managedRepositoryConfiguration);
org.apache.archiva.common.utils.FileUtils.deleteDirectory(repoRootInvalid);
repositoryRegistry.reload();
saveConfiguration(archivaConfiguration);
startRepository();
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class RepositoryServletSecurityTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
String appserverBase = System.getProperty("appserver.base", getProjectBase().resolve("target/appserver-base").toAbsolutePath().toString());
Path testConf = getProjectBase().resolve("src/test/resources/repository-archiva.xml");
Path testConfDest = Paths.get(appserverBase, "conf/archiva.xml");
FileUtils.copyFile(testConf.toFile(), testConfDest.toFile());
Configuration config = archivaConfiguration.getConfiguration();
// clear managed repository
List<ManagedRepositoryConfiguration> f1 = new ArrayList<>(config.getManagedRepositories());
for (ManagedRepositoryConfiguration f : f1) {
config.removeManagedRepository(f);
}
assertEquals(0, config.getManagedRepositories().size());
// add internal repo
config.addManagedRepository(createManagedRepository(REPOID_INTERNAL, "Internal Test Repo", repoRootInternal.getRoot()));
saveConfiguration(archivaConfiguration);
servletAuth = mock(ServletAuthenticator.class);
httpAuth = mock(HttpAuthenticator.class);
davSessionProvider = new ArchivaDavSessionProvider(servletAuth, httpAuth);
final MockServletContext mockServletContext = new MockServletContext();
WebApplicationContext webApplicationContext = new AbstractRepositoryServletTestCase.TestWebapplicationContext(applicationContext, mockServletContext);
mockServletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext);
MockServletConfig mockServletConfig = new MockServletConfig() {
@Override
public ServletContext getServletContext() {
return mockServletContext;
}
};
servlet = new RepositoryServlet();
servlet.init(mockServletConfig);
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class RepositoryServletSecurityTest method createManagedRepository.
protected ManagedRepositoryConfiguration createManagedRepository(String id, String name, Path location) {
ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
repo.setId(id);
repo.setName(name);
repo.setLocation(location.toAbsolutePath().toString());
return repo;
}
Aggregations