mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
add selenium test case for AnyOfRolesAuthorizationFilter
This commit is contained in:
parent
6222ce264f
commit
e2a7ad5485
2 changed files with 61 additions and 2 deletions
|
|
@ -40,6 +40,7 @@ abstract public class AbstractZeppelinIT {
|
|||
protected static WebDriver driver;
|
||||
|
||||
protected final static Logger LOG = LoggerFactory.getLogger(AbstractZeppelinIT.class);
|
||||
protected static final long MIN_IMPLICIT_WAIT = 5;
|
||||
protected static final long MAX_IMPLICIT_WAIT = 30;
|
||||
protected static final long MAX_BROWSER_TIMEOUT_SEC = 30;
|
||||
protected static final long MAX_PARAGRAPH_TIMEOUT_SEC = 120;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import java.io.IOException;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.zeppelin.AbstractZeppelinIT;
|
||||
|
|
@ -38,6 +37,7 @@ import org.junit.Test;
|
|||
import org.junit.rules.ErrorCollector;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.Keys;
|
||||
import org.openqa.selenium.TimeoutException;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -63,12 +63,14 @@ public class AuthenticationIT extends AbstractZeppelinIT {
|
|||
"securityManager.sessionManager = $sessionManager\n" +
|
||||
"securityManager.sessionManager.globalSessionTimeout = 86400000\n" +
|
||||
"shiro.loginUrl = /api/login\n" +
|
||||
"anyofroles = org.apache.zeppelin.utils.AnyOfRolesAuthorizationFilter\n" +
|
||||
"[roles]\n" +
|
||||
"admin = *\n" +
|
||||
"hr = *\n" +
|
||||
"finance = *\n" +
|
||||
"[urls]\n" +
|
||||
"/api/version = anon\n" +
|
||||
"/api/interpreter/** = authc, anyofroles[admin, finance]\n" +
|
||||
"/** = authc";
|
||||
|
||||
static String originalShiro = "";
|
||||
|
|
@ -182,6 +184,62 @@ public class AuthenticationIT extends AbstractZeppelinIT {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnyOfRoles() throws Exception {
|
||||
if (!endToEndTestEnabled()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
AuthenticationIT authenticationIT = new AuthenticationIT();
|
||||
authenticationIT.authenticationUser("admin", "password1");
|
||||
|
||||
pollingWait(By.xpath("//div/button[contains(@class, 'nav-btn dropdown-toggle ng-scope')]"),
|
||||
MAX_BROWSER_TIMEOUT_SEC).click();
|
||||
clickAndWait(By.xpath("//li/a[contains(@href, '#/interpreter')]"));
|
||||
|
||||
collector.checkThat("Check is user has permission to view this page", true,
|
||||
CoreMatchers.equalTo(pollingWait(By.xpath(
|
||||
"//div[@id='main']/div/div[2]"),
|
||||
MIN_IMPLICIT_WAIT).isDisplayed())
|
||||
);
|
||||
|
||||
authenticationIT.logoutUser("admin");
|
||||
|
||||
authenticationIT.authenticationUser("finance1", "finance1");
|
||||
|
||||
pollingWait(By.xpath("//div/button[contains(@class, 'nav-btn dropdown-toggle ng-scope')]"),
|
||||
MAX_BROWSER_TIMEOUT_SEC).click();
|
||||
clickAndWait(By.xpath("//li/a[contains(@href, '#/interpreter')]"));
|
||||
|
||||
collector.checkThat("Check is user has permission to view this page", true,
|
||||
CoreMatchers.equalTo(pollingWait(By.xpath(
|
||||
"//div[@id='main']/div/div[2]"),
|
||||
MIN_IMPLICIT_WAIT).isDisplayed())
|
||||
);
|
||||
|
||||
authenticationIT.logoutUser("finance1");
|
||||
|
||||
authenticationIT.authenticationUser("hr1", "hr1");
|
||||
|
||||
pollingWait(By.xpath("//div/button[contains(@class, 'nav-btn dropdown-toggle ng-scope')]"),
|
||||
MAX_BROWSER_TIMEOUT_SEC).click();
|
||||
clickAndWait(By.xpath("//li/a[contains(@href, '#/interpreter')]"));
|
||||
|
||||
try {
|
||||
collector.checkThat("Check is user has permission to view this page",
|
||||
true, CoreMatchers.equalTo(
|
||||
pollingWait(By.xpath("//li[contains(@class, 'ng-toast__message')]//span/span"),
|
||||
MIN_IMPLICIT_WAIT).isDisplayed()));
|
||||
} catch (TimeoutException e) {
|
||||
throw new Exception("Expected ngToast not found", e);
|
||||
}
|
||||
authenticationIT.logoutUser("hr1");
|
||||
|
||||
} catch (Exception e) {
|
||||
handleException("Exception in AuthenticationIT while testAnyOfRoles ", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroupPermission() throws Exception {
|
||||
if (!endToEndTestEnabled()) {
|
||||
|
|
@ -254,7 +312,7 @@ public class AuthenticationIT extends AbstractZeppelinIT {
|
|||
|
||||
|
||||
} catch (Exception e) {
|
||||
handleException("Exception in ParagraphActionsIT while testGroupPermission ", e);
|
||||
handleException("Exception in AuthenticationIT while testGroupPermission ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue