use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class TestActivityStream method testLastUpdate.
public void testLastUpdate() throws Throwable {
// "coach" group
Content content = this._contentManager.loadContent("EVN41", false);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(content, ApsAdminSystemConstants.ADD);
content.setId(null);
String contentId = null;
Thread.sleep(1000);
try {
this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, content);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentId = content.getId();
assertNotNull(this._contentManager.loadContent(contentId, false));
super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
ActionLogRecordSearchBean searchBean = this._helper.createSearchBean("admin", null, null, null, null, null);
List<Integer> ids = this._actionLoggerManager.getActionRecords(searchBean);
assertEquals(1, ids.size());
Thread.sleep(1000);
this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, content);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentId = content.getId();
assertNotNull(this._contentManager.loadContent(contentId, false));
super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
List<Integer> actionRecords = this._actionLoggerManager.getActionRecords(null);
assertNotNull(actionRecords);
assertEquals(2, actionRecords.size());
ActionLogRecord actionRecord = this._actionLoggerManager.getActionRecord(actionRecords.get(1));
UserDetails adminUser = this.getUser("admin", "admin");
Date lastUpdateDate = this._actionLoggerManager.lastUpdateDate(adminUser);
assertEquals(actionRecord.getUpdateDate(), lastUpdateDate);
} catch (Throwable t) {
throw t;
} finally {
this._contentManager.deleteContent(content);
assertNull(this._contentManager.loadContent(contentId, false));
}
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class TestActivityStream method testSaveNewContent_1.
// ----------------------------------------------
public void testSaveNewContent_1() throws Throwable {
Content content = this._contentManager.loadContent("ART1", false);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(content, ApsAdminSystemConstants.ADD);
content.setId(null);
String contentId = null;
try {
this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, content);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentId = content.getId();
assertNotNull(this._contentManager.loadContent(contentId, false));
super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
ActionLogRecordSearchBean searchBean = this._helper.createSearchBean("admin", null, null, null, null, null);
List<Integer> ids = this._actionLoggerManager.getActionRecords(searchBean);
assertEquals(1, ids.size());
UserDetails currentUser = (UserDetails) super.getRequest().getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
List<Integer> activityStream = this._actionLoggerManager.getActivityStream(currentUser);
assertEquals(activityStream.size(), ids.size());
assertEquals(activityStream.get(0), ids.get(0));
ActionLogRecord record = this._actionLoggerManager.getActionRecord(ids.get(0));
assertEquals("/do/jacms/Content", record.getNamespace());
assertEquals("save", record.getActionName());
ActivityStreamInfo asi = record.getActivityStreamInfo();
assertNotNull(asi);
assertEquals(1, asi.getActionType());
assertEquals(Permission.CONTENT_EDITOR, asi.getLinkAuthPermission());
assertEquals(content.getMainGroup(), asi.getLinkAuthGroup());
assertEquals("edit", asi.getLinkActionName());
assertEquals("/do/jacms/Content", asi.getLinkNamespace());
// assertEquals(1, asi.getLinkParameters().size());
Properties parameters = asi.getLinkParameters();
assertEquals(1, parameters.size());
assertEquals(contentId, parameters.getProperty("contentId"));
} catch (Throwable t) {
throw t;
} finally {
this._contentManager.deleteContent(content);
assertNull(this._contentManager.loadContent(contentId, false));
}
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class TestUserAction method testFailureDisableAdminUser.
public void testFailureDisableAdminUser() throws Throwable {
String username = SystemConstants.ADMIN_USER_NAME;
UserDetails adminUser = this._userManager.getUser(username);
try {
this.setUserOnSession("admin");
this.initAction("/do/User", "save");
this.addParameter("strutsAction", String.valueOf(ApsAdminSystemConstants.EDIT));
this.addParameter("username", username);
this.addParameter("active", "false");
String result = this.executeAction();
assertEquals(Action.INPUT, result);
Map<String, List<String>> fieldErrors = this.getAction().getFieldErrors();
assertEquals(1, fieldErrors.size());
List<String> errors = fieldErrors.get("active");
assertEquals(1, errors.size());
} catch (Throwable t) {
this._userManager.updateUser(adminUser);
throw t;
}
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class TestUserAction method testAddNew_1.
public void testAddNew_1() throws Throwable {
String username = "usernameForTest";
String password = "password";
try {
this.setUserOnSession("admin");
this.initAction("/do/User", "save");
this.addParameter("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
this.addParameter("username", username);
this.addParameter("password", password);
this.addParameter("passwordConfirm", password);
this.addParameter("active", "true");
this.addParameter("profileTypeCode", SystemConstants.DEFAULT_PROFILE_TYPE_CODE);
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
UserDetails extracted = this._userManager.getUser(username, password);
assertNotNull(extracted);
assertFalse(extracted.isDisabled());
} catch (Throwable t) {
throw t;
} finally {
this._userManager.removeUser(username);
}
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class TestUserAction method testAddNew_2.
public void testAddNew_2() throws Throwable {
// the dot '.' is accepted in the username as well as the underscore '_'
String username = "user.name_for_test";
String password = "password";
try {
this.setUserOnSession("admin");
this.initAction("/do/User", "save");
this.addParameter("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
this.addParameter("username", username);
this.addParameter("password", password);
this.addParameter("passwordConfirm", password);
this.addParameter("active", "true");
this.addParameter("profileTypeCode", SystemConstants.DEFAULT_PROFILE_TYPE_CODE);
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
UserDetails extracted = this._userManager.getUser(username, password);
assertNotNull(extracted);
assertFalse(extracted.isDisabled());
} catch (Throwable t) {
throw t;
} finally {
this._userManager.removeUser(username);
assertNull(this._userManager.getUser(username));
}
}
Aggregations