Search in sources :

Example 11 with Credentials

use of org.apache.zeppelin.user.Credentials 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)

Example 12 with Credentials

use of org.apache.zeppelin.user.Credentials in project zeppelin by apache.

the class Paragraph method getInterpreterContext.

private InterpreterContext getInterpreterContext() {
    AngularObjectRegistry registry = null;
    ResourcePool resourcePool = null;
    String replName = null;
    if (this.interpreter != null) {
        registry = this.interpreter.getInterpreterGroup().getAngularObjectRegistry();
        resourcePool = this.interpreter.getInterpreterGroup().getResourcePool();
        InterpreterSetting interpreterSetting = ((ManagedInterpreterGroup) interpreter.getInterpreterGroup()).getInterpreterSetting();
        replName = interpreterSetting.getName();
    }
    Credentials credentials = note.getCredentials();
    if (subject != null) {
        UserCredentials userCredentials;
        try {
            userCredentials = credentials.getUserCredentials(subject.getUser());
        } catch (IOException e) {
            LOGGER.warn("Unable to get Usercredentials. Working with empty UserCredentials", e);
            userCredentials = new UserCredentials();
        }
        subject.setUserCredentials(userCredentials);
    }
    return InterpreterContext.builder().setNoteId(note.getId()).setNoteName(note.getName()).setParagraphId(getId()).setReplName(replName).setParagraphTitle(title).setParagraphText(text).setAuthenticationInfo(subject).setLocalProperties(localProperties).setConfig(config).setGUI(settings).setNoteGUI(getNoteGui()).setAngularObjectRegistry(registry).setResourcePool(resourcePool).build();
}
Also used : InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) ResourcePool(org.apache.zeppelin.resource.ResourcePool) UserCredentials(org.apache.zeppelin.user.UserCredentials) IOException(java.io.IOException) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) UserCredentials(org.apache.zeppelin.user.UserCredentials) Credentials(org.apache.zeppelin.user.Credentials) ManagedInterpreterGroup(org.apache.zeppelin.interpreter.ManagedInterpreterGroup)

Example 13 with Credentials

use of org.apache.zeppelin.user.Credentials in project zeppelin by apache.

the class CredentialsRestApiTest method setUp.

@Before
public void setUp() throws IOException {
    credentials = new Credentials();
    authenticationService = new NoAuthenticationService();
    credentialRestApi = new CredentialRestApi(credentials, authenticationService);
}
Also used : NoAuthenticationService(org.apache.zeppelin.service.NoAuthenticationService) Credentials(org.apache.zeppelin.user.Credentials) UserCredentials(org.apache.zeppelin.user.UserCredentials) Before(org.junit.Before)

Example 14 with Credentials

use of org.apache.zeppelin.user.Credentials in project zeppelin by apache.

the class NotebookServiceTest method setUp.

