mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Add unit test for note permissions
This commit is contained in:
parent
a8d0ecbb8f
commit
6b9e27447d
1 changed files with 27 additions and 0 deletions
|
|
@ -27,10 +27,12 @@ import static org.mockito.Mockito.mock;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
|
|
@ -362,6 +364,31 @@ public class NotebookTest implements JobListenerFactory{
|
|||
notebook.removeNote(note.id());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPermissions() throws IOException {
|
||||
// create a note and a paragraph
|
||||
Note note = notebook.createNote();
|
||||
// empty owners, readers and writers means note is public
|
||||
assertEquals(note.isOwner(new HashSet<String>(Arrays.asList("user2"))), true);
|
||||
assertEquals(note.isReader(new HashSet<String>(Arrays.asList("user2"))), true);
|
||||
assertEquals(note.isWriter(new HashSet<String>(Arrays.asList("user2"))), true);
|
||||
|
||||
note.setOwners(new HashSet<String>(Arrays.asList("user1")));
|
||||
note.setReaders(new HashSet<String>(Arrays.asList("user1", "user2")));
|
||||
note.setWriters(new HashSet<String>(Arrays.asList("user1")));
|
||||
|
||||
assertEquals(note.isOwner(new HashSet<String>(Arrays.asList("user2"))), false);
|
||||
assertEquals(note.isOwner(new HashSet<String>(Arrays.asList("user1"))), true);
|
||||
|
||||
assertEquals(note.isReader(new HashSet<String>(Arrays.asList("user3"))), false);
|
||||
assertEquals(note.isReader(new HashSet<String>(Arrays.asList("user2"))), true);
|
||||
|
||||
assertEquals(note.isWriter(new HashSet<String>(Arrays.asList("user2"))), false);
|
||||
assertEquals(note.isWriter(new HashSet<String>(Arrays.asList("user1"))), true);
|
||||
|
||||
notebook.removeNote(note.id());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbortParagraphStatusOnInterpreterRestart() throws InterruptedException,
|
||||
IOException {
|
||||
|
|
|
|||
Loading…
Reference in a new issue