import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
import org.apache.archiva.audit.AuditEvent;
import org.apache.archiva.audit.AuditListener;
+import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
+import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.FileTypes;
+import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.archiva.configuration.RepositoryGroupConfiguration;
+import org.apache.archiva.configuration.RepositoryScanningConfiguration;
+import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
+import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.filter.Filter;
import org.apache.archiva.metadata.repository.filter.IncludesFilter;
import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
+import org.apache.archiva.model.ArtifactReference;
+import org.apache.archiva.repository.RepositoryContentFactory;
+import org.apache.archiva.repository.content.ManagedDefaultRepositoryContent;
+import org.apache.archiva.repository.content.ManagedLegacyRepositoryContent;
+import org.apache.archiva.repository.content.PathParser;
import org.apache.archiva.repository.events.RepositoryListener;
+import org.apache.archiva.repository.layout.LayoutException;
import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
import org.apache.archiva.scheduler.repository.RepositoryTask;
import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.FileTypes;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.archiva.configuration.RepositoryGroupConfiguration;
-import org.apache.archiva.configuration.RepositoryScanningConfiguration;
-import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
-import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
-import org.apache.archiva.model.ArtifactReference;
-import org.apache.archiva.repository.RepositoryContentFactory;
-import org.apache.archiva.repository.content.ManagedDefaultRepositoryContent;
-import org.apache.archiva.repository.content.ManagedLegacyRepositoryContent;
-import org.apache.archiva.repository.content.PathParser;
-import org.apache.archiva.repository.layout.LayoutException;
import org.codehaus.plexus.redback.role.RoleManager;
import org.codehaus.plexus.registry.Registry;
import org.easymock.MockControl;
import org.easymock.classextension.MockClassControl;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
private DefaultRepositoryGroupAdmin repositoryGroupAdmin;
+ @Inject
+ PlexusSisuBridge plexusSisuBridge;
+
+ @Inject
+ MavenIndexerUtils mavenIndexerUtils;
+
@Before
public void setUp()
throws Exception
configControl = MockClassControl.createControl( Configuration.class );
config = (Configuration) configControl.getMock();
+
+
repositoryTaskSchedulerControl = MockClassControl.createControl( RepositoryArchivaTaskScheduler.class );
repositoryTaskScheduler = (RepositoryArchivaTaskScheduler) repositoryTaskSchedulerControl.getMock();
managedRepositoryAdmin.setRepositorySessionFactory( repositorySessionFactory );
managedRepositoryAdmin.setAuditListeners( Arrays.asList( auditListener ) );
managedRepositoryAdmin.setRoleManager( roleManager );
+ managedRepositoryAdmin.setMavenIndexerUtils( mavenIndexerUtils );
+ managedRepositoryAdmin.setPlexusSisuBridge( plexusSisuBridge );
+ archivaConfigControl.reset();
+ archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 3 );
+ configControl.expectAndReturn( config.getManagedRepositories(), new ArrayList( 0 ) );
+ archivaConfigControl.replay();
+ configControl.replay();
+ managedRepositoryAdmin.initialize();
RepositoryCommonValidator repositoryCommonValidator = new RepositoryCommonValidator();
repositoryCommonValidator.setArchivaConfiguration( archivaConfig );
Collections.singletonList( listener ), repositoryStatisticsManager,
repositoryMerger, auditListener, managedRepositoryAdmin,
remoteRepositoryAdmin, proxyConnectorAdmin, repositoryGroupAdmin );
+
+
+ }
+
+ @After
+ public void shutdown()
+ throws Exception
+ {
+ //archivaConfigControl.reset();
+ //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1 );
+ //configControl.expectAndReturn( config.getManagedRepositories(), new ArrayList( 0 ), 1 );
+ //managedRepositoryAdmin.shutdown();
}
/* Tests for repository consumers */
// test enable "check-metadata" consumer
recordRepoConsumers();
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning, 1, 5 );
archivaConfig.save( config );
{
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "default", "default-repo" );
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( managedRepo ), 1, 5 );
ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
PathParser parser = (PathParser) pathParserControl.getMock();
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "legacy", "legacy-repo" );
-
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( managedRepo ), 1, 5 );
ManagedLegacyRepositoryContent repoContent = new ManagedLegacyRepositoryContent();
{
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "default", "default-repo" );
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( managedRepo ), 1, 5 );
ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
public void testDeleteArtifacRepositoryDoesNotExist()
throws Exception
{
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), Collections.emptyList() );
archivaConfigControl.replay();
public void testExecuteRepoScannerRepoExistsAndNotBeingScanned()
throws Exception
{
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList(
createManagedRepo( "internal", "default", "Internal Repository", true, false ) ), 1, 5 );
public void testExecuteRepoScannerRepoExistsButBeingScanned()
throws Exception
{
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList(
createManagedRepo( "internal", "default", "Internal Repository", true, false ) ), 1, 5 );
public void testExecuteRepoScannerRepoDoesNotExist()
throws Exception
{
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), Collections.emptyList(), 1, 5 );
archivaConfigControl.replay();
managedRepos.add( createManagedRepo( "internal", "default", "Internal Repository", true, false ) );
managedRepos.add( createManagedRepo( "snapshots", "default", "Snapshots Repository", false, true ) );
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), managedRepos );
archivaConfigControl.replay();
remoteRepos.add(
createRemoteRepository( "dummy", "Dummy Remote Repository", "legacy", "http://dummy.com/dummy" ) );
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getRemoteRepositories(), remoteRepos );
archivaConfigControl.replay();
@Test
public void testDeleteInvalidRepositoryContent()
{
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), Collections.emptyList(), 1, 5 );
archivaConfigControl.replay();
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "default", "default-repo" );
assertTrue( new File( managedRepo.getLocation(), "org" ).exists() );
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 3 );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( managedRepo ), 1, 5 );
metadataRepository.removeRepository( "internal" );
public void testMergeRepositoryWithInvalidRepository()
throws Exception
{
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), Collections.emptyList(), 1, 2 );
archivaConfigControl.replay();
public void testMergeWithNoStagingRepository()
throws Exception
{
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(),
Arrays.asList( createManagedRepo( "repo", "default", "repo", true, false ) ), 1,
4 );
RepositoryTask task = new RepositoryTask();
task.setScanAll( true );
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( merge, staging ), 1, 5 );
metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( staging.getId() ), sources );
repo.setLocation( "target/test-repository/one" );
ManagedRepositoryConfiguration staging = createStagingRepo( repo );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( repo, staging ), 1, 5 );
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( staging.getId() ), sources );
remoteRepoMap.put( "repo1", remoteRepo );
repoGroupMap.put( "repo1", repoGroup );
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositoriesAsMap(), managedRepoMap );
configControl.expectAndReturn( config.getRemoteRepositoriesAsMap(), remoteRepoMap );
configControl.expectAndReturn( config.getRepositoryGroupsAsMap(), repoGroupMap );
assertFalse( new File( releaseLocation ).isDirectory() );
assertFalse( new File( stageLocation ).isDirectory() );
boolean success = service.addManagedRepository( repoId, layout, name,
- "${appserver.base}/test-repository/" + projId + ".releases",
+ appserverBase + "/test-repository/" + projId + ".releases",
true, true, false, true, "0 15 3 * * ? *", 1, 1, true );
assertTrue( success );
assertTrue( new File( releaseLocation ).isDirectory() );
remoteRepoMap.put( "repo1", remoteRepo );
repoGroupMap.put( "repo1", repoGroup );
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositoriesAsMap(), managedRepoMap );
configControl.expectAndReturn( config.getRemoteRepositoriesAsMap(), remoteRepoMap );
configControl.expectAndReturn( config.getRepositoryGroupsAsMap(), repoGroupMap );
try
{
service.addManagedRepository( repoId, layout, name,
- "${appserver.base}/test-repository/" + projId + ".releases", true, true,
+ "target/test-repository/" + projId + ".releases", true, true,
false, true, "0 15 3 * * ? *", 1, 1, true );
fail( "An exception should have been thrown! Repository ID is not valid." );
}
remoteRepoMap.put( "repo1", remoteRepo );
repoGroupMap.put( "repo1", repoGroup );
+ archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ configControl.reset();
configControl.expectAndReturn( config.getManagedRepositoriesAsMap(), managedRepoMap );
configControl.expectAndReturn( config.getRemoteRepositoriesAsMap(), remoteRepoMap );
configControl.expectAndReturn( config.getRepositoryGroupsAsMap(), repoGroupMap );
try
{
service.addManagedRepository( repoId, layout, name,
- "${appserver.base}/test-repository/" + projId + ".releases", true, true,
+ "target/test-repository/" + projId + ".releases", true, true,
false, true, "0 15 3 * * ? *", 1, 1, true );
fail( "An exception should have been thrown! Repository name is not valid." );
}
remoteRepoMap.put( "repo1", remoteRepo );
repoGroupMap.put( "repo1", repoGroup );
- archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
- archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ archivaConfigControl.reset();
+ archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 3 );
- configControl.expectAndReturn( config.getManagedRepositoriesAsMap(), managedRepoMap );
- configControl.expectAndReturn( config.getRemoteRepositoriesAsMap(), remoteRepoMap );
+ configControl.reset();
+ configControl.expectAndReturn( config.getManagedRepositoriesAsMap(), managedRepoMap, 0, 3 );
+ configControl.expectAndReturn( config.getRemoteRepositoriesAsMap(), remoteRepoMap, 1, 3 );
configControl.expectAndReturn( config.getRepositoryGroupsAsMap(), repoGroupMap );
registryControl.expectAndReturn( registry.getString( "appserver.base", "${appserver.base}" ), appserverBase );
registryControl.expectAndReturn( registry.getString( "appserver.home", "${appserver.home}" ), appserverBase );
--- /dev/null
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<redback-role-model>
+ <modelVersion>1.0.0</modelVersion>
+ <applications>
+ <application>
+ <id>System</id>
+ <description>Roles that apply system-wide, across all of the applications</description>
+ <version>1.0.0</version>
+ <resources>
+ <resource>
+ <id>global</id>
+ <name>*</name>
+ <permanent>true</permanent>
+ <description>global resource implies full access for authorization</description>
+ </resource>
+ <resource>
+ <id>username</id>
+ <name>${username}</name>
+ <permanent>true</permanent>
+ <description>replaced with the username of the principal at authorization check time</description>
+ </resource>
+ </resources>
+ <operations>
+ <operation>
+ <id>configuration-edit</id>
+ <name>configuration-edit</name>
+ <description>edit configuration</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-create</id>
+ <name>user-management-user-create</name>
+ <description>create user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-edit</id>
+ <name>user-management-user-edit</name>
+ <description>edit user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-role</id>
+ <name>user-management-user-role</name>
+ <description>user roles</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-delete</id>
+ <name>user-management-user-delete</name>
+ <description>delete user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-list</id>
+ <name>user-management-user-list</name>
+ <description>list users</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-role-grant</id>
+ <name>user-management-role-grant</name>
+ <description>grant role</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-role-drop</id>
+ <name>user-management-role-drop</name>
+ <description>drop role</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-rbac-admin</id>
+ <name>user-management-rbac-admin</name>
+ <description>administer rbac</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>guest-access</id>
+ <name>guest-access</name>
+ <description>access guest</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-manage-data</id>
+ <name>user-management-manage-data</name>
+ <description>manage data</description>
+ <permanent>true</permanent>
+ </operation>
+ </operations>
+ <roles>
+ <role>
+ <id>system-administrator</id>
+ <name>System Administrator</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>edit-redback-configuration</id>
+ <name>Edit Redback Configuration</name>
+ <operation>configuration-edit</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>manage-rbac-setup</id>
+ <name>User RBAC Management</name>
+ <operation>user-management-rbac-admin</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>manage-rbac-data</id>
+ <name>RBAC Manage Data</name>
+ <operation>user-management-manage-data</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ <childRoles>
+ <childRole>user-administrator</childRole>
+ </childRoles>
+ </role>
+ <role>
+ <id>user-administrator</id>
+ <name>User Administrator</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>drop-roles-for-anyone</id>
+ <name>Drop Roles for Anyone</name>
+ <operation>user-management-role-drop</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>grant-roles-for-anyone</id>
+ <name>Grant Roles for Anyone</name>
+ <operation>user-management-role-grant</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-create</id>
+ <name>Create Users</name>
+ <operation>user-management-user-create</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-delete</id>
+ <name>Delete Users</name>
+ <operation>user-management-user-delete</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-edit</id>
+ <name>Edit Users</name>
+ <operation>user-management-user-edit</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>access-users-roles</id>
+ <name>Access Users Roles</name>
+ <operation>user-management-user-role</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>access-user-list</id>
+ <name>Access User List</name>
+ <operation>user-management-user-list</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ <role>
+ <id>edit-users-list</id>
+ <name>edit users list</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>access-user-list</id>
+ <name>Access User List</name>
+ <operation>user-management-user-list</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ <role>
+ <id>registered-user</id>
+ <name>Registered User</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>edit-user-by-username</id>
+ <name>Edit User Data by Username</name>
+ <operation>user-management-user-edit</operation>
+ <resource>username</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ <role>
+ <id>guest</id>
+ <name>Guest</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>guest-permission</id>
+ <name>Guest Permission</name>
+ <operation>guest-access</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ </roles>
+ </application>
+ </applications>
+</redback-role-model>
\ No newline at end of file