@Before
public void setUp() throws Exception {
    notebookDir = Files.createTempDirectory("notebookDir").toAbsolutePath().toFile();
    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath());
    ZeppelinConfiguration zeppelinConfiguration = ZeppelinConfiguration.create();
    NotebookRepo notebookRepo = new VFSNotebookRepo();
    notebookRepo.init(zeppelinConfiguration);
    InterpreterSettingManager mockInterpreterSettingManager = mock(InterpreterSettingManager.class);
    InterpreterFactory mockInterpreterFactory = mock(InterpreterFactory.class);
    Interpreter mockInterpreter = mock(Interpreter.class);
    when(mockInterpreterFactory.getInterpreter(any(), any())).thenReturn(mockInterpreter);
    when(mockInterpreter.interpret(eq("invalid_code"), any())).thenReturn(new InterpreterResult(Code.ERROR, "failed"));
    when(mockInterpreter.interpret(eq("1+1"), any())).thenReturn(new InterpreterResult(Code.SUCCESS, "succeed"));
    doCallRealMethod().when(mockInterpreter).getScheduler();
    when(mockInterpreter.getFormType()).thenReturn(FormType.NATIVE);
    ManagedInterpreterGroup mockInterpreterGroup = mock(ManagedInterpreterGroup.class);
    when(mockInterpreter.getInterpreterGroup()).thenReturn(mockInterpreterGroup);
    InterpreterSetting mockInterpreterSetting = mock(InterpreterSetting.class);
    when(mockInterpreterSetting.isUserAuthorized(any())).thenReturn(true);
    when(mockInterpreterGroup.getInterpreterSetting()).thenReturn(mockInterpreterSetting);
    when(mockInterpreterSetting.getStatus()).thenReturn(InterpreterSetting.Status.READY);
    Credentials credentials = new Credentials();
    NoteManager noteManager = new NoteManager(notebookRepo, zeppelinConfiguration);
    AuthorizationService authorizationService = new AuthorizationService(noteManager, zeppelinConfiguration);
    notebook = new Notebook(zeppelinConfiguration, authorizationService, notebookRepo, noteManager, mockInterpreterFactory, mockInterpreterSettingManager, credentials, null);
    searchService = new LuceneSearch(zeppelinConfiguration, notebook);
    QuartzSchedulerService schedulerService = new QuartzSchedulerService(zeppelinConfiguration, notebook);
    schedulerService.waitForFinishInit();
    notebookService = new NotebookService(notebook, authorizationService, zeppelinConfiguration, schedulerService);
    String interpreterName = "test";
    when(mockInterpreterSetting.getName()).thenReturn(interpreterName);
    when(mockInterpreterSettingManager.getDefaultInterpreterSetting()).thenReturn(mockInterpreterSetting);
}
Also used : NotebookRepo(org.apache.zeppelin.notebook.repo.NotebookRepo) VFSNotebookRepo(org.apache.zeppelin.notebook.repo.VFSNotebookRepo) Interpreter(org.apache.zeppelin.interpreter.Interpreter) Notebook(org.apache.zeppelin.notebook.Notebook) QuartzSchedulerService(org.apache.zeppelin.notebook.scheduler.QuartzSchedulerService) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) InterpreterSettingManager(org.apache.zeppelin.interpreter.InterpreterSettingManager) InterpreterFactory(org.apache.zeppelin.interpreter.InterpreterFactory) ManagedInterpreterGroup(org.apache.zeppelin.interpreter.ManagedInterpreterGroup) VFSNotebookRepo(org.apache.zeppelin.notebook.repo.VFSNotebookRepo) AuthorizationService(org.apache.zeppelin.notebook.AuthorizationService) LuceneSearch(org.apache.zeppelin.search.LuceneSearch) ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) NoteManager(org.apache.zeppelin.notebook.NoteManager) Credentials(org.apache.zeppelin.user.Credentials) Before(org.junit.Before)

Aggregations

Credentials (org.apache.zeppelin.user.Credentials)14 UserCredentials (org.apache.zeppelin.user.UserCredentials)7 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)6 ResourcePool (org.apache.zeppelin.resource.ResourcePool)6 Before (org.junit.Before)6 Notebook (org.apache.zeppelin.notebook.Notebook)5 InterpreterSettingManager (org.apache.zeppelin.interpreter.InterpreterSettingManager)4 AuthorizationService (org.apache.zeppelin.notebook.AuthorizationService)4 NoteManager (org.apache.zeppelin.notebook.NoteManager)4 File (java.io.File)3 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)3 ManagedInterpreterGroup (org.apache.zeppelin.interpreter.ManagedInterpreterGroup)3 NotebookRepo (org.apache.zeppelin.notebook.repo.NotebookRepo)3 QuartzSchedulerService (org.apache.zeppelin.notebook.scheduler.QuartzSchedulerService)3 LuceneSearch (org.apache.zeppelin.search.LuceneSearch)3 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)3 IOException (java.io.IOException)2 ZeppelinConfiguration (org.apache.zeppelin.conf.ZeppelinConfiguration)2 Interpreter (org.apache.zeppelin.interpreter.Interpreter)2 InterpreterFactory (org.apache.zeppelin.interpreter.InterpreterFactory)2