use of net.n2oapp.framework.config.test.SimplePropertyResolver in project n2o-framework by i-novus-llc.
the class AccessHeaderAT method testAdminAccess.
@Test
public void testAdminAccess() {
Map<String, Object> user = new HashMap<>();
user.put("username", "Admin");
user.put("roles", Collections.singleton("admin"));
user.put("permissions", Collections.singleton("edit"));
setUserInfo(user);
((SimplePropertyResolver) builder.getEnvironment().getSystemProperties()).setProperty("n2o.access.schema.id", "schema");
builder.getEnvironment().getContextProcessor().set("username", user.get("username"));
SimplePage page = open(SimplePage.class);
page.shouldExists();
page.header().brandNameShouldBe("Шапка");
page.widget(FormWidget.class).shouldExists();
page.breadcrumb().titleShouldHaveText("Главная страница");
page.header().nav().shouldHaveSize(3);
AnchorMenuItem menuItem0 = page.header().nav().anchor(0);
menuItem0.labelShouldHave("Доступно всем");
menuItem0.urlShouldHave(getBaseUrl() + "/#/menu1");
menuItem0.click();
page.breadcrumb().titleShouldHaveText("Страница доступная всем");
AnchorMenuItem menuItem1 = page.header().nav().anchor(1);
menuItem1.labelShouldHave("Требуется роль admin");
menuItem1.urlShouldHave(getBaseUrl() + "/#/menu2");
menuItem1.click();
page.breadcrumb().titleShouldHaveText("Страница доступная с ролью admin");
AnchorMenuItem menuItem2 = page.header().nav().anchor(2);
menuItem2.labelShouldHave("Требуется право edit");
menuItem2.urlShouldHave(getBaseUrl() + "/#/menu3");
menuItem2.click();
page.breadcrumb().titleShouldHaveText("Страница доступная с правом edit");
page.header().extra().shouldHaveSize(1);
AnchorMenuItem extraLink = page.header().extra().item(0, AnchorMenuItem.class);
extraLink.labelShouldHave("Admin");
extraLink.click();
page.breadcrumb().titleShouldHaveText("Главная страница");
}
use of net.n2oapp.framework.config.test.SimplePropertyResolver in project n2o-framework by i-novus-llc.
the class AccessHeaderAT method testAnonymousAccess.
@Test
public void testAnonymousAccess() {
setUserInfo(null);
((SimplePropertyResolver) builder.getEnvironment().getSystemProperties()).setProperty("n2o.access.schema.id", "schema");
SimplePage page = open(SimplePage.class);
page.shouldExists();
page.header().brandNameShouldBe("Шапка");
page.widget(FormWidget.class).shouldExists();
page.breadcrumb().titleShouldHaveText("Главная страница");
page.header().nav().shouldHaveSize(2);
AnchorMenuItem menuItem0 = page.header().nav().anchor(0);
menuItem0.labelShouldHave("Доступно всем");
menuItem0.urlShouldHave(getBaseUrl() + "/#/menu1");
menuItem0.click();
page.breadcrumb().titleShouldHaveText("Страница доступная всем");
AnchorMenuItem menuItem3 = page.header().nav().anchor(1);
menuItem3.labelShouldHave("Только анонимам");
menuItem3.urlShouldHave(getBaseUrl() + "/#/menu4");
menuItem3.click();
page.breadcrumb().titleShouldHaveText("Страница доступная только анонимам");
}
use of net.n2oapp.framework.config.test.SimplePropertyResolver in project n2o-framework by i-novus-llc.
the class ApplicationAccessTransformerTest method testHeaderSidebarTransformV2permitAll.
@Test
public void testHeaderSidebarTransformV2permitAll() {
((SimplePropertyResolver) builder.getEnvironment().getSystemProperties()).setProperty("n2o.access.schema.id", "testHeaderV2permitAll");
ReadCompileTerminalPipeline pipeline = compile("net/n2oapp/framework/access/metadata/schema/testHeaderV2permitAll.access.xml", "net/n2oapp/framework/access/metadata/transform/testApplicationAccessTransformer.application.xml");
Application application = (Application) ((ReadCompileTerminalPipeline) pipeline.transform()).get(new ApplicationContext("testApplicationAccessTransformer"));
checkPermitAll(((Security) application.getHeader().getMenu().getItems().get(0).getProperties().get(SECURITY_PROP_NAME)).getSecurityMap());
checkPermitAll(((Security) application.getSidebar().getMenu().getItems().get(0).getProperties().get(SECURITY_PROP_NAME)).getSecurityMap());
}
use of net.n2oapp.framework.config.test.SimplePropertyResolver in project n2o-framework by i-novus-llc.
the class ApplicationAccessTransformerTest method testHeaderSidebarTransformV2Auth.
@Test
public void testHeaderSidebarTransformV2Auth() {
((SimplePropertyResolver) builder.getEnvironment().getSystemProperties()).setProperty("n2o.access.schema.id", "testHeaderV2auth");
ReadCompileTerminalPipeline pipeline = compile("net/n2oapp/framework/access/metadata/schema/testHeaderV2auth.access.xml", "net/n2oapp/framework/access/metadata/transform/testApplicationAccessTransformer.application.xml");
Application application = (Application) ((ReadCompileTerminalPipeline) pipeline.transform()).get(new ApplicationContext("testApplicationAccessTransformer"));
checkAuth(((Security) application.getHeader().getMenu().getItems().get(0).getProperties().get(SECURITY_PROP_NAME)).getSecurityMap());
checkAuth(((Security) application.getSidebar().getMenu().getItems().get(0).getProperties().get(SECURITY_PROP_NAME)).getSecurityMap());
}
use of net.n2oapp.framework.config.test.SimplePropertyResolver in project n2o-framework by i-novus-llc.
the class ApplicationAccessTransformerTest method testHeaderSidebarTransformV2Anonym.
@Test
public void testHeaderSidebarTransformV2Anonym() {
((SimplePropertyResolver) builder.getEnvironment().getSystemProperties()).setProperty("n2o.access.schema.id", "testHeaderV2anonym");
ReadCompileTerminalPipeline pipeline = compile("net/n2oapp/framework/access/metadata/schema/testHeaderV2anonym.access.xml", "net/n2oapp/framework/access/metadata/transform/testApplicationAccessTransformer.application.xml");
Application application = (Application) ((ReadCompileTerminalPipeline) pipeline.transform()).get(new ApplicationContext("testApplicationAccessTransformer"));
checkAnonym(((Security) application.getHeader().getMenu().getItems().get(0).getProperties().get(SECURITY_PROP_NAME)).getSecurityMap());
checkAnonym(((Security) application.getSidebar().getMenu().getItems().get(0).getProperties().get(SECURITY_PROP_NAME)).getSecurityMap());
}
Aggregations