Skip to content

Commit

Permalink
Initial commit for mercedes-benz#1139
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Nov 19, 2023
1 parent 5f5111e commit 2196b6c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ public class AnonymousSignupCreateService {
@UseCaseUserSignup(@Step(number = 2, name = "Persistence", description = "Valid self registration input will be persisted to database."))
public void register(@Valid SignupJsonInput userSelfRegistrationInput) {
String userId = userSelfRegistrationInput.getUserId();
String emailAdress = userSelfRegistrationInput.getEmailAdress();
String emailAddress = userSelfRegistrationInput.getEmailAdress();

LOG.debug("user tries to register himself:{},mail:{}", userId, emailAdress);
LOG.debug("user tries to register himself:{},mail:{}", userId, emailAddress);

assertion.assertIsValidUserId(userId);
assertion.assertIsValidEmailAddress(emailAdress);
assertion.assertIsValidEmailAddress(emailAddress);

assertNotAlreadySignedIn(userId, emailAdress);
assertUsernameNotUsedAlready(userId, emailAdress);
assertEmailAdressNotUsedAlready(userId, emailAdress);
assertNotAlreadySignedIn(userId, emailAddress);
assertUsernameNotUsedAlready(userId, emailAddress);
assertEmailAdressNotUsedAlready(userId, emailAddress);

Signup entity = new Signup();

entity.setEmailAdress(emailAdress);
entity.setEmailAddress(emailAddress);
entity.setUserId(userId);
userSelfRegistrationRepository.save(entity);
LOG.debug("Added registration entry for user:{},mail:{}", entity.getUserId(), entity.getEmailAdress());
LOG.debug("Added registration entry for user:{},mail:{}", entity.getUserId(), entity.getEmailAddress());

/* trigger event */
informAboutSignupRequest(entity);
Expand All @@ -81,7 +81,7 @@ private void informAboutSignupRequest(Signup signup) {
DomainMessage infoRequest = new DomainMessage(MessageID.USER_SIGNUP_REQUESTED);

UserMessage userMessage = new UserMessage();
userMessage.setEmailAdress(signup.getEmailAdress());
userMessage.setEmailAdress(signup.getEmailAddress());
userMessage.setUserId(signup.getUserId());

infoRequest.set(MessageDataKeys.USER_SIGNUP_DATA, userMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public class Signup {
public static final String TABLE_NAME = "ADM_USER_SELFREGISTRATION";

/**
* Email adress is also the primary key. So no duplicates
* Email address is also the primary key. So no duplicates
*/
public static final String COLUMN_EMAIL_ADRESS = "EMAIL_ADRESS";
public static final String COLUMN_EMAIL_ADDRESS = "EMAIL_ADDRESS";
public static final String COLUMN_USER_ID = "USER_ID";

/* +-----------------------------------------------------------------------+ */
Expand All @@ -33,23 +33,23 @@ public class Signup {
@Column(name = COLUMN_USER_ID)
String userId;

@Column(name = COLUMN_EMAIL_ADRESS, nullable = false)
String emailAdress;
@Column(name = COLUMN_EMAIL_ADDRESS, nullable = false)
String emailAddress;

@Version
@Column(name = "VERSION")
Integer version;

public void setEmailAdress(String emailAdress) {
this.emailAdress = emailAdress;
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}

public void setUserId(String userId) {
this.userId = userId;
}

public String getEmailAdress() {
return emailAdress;
public String getEmailAddress() {
return emailAddress;
}

public String getUserId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void createUserFromSelfRegistration(String userId) {
return;
}

String emailAdress = selfRegistration.get().getEmailAdress();
String emailAdress = selfRegistration.get().getEmailAddress();
assertion.assertIsValidEmailAddress(emailAdress);

found = userRepository.findByEmailAdress(emailAdress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ public void listUserSignups_results_in_a_filled_list_when_2_signups_exist() thro
/* prepare */
List<Signup> list = new ArrayList<>();
Signup signup1 = new Signup();
signup1.setEmailAdress("sechub.test1@example.org");
signup1.setEmailAddress("sechub.test1@example.org");
signup1.setUserId("sechub.test1");

Signup signup2 = new Signup();
signup2.setEmailAdress("sechub.test2@example.org");
signup2.setEmailAddress("sechub.test2@example.org");
signup2.setUserId("sechub.test2");

list.add(signup1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ public void restdoc_list_user_signups() throws Exception {
Class<? extends Annotation> useCase = UseCaseAdminListsOpenUserSignups.class;

Signup signup1 = new Signup();
signup1.setEmailAdress("john.smith@example.com");
signup1.setEmailAddress("john.smith@example.com");
signup1.setUserId("johnsmith");

Signup signup2 = new Signup();
signup2.setEmailAdress("jane.smith@example.com");
signup2.setEmailAddress("jane.smith@example.com");
signup2.setUserId("janesmith");

List<Signup> signupList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- SPDX-License-Identifier: MIT
ALTER TABLE adm_user_selfregistration
RENAME COLUMN email_address TO email_adress;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- SPDX-License-Identifier: MIT
ALTER TABLE adm_user_selfregistration
RENAME COLUMN email_adress TO email_address;

0 comments on commit 2196b6c

Please sign in to comment.