use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project pentaho-platform by pentaho.
the class FileServiceIT method testDoGetFileAcl.
@Test
public void testDoGetFileAcl() {
RepositoryFileDto file = mock(RepositoryFileDto.class);
RepositoryFileAclDto fileAcl = mock(RepositoryFileAclDto.class);
when(fileAcl.isEntriesInheriting()).thenReturn(false);
when(fileService.defaultUnifiedRepositoryWebService.getFile(nullable(String.class))).thenReturn(file);
when(fileService.defaultUnifiedRepositoryWebService.getAcl(nullable(String.class))).thenReturn(fileAcl);
doNothing().when(fileService).addAdminRole(fileAcl);
String pathId = "/usr/dir/file.txt";
fileService.doGetFileAcl(pathId);
verify(fileService).addAdminRole(fileAcl);
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project pentaho-platform by pentaho.
the class FileServiceIT method testSetFileAclsException.
@Test
public void testSetFileAclsException() throws Exception {
String pathId = "/usr/folder/file.txt";
RepositoryFileAclDto acl = mock(RepositoryFileAclDto.class);
try {
fileService.setFileAcls(pathId, acl);
fail();
} catch (FileNotFoundException e) {
// expected exception
}
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project pentaho-platform by pentaho.
the class RepositoryFileAclAdapter method unmarshal.
@Override
public RepositoryFileAcl unmarshal(final RepositoryFileAclDto v) {
RepositoryFileAcl.Builder builder = null;
if (v.getOwnerType() != -1) {
if (v.getId() != null) {
builder = new RepositoryFileAcl.Builder(v.getId(), v.getOwner(), RepositoryFileSid.Type.values()[v.getOwnerType()]);
} else {
builder = new RepositoryFileAcl.Builder(v.getTenantPath(), v.getOwner(), RepositoryFileSid.Type.values()[v.getOwnerType()]);
}
} else {
builder = new RepositoryFileAcl.Builder((Serializable) v.getId(), null);
}
builder.entriesInheriting(v.isEntriesInheriting());
for (RepositoryFileAclAceDto fileAclAceDto : v.getAces()) {
builder.ace(RepositoryFileAclAceAdapter.toAce(fileAclAceDto));
}
return builder.build();
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project pentaho-platform by pentaho.
the class FileResourceTest method usersOrRolesExist_RecipientUserExists.
@Test
public void usersOrRolesExist_RecipientUserExists() {
RepositoryFileAclDto acl = new RepositoryFileAclDto();
acl.setOwner(ACL_OWNER);
RepositoryFileAclAceDto recipient = mock(RepositoryFileAclAceDto.class);
doReturn(USERNAME).when(recipient).getRecipient();
acl.setAces(Arrays.asList(new RepositoryFileAclAceDto[] { recipient }), false);
assertTrue(fileResource.validateUsersAndRoles(acl));
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto in project pentaho-platform by pentaho.
the class FileResourceTest method testSetFileAclsError.
@Test
public void testSetFileAclsError() throws Exception {
RepositoryFileAclDto repository = mock(RepositoryFileAclDto.class);
doReturn(mock(Messages.class)).when(fileResource).getMessagesInstance();
doReturn(true).when(fileResource).validateUsersAndRoles(any());
doThrow(mock(RuntimeException.class)).when(fileResource.fileService).setFileAcls(PATH_ID, repository);
assertEquals(INTERNAL_SERVER_ERROR.getStatusCode(), fileResource.setFileAcls(PATH_ID, repository).getStatus());
}
Aggregations