You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by pd...@apache.org on 2022/09/30 09:07:32 UTC
[zeppelin] branch master updated: [ZEPPELIN-5826] Activate credentialReplacement test (#4468)
This is an automated email from the ASF dual-hosted git repository.
pdallig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/master by this push:
new e09d6cb74f [ZEPPELIN-5826] Activate credentialReplacement test (#4468)
e09d6cb74f is described below
commit e09d6cb74ff81dc7482bd353eb6904f9bcb71d02
Author: Philipp Dallig <ph...@gmail.com>
AuthorDate: Fri Sep 30 11:07:21 2022 +0200
[ZEPPELIN-5826] Activate credentialReplacement test (#4468)
---
.../apache/zeppelin/notebook/ParagraphTest.java | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java
index f56ead3d1d..e219fad47b 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java
@@ -22,11 +22,15 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyListOf;
+import static org.mockito.Matchers.anySetOf;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -351,9 +355,6 @@ public class ParagraphTest extends AbstractInterpreterTest {
}
}
- //(TODO zjffdu) temporary disable it.
- //https://github.com/apache/zeppelin/pull/3416
- @Ignore
@Test
public void credentialReplacement() throws Throwable {
Note mockNote = mock(Note.class);
@@ -369,11 +370,16 @@ public class ParagraphTest extends AbstractInterpreterTest {
spyParagraph.setInterpreter(mockInterpreter);
doReturn(mockInterpreter).when(spyParagraph).getBindedInterpreter();
+ InterpreterSetting mockInterpreterSetting = mock(InterpreterSetting.class);
+ when(mockInterpreterSetting.getStatus()).thenReturn(InterpreterSetting.Status.READY);
+ when(mockInterpreterSetting.isUserAuthorized(anyListOf(String.class))).thenReturn(true);
+
ManagedInterpreterGroup mockInterpreterGroup = mock(ManagedInterpreterGroup.class);
when(mockInterpreter.getInterpreterGroup()).thenReturn(mockInterpreterGroup);
when(mockInterpreterGroup.getId()).thenReturn("mock_id_1");
when(mockInterpreterGroup.getAngularObjectRegistry()).thenReturn(mock(AngularObjectRegistry.class));
when(mockInterpreterGroup.getResourcePool()).thenReturn(mock(ResourcePool.class));
+ when(mockInterpreterGroup.getInterpreterSetting()).thenReturn(mockInterpreterSetting);
when(mockInterpreter.getFormType()).thenReturn(FormType.NONE);
ParagraphJobListener mockJobListener = mock(ParagraphJobListener.class);
@@ -386,23 +392,23 @@ public class ParagraphTest extends AbstractInterpreterTest {
AuthenticationInfo user1 = new AuthenticationInfo("user1");
spyParagraph.setAuthenticationInfo(user1);
- spyParagraph.setText("val x = \"usr={user.ent}&pass={password.ent}\"");
+ spyParagraph.setText("val x = \"usr={ent.user}&pass={ent.password}\"");
// Credentials should only be injected when it is enabled for an interpreter or when specified in a local property
when(mockInterpreter.getProperty(Constants.INJECT_CREDENTIALS, "false")).thenReturn("false");
spyParagraph.jobRun();
- verify(mockInterpreter).interpret(eq("val x = \"usr={user.ent}&pass={password.ent}\""), any(InterpreterContext.class));
+ verify(mockInterpreter).interpret(eq("val x = \"usr={ent.user}&pass={ent.password}\""), any(InterpreterContext.class));
when(mockInterpreter.getProperty(Constants.INJECT_CREDENTIALS, "false")).thenReturn("true");
- mockInterpreter.setProperty(Constants.INJECT_CREDENTIALS, "true");
+ mockInterpreter.setProperty(Constants.INJECT_CREDENTIALS, "false");
spyParagraph.jobRun();
verify(mockInterpreter).interpret(eq("val x = \"usr=user&pass=pwd\""), any(InterpreterContext.class));
// Check if local property override works
- when(mockInterpreter.getProperty(Constants.INJECT_CREDENTIALS, "false")).thenReturn("true");
+ when(mockInterpreter.getProperty(Constants.INJECT_CREDENTIALS, "false")).thenReturn("false");
spyParagraph.getLocalProperties().put(Constants.INJECT_CREDENTIALS, "true");
spyParagraph.jobRun();
- verify(mockInterpreter).interpret(eq("val x = \"usr=user&pass=pwd\""), any(InterpreterContext.class));
+ verify(mockInterpreter, times(2)).interpret(eq("val x = \"usr=user&pass=pwd\""), any(InterpreterContext.class));
}
}