Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public enum Key {
USER_PASSWORD_RECOVERY_SENT_MAIL_SUCCESS(true),
USER_ACTIVATION_SENT_MAIL_FAIL(false),
USER_ACTIVATION_SENT_MAIL_SUCCESS(true),
USER_CREATE_SUCCESS_ACTIVATION_MAIL_FAIL(true),
GALLERY_UPLOAD_SUCCESS(true),
GALLERY_UPLOAD_ERROR(false),
LIKE_SAVE_SUCCESS(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ public Response createUser(@OraData DbSession dbSession, FullRestRequest fullReq
String lang = request.getLanguage();
PendingEmailConfirmations confirmation = pendingConfirmationProcessor.createEmailConfirmation(newUser);
sendActivationMail(up, confirmation.getUrlPostfix(), account, email, lang, isYoungerThen14, httpSessionState.getUrl());
if ( up.getMessage() == Key.USER_ACTIVATION_SENT_MAIL_FAIL ) {
up.setStatus(
ProcessorStatus.SUCCEEDED,
Key.USER_CREATE_SUCCESS_ACTIVATION_MAIL_FAIL,
new HashMap<>());
}
}
Statistics.info("UserCreate", "success", up.succeeded());
UtilForREST.addResultInfo(response, up);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public abstract class AbstractRestInterfaceTest {

protected Map<String, RobotFactory> robotPlugins;

protected MailManagement mailManagement;

//this is the setup class and should be called before testing
protected void setup() throws Exception {
ServerStarter.initLoggingBeforeFirstUse(new String[0]);
Expand All @@ -122,8 +124,8 @@ protected void setup() throws Exception {

this.robotCommunicator = new RobotCommunicator();

MailManagement mailManagement = Mockito.mock(MailManagement.class);
this.restUser = new ClientUser(this.robotCommunicator, this.serverProperties, mailManagement);
this.mailManagement = Mockito.mock(MailManagement.class);
this.restUser = new ClientUser(this.robotCommunicator, this.serverProperties, this.mailManagement);

tc = TestConfiguration.setup();
tc.deleteAllFromUserAndProgramTmpPasswords();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package de.fhg.iais.roberta.javaServer.basics.restInterface;

import javax.mail.MessagingException;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;

import de.fhg.iais.roberta.util.Key;

Expand All @@ -20,6 +23,7 @@ public void userWorkflowTest() throws Exception {
updateUser();
changeUserPassword();
loginLogoutPid();
createUserWhenActivationMailFails();
}

/**
Expand Down Expand Up @@ -195,4 +199,11 @@ private void loginLogoutPid() throws Exception {
Assert.assertTrue(this.sPid.isUserLoggedIn() && this.sMinscha.isUserLoggedIn());
}


private void createUserWhenActivationMailFails() throws Exception {
long userCountBefore = this.memoryDbSetup.getOneBigIntegerAsLong("select count(*) from USER");
Mockito.doThrow(new MessagingException("Test activation mail failure")).when(this.mailManagement).send(Mockito.anyString(), Mockito.eq("activate"), Mockito.any(String[].class), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString());
restUser(this.sPid, "{'cmd':'createUser';'accountName':'mailFailUser';'userName':'Mail Fail';'password':'1234';'userEmail':'mailfail@example.com';'role':'STUDENT', 'isYoungerThen14': false, 'language': 'de'}", "ok", Key.USER_CREATE_SUCCESS_ACTIVATION_MAIL_FAIL);
Assert.assertEquals(userCountBefore + 1, this.memoryDbSetup.getOneBigIntegerAsLong("select count(*) from USER"));
}
}
20 changes: 10 additions & 10 deletions OpenRobertaServer/staticResources/blockly/blockly_compressed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions OpenRobertaServer/staticResources/blockly/msg/js/ar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,7 @@ Blockly.Msg.ORA_USER_CREATE_ERROR_CONTAINS_SPECIAL_CHARACTERS = "You are using s
Blockly.Msg.ORA_USER_CREATE_ERROR_MISSING_REQ_FIELDS = "Please make sure you have filled in all required fields! Your account couldn't be created."; // untranslated
Blockly.Msg.ORA_USER_CREATE_ERROR_NOT_SAVED_TO_DB = "The given user name already exists in the database, please choose another user name."; // untranslated
Blockly.Msg.ORA_USER_CREATE_SUCCESS = "Your user account »$« was successfully created!"; // untranslated
Blockly.Msg.ORA_USER_CREATE_SUCCESS_ACTIVATION_MAIL_FAIL = "Your account was created, but the activation email could not be sent. You can update your email or resend the activation link under Login → Change."; // untranslated
Blockly.Msg.ORA_USER_DEACTIVATION_SUCCESS = "Your account is currently not verified, please check your mailbox!"; // untranslated
Blockly.Msg.ORA_USER_DELETE_ERROR_HAS_GROUPS = "You have user groups associated with your account. Please delete them first, before you delete your account."; // untranslated
Blockly.Msg.ORA_USER_DELETE_ERROR_ID_NOT_FOUND = "Error while deleting user."; // untranslated
Expand Down
1 change: 1 addition & 0 deletions OpenRobertaServer/staticResources/blockly/msg/js/az.js
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,7 @@ Blockly.Msg.ORA_USER_CREATE_ERROR_CONTAINS_SPECIAL_CHARACTERS = "You are using s
Blockly.Msg.ORA_USER_CREATE_ERROR_MISSING_REQ_FIELDS = "Please make sure you have filled in all required fields! Your account couldn't be created."; // untranslated
Blockly.Msg.ORA_USER_CREATE_ERROR_NOT_SAVED_TO_DB = "The given user name already exists in the database, please choose another user name."; // untranslated
Blockly.Msg.ORA_USER_CREATE_SUCCESS = "Your user account »$« was successfully created!"; // untranslated
Blockly.Msg.ORA_USER_CREATE_SUCCESS_ACTIVATION_MAIL_FAIL = "Your account was created, but the activation email could not be sent. You can update your email or resend the activation link under Login → Change."; // untranslated
Blockly.Msg.ORA_USER_DEACTIVATION_SUCCESS = "Your account is currently not verified, please check your mailbox!"; // untranslated
Blockly.Msg.ORA_USER_DELETE_ERROR_HAS_GROUPS = "You have user groups associated with your account. Please delete them first, before you delete your account."; // untranslated
Blockly.Msg.ORA_USER_DELETE_ERROR_ID_NOT_FOUND = "Error while deleting user."; // untranslated
Expand Down
Loading
Loading