Search in sources :

Example 21 with Settings

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);
}
Also used : SimpleAccount(org.apache.shiro.authc.SimpleAccount) Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 22 with Settings

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);
}
Also used : Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 23 with Settings

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);
}
Also used : Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 24 with Settings

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);
}
Also used : Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 25 with Settings

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);
}
Also used : Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Settings (com.artezio.arttime.config.Settings)40 Test (org.junit.Test)31 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)21 Setting (com.artezio.arttime.config.Setting)9 EnumMap (java.util.EnumMap)5 Before (org.junit.Before)5 SimpleAccount (org.apache.shiro.authc.SimpleAccount)4 Instance (javax.enterprise.inject.Instance)3 Properties (java.util.Properties)2 URLName (javax.mail.URLName)2 ApplicationSettings (com.artezio.arttime.config.ApplicationSettings)1 Employee (com.artezio.arttime.datamodel.Employee)1 ProjectService (com.artezio.arttime.services.ProjectService)1 SettingsService (com.artezio.arttime.services.SettingsService)1 UserInfo (com.artezio.arttime.services.integration.spi.UserInfo)1 Duration (java.time.Duration)1 java.util (java.util)1 HashMap (java.util.HashMap)1 Timer (javax.ejb.Timer)1 TimerConfig (javax.ejb.TimerConfig)1