Search in sources :

Example 6 with AuthorizationService

use of org.apache.zeppelin.notebook.AuthorizationService in project zeppelin by apache.

the class ZeppelinRestApiTest method testListNotes.

@Test
public void testListNotes() throws IOException {
    LOG.info("testListNotes");
    CloseableHttpResponse get = httpGet("/notebook/");
    assertThat("List notes method", get, isAllowed());
    Map<String, Object> resp = gson.fromJson(EntityUtils.toString(get.getEntity(), StandardCharsets.UTF_8), new TypeToken<Map<String, Object>>() {
    }.getType());
    List<Map<String, String>> body = (List<Map<String, String>>) resp.get("body");
    // TODO(khalid): anonymous or specific user notes?
    HashSet<String> anonymous = new HashSet<>(Arrays.asList("anonymous"));
    AuthorizationService authorizationService = TestUtils.getInstance(AuthorizationService.class);
    assertEquals("List notes are equal", TestUtils.getInstance(Notebook.class).getNotesInfo(noteId -> authorizationService.isReader(noteId, anonymous)).size(), body.size());
    get.close();
}
Also used : Notebook(org.apache.zeppelin.notebook.Notebook) AuthorizationService(org.apache.zeppelin.notebook.AuthorizationService) TypeToken(com.google.gson.reflect.TypeToken) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with AuthorizationService

use of org.apache.zeppelin.notebook.AuthorizationService in project zeppelin by apache.

the class HeliumApplicationFactoryTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    // set AppEventListener properly
    for (InterpreterSetting interpreterSetting : interpreterSettingManager.get()) {
        interpreterSetting.setAppEventListener(heliumAppFactory);
    }
    AuthorizationService authorizationService = mock(AuthorizationService.class);
    notebookRepo = mock(NotebookRepo.class);
    notebook = new Notebook(conf, authorizationService, notebookRepo, new NoteManager(notebookRepo, ZeppelinConfiguration.create()), interpreterFactory, interpreterSettingManager, new Credentials());
    heliumAppFactory = new HeliumApplicationFactory(notebook, null);
    notebook.addNotebookEventListener(heliumAppFactory);
    anonymous = new AuthenticationInfo("anonymous");
}
Also used : NotebookRepo(org.apache.zeppelin.notebook.repo.NotebookRepo) Notebook(org.apache.zeppelin.notebook.Notebook) AuthorizationService(org.apache.zeppelin.notebook.AuthorizationService) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) NoteManager(org.apache.zeppelin.notebook.NoteManager) Credentials(org.apache.zeppelin.user.Credentials) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) Before(org.junit.Before)

Aggregations

AuthorizationService (org.apache.zeppelin.notebook.AuthorizationService)7 Notebook (org.apache.zeppelin.notebook.Notebook)6 NoteManager (org.apache.zeppelin.notebook.NoteManager)4 Credentials (org.apache.zeppelin.user.Credentials)4 Before (org.junit.Before)4 InterpreterSettingManager (org.apache.zeppelin.interpreter.InterpreterSettingManager)3 NotebookRepo (org.apache.zeppelin.notebook.repo.NotebookRepo)3 File (java.io.File)2 ZeppelinConfiguration (org.apache.zeppelin.conf.ZeppelinConfiguration)2 InterpreterFactory (org.apache.zeppelin.interpreter.InterpreterFactory)2 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)2 QuartzSchedulerService (org.apache.zeppelin.notebook.scheduler.QuartzSchedulerService)2 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)2 TypeToken (com.google.gson.reflect.TypeToken)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1