diff options
author | Martin Stockhammer <m.stockhammer@web.de> | 2016-09-14 23:04:03 +0200 |
---|---|---|
committer | Martin Stockhammer <m.stockhammer@web.de> | 2016-09-14 23:04:03 +0200 |
commit | 5bc8ad7de352acb025fefb2e39967abf94163b3b (patch) | |
tree | f4052efd692fe314e2f00b726323145341dc0d5f /archiva-modules | |
parent | de3eb83242b42d75546670e8859cdb1f59fe4fa6 (diff) | |
download | archiva-5bc8ad7de352acb025fefb2e39967abf94163b3b.tar.gz archiva-5bc8ad7de352acb025fefb2e39967abf94163b3b.zip |
Adding test case for repository listing
Diffstat (limited to 'archiva-modules')
-rw-r--r-- | archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java index 7ee34c6d9..f6e58855c 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java @@ -18,8 +18,10 @@ package org.apache.archiva.rest.services; * under the License. */ +import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.maven2.model.Artifact; import org.apache.archiva.metadata.model.ProjectVersionMetadata; +import org.apache.archiva.redback.rest.api.model.Role; import org.apache.archiva.redback.rest.api.services.RedbackServiceException; import org.apache.archiva.rest.api.model.ArtifactContentEntry; import org.apache.archiva.rest.api.model.BrowseResult; @@ -38,9 +40,7 @@ import org.junit.Test; import javax.ws.rs.core.MediaType; import java.io.File; import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import static org.assertj.core.api.Assertions.assertThat; @@ -154,6 +154,52 @@ public class BrowseServiceTest new BrowseResultEntry( "org.apache.karaf.features", false ) ); } + @Test + public void listUserRepositories() + throws Exception + { + initSourceTargetRepo(); + BrowseService browseService = getBrowseService( authorizationHeader, false ); + + List<ManagedRepository> browseResult = browseService.getUserRepositories(); + assertThat( browseResult ) + .isNotNull() + .isNotEmpty() + .hasSize(5); + List<String> repIds = new ArrayList<>(); + for(ManagedRepository rep : browseResult) { + repIds.add(rep.getId()); + } + assertThat(repIds).contains("internal","snapshots","test-repo","test-copy-target","test-origin-repo"); + + } + + + @Test + public void listUserManagableRepositories() + throws Exception + { + initSourceTargetRepo(); + // Giving the guest user a manager role + String name = "Repository Manager - internal"; + Role role = getRoleManagementService( authorizationHeader ).getRole( name ); + role.setUsers( Arrays.asList( getUserService( authorizationHeader ).getUser( "guest" ) ) ); + getRoleManagementService( authorizationHeader ).updateRoleUsers( role ); + + // browseService with guest user + BrowseService browseService = getBrowseService( "", false ); + + List<ManagedRepository> browseResult = browseService.getUserManagableRepositories(); + assertThat( browseResult ) + .isNotNull() + .isNotEmpty().hasSize(1); + List<String> repIds = new ArrayList<>(); + for(ManagedRepository rep : browseResult) { + repIds.add(rep.getId()); + } + assertThat(repIds).contains("internal"); + + } @Test public void browsegroupIdWithReleaseStartNumber() |