use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.
the class AdminRealmTest method testGetAccount_ifLoggedUserNotAdmin.
@Test
public void testGetAccount_ifLoggedUserNotAdmin() {
Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
settings.setAdminUsername("admin");
SimpleAccount actual = adminRealm.getAccount("user", settings);
assertNull(actual);
}
use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.
the class AdminSetupControlFilterTest method testIsAccessAllowed_ifRequestNotSetupPage_AndAdminSettingsNotRequired.
@Test
public void testIsAccessAllowed_ifRequestNotSetupPage_AndAdminSettingsNotRequired() {
filter = createMockBuilder(AdminSetupControlFilter.class).addMockedMethod("isSetupPageRequest", ServletRequest.class).createMock();
Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
settings.setAdminUsername("admin");
settings.setAdminPassword("pass");
PowerMock.mockStatic(CDIUtils.class);
expect(CDIUtils.getBean(SettingsService.class)).andReturn(settingsService);
expect(settingsService.getSettings()).andReturn(settings);
expect(filter.isSetupPageRequest(request)).andReturn(false);
PowerMock.replayAll(CDIUtils.class, settingsService, filter);
boolean actual = filter.isAccessAllowed(request, response, null);
PowerMock.verifyAll();
assertTrue(actual);
}
use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.
the class AdminSetupControlFilterTest method testOnAccessDenied_ifAdminSettingsNotRequired_andRequestSetupPage.
@Test
public void testOnAccessDenied_ifAdminSettingsNotRequired_andRequestSetupPage() throws Exception {
filter = createMockBuilder(AdminSetupControlFilter.class).addMockedMethod("isSetupPageRequest", ServletRequest.class).createMock();
Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
settings.setAdminUsername("admin");
settings.setAdminPassword("pass");
PowerMock.mockStatic(CDIUtils.class);
expect(CDIUtils.getBean(SettingsService.class)).andReturn(settingsService);
expect(settingsService.getSettings()).andReturn(settings);
expect(filter.isSetupPageRequest(request)).andReturn(true);
response.sendError(403);
PowerMock.replayAll(CDIUtils.class, settingsService, response, filter);
boolean actual = filter.onAccessDenied(request, response);
PowerMock.verifyAll();
assertFalse(actual);
}
use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.
the class AdminSetupControlFilterTest method testOnAccessDenied_ifAdminSettingsRequired.
@Test
public void testOnAccessDenied_ifAdminSettingsRequired() throws Exception {
Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
settings.setAdminUsername(null);
PowerMock.mockStatic(CDIUtils.class);
PowerMock.mockStatic(WebUtils.class);
expect(CDIUtils.getBean(SettingsService.class)).andReturn(settingsService);
expect(settingsService.getSettings()).andReturn(settings);
WebUtils.issueRedirect(request, response, "/adminAccountSetup.xhtml");
PowerMock.replayAll(CDIUtils.class, WebUtils.class, settingsService);
boolean actual = filter.onAccessDenied(request, response);
PowerMock.verifyAll();
assertFalse(actual);
}
use of com.artezio.arttime.config.Settings in project ART-TIME by Artezio.
the class IniWebEnvironmentTest method testBuildGroupRolesMap.
@Test
public void testBuildGroupRolesMap() {
Settings settings = new Settings(new EnumMap<>(Setting.Name.class));
settings.setLdapCommonNameAttribute("CN");
settings.setExecRoleMemberOf("EXEC_GROUP,ONE-MORE-EXEC-GROUP");
settings.setIntegrationClientGroups("INTEGRATION-CLIENT");
settings.setLdapUserContextDN("DC=MyCompany,DC=local");
String expected = "\"CN=INTEGRATION-CLIENT,DC=MyCompany,DC=local\":\"ArtTimeIntegrationClient\",\"CN=ONE-MORE-EXEC-GROUP,DC=MyCompany,DC=local\":\"exec\",\"CN=EXEC_GROUP,DC=MyCompany,DC=local\":\"exec\"";
String actual = iniWebEnvironment.getGroupRolesMapProperty(settings);
assertEquals(expected, actual);
}
Aggregations