Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@
<artifactId>shiro-web</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-config-core</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.zeppelin.search.SearchService;
import org.apache.zeppelin.socket.NotebookServer;
import org.apache.zeppelin.user.Credentials;
import org.apache.zeppelin.utils.SecurityUtils;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.*;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
Expand Down Expand Up @@ -238,6 +239,7 @@ private static void setupRestApiContextHandler(WebAppContext webapp,
webapp.setInitParameter("shiroConfigLocations",
new File(conf.getShiroPath()).toURI().toString());

SecurityUtils.initSecurityManager(conf.getShiroPath());
webapp.addFilter(org.apache.shiro.web.servlet.ShiroFilter.class, "/api/*",
EnumSet.allOf(DispatcherType.class));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.ThreadContext;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.zeppelin.conf.ZeppelinConfiguration;

import java.net.InetAddress;
Expand All @@ -34,6 +36,12 @@
*/
public class SecurityUtils {

public static void initSecurityManager(String shiroPath) {
IniSecurityManagerFactory factory = new IniSecurityManagerFactory("file:" + shiroPath);
SecurityManager securityManager = factory.getInstance();
org.apache.shiro.SecurityUtils.setSecurityManager(securityManager);
}

public static Boolean isValidOrigin(String sourceHost, ZeppelinConfiguration conf)
throws UnknownHostException, URISyntaxException {
if (sourceHost == null || sourceHost.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,28 @@ public void testCreateNewButton() throws Exception {
ZeppelinITUtils.sleep(1000, false);
waitForParagraph(1, "READY");

String oldIntpTag = driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText();

collector.checkThat("Paragraph is created above",
driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(),
CoreMatchers.equalTo(StringUtils.EMPTY));
CoreMatchers.not(StringUtils.EMPTY));
setTextOfParagraph(1, " this is above ");


newPara = driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class,'new-paragraph')][2]"));
action.moveToElement(newPara).click().build().perform();

waitForParagraph(3, "READY");

String lastIntpTag = driver.findElement(By.xpath(getParagraphXPath(3) + "//div[contains(@class, 'editor')]")).getText();

collector.checkThat("Paragraph is created below",
driver.findElement(By.xpath(getParagraphXPath(3) + "//div[contains(@class, 'editor')]")).getText(),
CoreMatchers.equalTo(StringUtils.EMPTY));
CoreMatchers.not(StringUtils.EMPTY));
setTextOfParagraph(3, " this is below ");

collector.checkThat("Compare interpreter name tag", oldIntpTag, CoreMatchers.equalTo(lastIntpTag));

collector.checkThat("The output field of paragraph1 contains",
driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(),
CoreMatchers.equalTo(" this is above "));
Expand Down Expand Up @@ -331,24 +338,30 @@ public void testTitleButton() throws Exception {
String xpathToShowTitle=getParagraphXPath(1) + "//ul/li/a[@ng-click='showTitle()']";
String xpathToHideTitle=getParagraphXPath(1) + "//ul/li/a[@ng-click='hideTitle()']";

LOG.info("1clover is displaded {}", driver.findElement(By.xpath(xpathToTitle)).isDisplayed());

sleep(1000, false);


LOG.info("2clover is displaded {}", driver.findElement(By.xpath(xpathToTitle)).isDisplayed());
collector.checkThat("Before Show Title : The title field contains",
driver.findElement(By.xpath(xpathToTitle)).getText(),
CoreMatchers.equalTo(""));
driver.findElement(By.xpath(xpathToSettingIcon)).click();
collector.checkThat("Before Show Title : The title option in option panel of paragraph is labeled as ",
driver.findElement(By.xpath(xpathToShowTitle)).getText(),
CoreMatchers.equalTo("Show title"));

LOG.info("3clover is displaded {}", driver.findElement(By.xpath(xpathToTitle)).isDisplayed());
driver.findElement(By.xpath(xpathToShowTitle)).click();
collector.checkThat("After Show Title : The title field contains",
driver.findElement(By.xpath(xpathToTitle)).getText(),
CoreMatchers.equalTo("Untitled"));

LOG.info("4clover is displaded {}", driver.findElement(By.xpath(xpathToTitle)).isDisplayed());
driver.findElement(By.xpath(xpathToSettingIcon)).click();
collector.checkThat("After Show Title : The title option in option panel of paragraph is labeled as",
driver.findElement(By.xpath(xpathToHideTitle)).getText(),
CoreMatchers.equalTo("Hide title"));

LOG.info("5clover is displaded {}", driver.findElement(By.xpath(xpathToTitle)).isDisplayed());
driver.findElement(By.xpath(xpathToHideTitle)).click();
collector.checkThat("After Hide Title : The title field contains",
driver.findElement(By.xpath(xpathToTitle)).getText(),
Expand Down