You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mi...@apache.org on 2016/12/03 05:13:03 UTC
zeppelin git commit: Fix case where user use zeppelin in normal mode
with token
Repository: zeppelin
Updated Branches:
refs/heads/master d1fc86b7b -> 0d65dabf3
Fix case where user use zeppelin in normal mode with token
### What is this PR for?
Fix the case where user use zeppelin in normal mode (doesnt use authentication) and set zeppelinhub token in zeppelin-env.sh.
### What type of PR is it?
[Bug Fix | Hot Fix]
### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No
Author: Anthony Corbacho <co...@gmail.com>
Closes #1720 from anthonycorbacho/fix/ZeppelinhubNotebookRepo and squashes the following commits:
5de2e47 [Anthony Corbacho] Fix test
7e5fbc5 [Anthony Corbacho] Fix case where user use zeppelin in normal mode with token
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/0d65dabf
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/0d65dabf
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/0d65dabf
Branch: refs/heads/master
Commit: 0d65dabf30f9761530f33234646e602b1c15dca3
Parents: d1fc86b
Author: Anthony Corbacho <co...@gmail.com>
Authored: Sat Dec 3 13:31:41 2016 +0900
Committer: Mina Lee <mi...@apache.org>
Committed: Sat Dec 3 14:12:54 2016 +0900
----------------------------------------------------------------------
.../notebook/repo/zeppelinhub/ZeppelinHubRepo.java | 8 +++++++-
.../notebook/repo/zeppelinhub/ZeppelinHubRepoTest.java | 10 ++++++----
2 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d65dabf/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepo.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepo.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepo.java
index 8141b1c..009ba6e 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepo.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepo.java
@@ -186,8 +186,14 @@ public class ZeppelinHubRepo implements NotebookRepo {
/**
* For a given user logged in is zeppelin (via zeppelinhub notebook repo), get default token.
- * */
+ *
+ */
private String getUserToken(String principal) {
+ // Case of user use token instead of authentication.
+ if (!StringUtils.isBlank(token)) {
+ return token;
+ }
+
String token = usersToken.get(principal);
if (StringUtils.isBlank(token)) {
String ticket = UserSessionContainer.instance.getSession(principal);
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d65dabf/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepoTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepoTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepoTest.java
index 1a954e7..251795a 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepoTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/zeppelinhub/ZeppelinHubRepoTest.java
@@ -42,11 +42,13 @@ public class ZeppelinHubRepoTest {
private ZeppelinhubRestApiHandler getMockedZeppelinHandler() throws HttpException, IOException {
ZeppelinhubRestApiHandler mockedZeppelinhubHandler = mock(ZeppelinhubRestApiHandler.class);
- byte[] response = Files.toByteArray(pathOfNotebooks);
- when(mockedZeppelinhubHandler.get("", "")).thenReturn(new String(response));
+ byte[] listOfNotesResponse = Files.toByteArray(pathOfNotebooks);
+ when(mockedZeppelinhubHandler.get("AAA-BBB-CCC-00", ""))
+ .thenReturn(new String(listOfNotesResponse));
- response = Files.toByteArray(pathOfNotebook);
- when(mockedZeppelinhubHandler.get("", "AAAAA")).thenReturn(new String(response));
+ byte[] noteResponse = Files.toByteArray(pathOfNotebook);
+ when(mockedZeppelinhubHandler.get("AAA-BBB-CCC-00", "AAAAA"))
+ .thenReturn(new String(noteResponse));
return mockedZeppelinhubHandler;
}