SpaceUtil { public static AclType resolveCallerAcl(String spaceId, ContentStore store, Map<String, AclType> acls, Authentication authentication) throws ContentStoreException { return resolveCallerAcl(spaceId, store, acls, authentication, null); } private  SpaceUtil(); static Space populateSpace(Space space,
                                      org.duracloud.domain.Space cloudSpace,
                                      ContentStore contentStore,
                                      Authentication authentication); static void populateContentItem(String duradminBaseURL,
                                           ContentItem contentItem,
                                           String spaceId,
                                           String contentId,
                                           ContentStore store,
                                           Authentication authentication); static void streamContent(ContentStore store, HttpServletResponse response, String spaceId, String contentId); static void streamToResponse(InputStream is,
                                        HttpServletResponse response,
                                        String mimetype,
                                        String contentLength); static AclType resolveCallerAcl(String spaceId, ContentStore store, Map<String, AclType> acls,
                                           Authentication authentication); static AclType resolveCallerAcl(String spaceId, ContentStore store, Map<String, AclType> acls,
                                           Authentication authentication, Boolean snapshotInProgress); static boolean isAdmin(Authentication authentication); static List<Acl> toAclList(Map<String, AclType> spaceACLs); static void sortAcls(List<Acl> acls); static String formatAclDisplayName(String key);  }
@Test public void testAdmin() throws Exception { expectAdminAuthority(); expectedAmazonS3StorageProviderType(); replay(); AclType result = SpaceUtil.resolveCallerAcl(spaceId, contentStore, new HashMap<String, AclType>(), authentication); Assert.assertEquals(AclType.WRITE, result); }
@Test public void testReadOnlyNonAdmin() throws Exception { expectSubAdminAuthority(); expectedAmazonS3StorageProviderType(); Map<String, AclType> acls = new HashMap<String, AclType>(); acls.put(username, AclType.READ); replay(); AclType result = SpaceUtil.resolveCallerAcl(spaceId, contentStore, acls, authentication); Assert.assertEquals(AclType.READ, result); }
@Test public void testReadWriteNonAdmin() throws Exception { expectedAmazonS3StorageProviderType(); Map<String, AclType> acls = new HashMap<String, AclType>(); acls.put(username, AclType.WRITE); expectSubAdminAuthority(); replay(); AclType result = SpaceUtil.resolveCallerAcl(spaceId, contentStore, acls, authentication); Assert.assertEquals(AclType.WRITE, result); }
@Test public void testReadWriteGroupNonAdmin() throws Exception { expectedAmazonS3StorageProviderType(); Map<String, AclType> acls = new HashMap<String, AclType>(); acls.put(group, AclType.WRITE); expectSubAdminAuthority(); replay(); AclType result = SpaceUtil.resolveCallerAcl(spaceId, contentStore, acls, authentication); Assert.assertEquals(AclType.WRITE, result); }
@Test public void testUnauthorized() throws Exception { expectedAmazonS3StorageProviderType(); expectSubAdminAuthority(); replay(); AclType result = SpaceUtil.resolveCallerAcl(spaceId, contentStore, new HashMap<String, AclType>(), authentication); Assert.assertNull(result); }