Search in sources :

Example 66 with ManagedRepositoryConfiguration

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());
}
Also used : IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ArtifactCleanupFeature(org.apache.archiva.repository.features.ArtifactCleanupFeature) StagingRepositoryFeature(org.apache.archiva.repository.features.StagingRepositoryFeature) URI(java.net.URI) Test(org.junit.Test)

Example 67 with ManagedRepositoryConfiguration

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);
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)

Example 68 with ManagedRepositoryConfiguration

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();
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 69 with ManagedRepositoryConfiguration

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);
}
Also used : Path(java.nio.file.Path) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ArrayList(java.util.ArrayList) MockServletConfig(org.springframework.mock.web.MockServletConfig) HttpAuthenticator(org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator) MockServletContext(org.springframework.mock.web.MockServletContext) WebApplicationContext(org.springframework.web.context.WebApplicationContext) ServletAuthenticator(org.apache.archiva.security.ServletAuthenticator) Before(org.junit.Before)

Example 70 with ManagedRepositoryConfiguration

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;
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)

Aggregations

ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)72 Configuration (org.apache.archiva.configuration.model.Configuration)27 ManagedRepository (org.apache.archiva.repository.ManagedRepository)18 ContextConfiguration (org.springframework.test.context.ContextConfiguration)18 Path (java.nio.file.Path)17 ProxyConnectorConfiguration (org.apache.archiva.configuration.model.ProxyConnectorConfiguration)14 RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)14 ArchivaConfiguration (org.apache.archiva.configuration.provider.ArchivaConfiguration)14 Test (org.junit.Test)14 StagingRepositoryFeature (org.apache.archiva.repository.features.StagingRepositoryFeature)13 EditableManagedRepository (org.apache.archiva.repository.EditableManagedRepository)11 RepositoryScanningConfiguration (org.apache.archiva.configuration.model.RepositoryScanningConfiguration)10 Test (org.junit.jupiter.api.Test)10 ArrayList (java.util.ArrayList)9 NetworkProxyConfiguration (org.apache.archiva.configuration.model.NetworkProxyConfiguration)9 RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)9 RepositoryException (org.apache.archiva.repository.RepositoryException)9 Before (org.junit.Before)8 IOException (java.io.IOException)7 ArtifactCleanupFeature (org.apache.archiva.repository.features.ArtifactCleanupFeature)7