Skip to content

Commit

Permalink
Fixed typo in the adm_user_selfregistration table and in the classes …
Browse files Browse the repository at this point in the history
…that depends on it. #1139
  • Loading branch information
zigfridus committed Dec 13, 2023
1 parent 9c12572 commit 34d998c
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 63 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 All @@ -86,10 +86,10 @@ public void listUserSignups_results_in_a_filled_list_when_2_signups_exist() thro
).
andExpect(status().isOk()).
andExpect(jsonPath("$.[0].userId", equalTo("sechub.test1"))).
andExpect(jsonPath("$.[0].emailAdress", equalTo("sechub.test1@example.org"))).
andExpect(jsonPath("$.[0].emailAddress", equalTo("sechub.test1@example.org"))).

andExpect(jsonPath("$.[1].userId", equalTo("sechub.test2"))).
andExpect(jsonPath("$.[1].emailAdress", equalTo("sechub.test2@example.org"))
andExpect(jsonPath("$.[1].emailAddress", equalTo("sechub.test2@example.org"))

);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ protected void initDelegateWithDefaults() {
}

public String getEmailAdress() {
return delegate.getEmailAdress();
return delegate.getEmailAddress();
}

public String getUserId() {
return delegate.getUserId();
}

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

public void setUserId(String userId) {
Expand Down
64 changes: 32 additions & 32 deletions sechub-api-java/src/main/resources/reduced-openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -2505,6 +2505,25 @@
"type": "string"
}
},
"ListOfSignups": {
"title": "ListOfSignups",
"type": "array",
"description": "List of user signups",
"items": {
"type": "object",
"properties": {
"emailAddress": {
"type": "string",
"description": "The email address"
},
"userId": {
"type": "string",
"description": "The user id"
}
},
"description": "List of user signups"
}
},
"UserSignup": {
"title": "UserSignup",
"type": "object",
Expand Down Expand Up @@ -3251,19 +3270,6 @@
"webScan": {
"type": "object",
"properties": {
"maxScanDuration": {
"type": "object",
"properties": {
"duration": {
"type": "number",
"description": "Duration of the scan as integer"
},
"unit": {
"type": "string",
"description": "Unit of the duration. Possible values are: millisecond(s), second(s), minute(s), hour(s), day(s)"
}
}
},
"headers": {
"type": "array",
"description": "List of HTTP headers. Can be used for authentication or anything else.",
Expand Down Expand Up @@ -3292,6 +3298,19 @@
}
}
},
"maxScanDuration": {
"type": "object",
"properties": {
"duration": {
"type": "number",
"description": "Duration of the scan as integer"
},
"unit": {
"type": "string",
"description": "Unit of the duration. Possible values are: millisecond(s), second(s), minute(s), hour(s), day(s)"
}
}
},
"clientCertificate": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -3537,25 +3556,6 @@
}
}
},
"ListOfSignups": {
"title": "ListOfSignups",
"type": "array",
"description": "List of user signups",
"items": {
"type": "object",
"properties": {
"emailAdress": {
"type": "string",
"description": "The email address"
},
"userId": {
"type": "string",
"description": "The user id"
}
},
"description": "List of user signups"
}
},
"ListOfRunningJobs": {
"title": "ListOfRunningJobs",
"type": "array",
Expand Down
2 changes: 1 addition & 1 deletion sechub-developertools/scripts/sechub-api.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ function generate_sechub_user_signup_data {
{
"apiVersion":"$SECHUB_API_VERSION",
"userId":"$1",
"emailAdress":"$2"
"emailAddress":"$2"
}
EOF
}
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 All @@ -97,7 +97,7 @@ public void restdoc_list_user_signups() throws Exception {
header(AuthenticationHelper.HEADER_NAME, AuthenticationHelper.getHeaderValue())
).
andExpect(status().isOk()).
andExpect(content().json("[{\"userId\":\"johnsmith\",\"emailAdress\":\"john.smith@example.com\"},{\"userId\":\"janesmith\",\"emailAdress\":\"jane.smith@example.com\"}]")).
andExpect(content().json("[{\"userId\":\"johnsmith\",\"emailAddress\":\"john.smith@example.com\"},{\"userId\":\"janesmith\",\"emailAddress\":\"jane.smith@example.com\"}]")).
andDo(defineRestService().
with().
useCaseData(useCase).
Expand All @@ -111,7 +111,7 @@ public void restdoc_list_user_signups() throws Exception {
responseFields(
fieldWithPath("[]").description("List of user signups").optional(),
fieldWithPath("[]."+RestDocPathParameter.USER_ID.paramName()).type(JsonFieldType.STRING).description("The user id"),
fieldWithPath("[].emailAdress").type(JsonFieldType.STRING).description("The email address")
fieldWithPath("[].emailAddress").type(JsonFieldType.STRING).description("The email address")
)
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ public static SortedMap<String, String> listSignups() {
@Override
public void accept(JsonNode node) {
JsonNode userAsKey = node.get("userId");
JsonNode emailAsValue = node.get("emailAdress");
JsonNode emailAsValue = node.get("emailAddress");
String keyText = userAsKey.textValue();
String valueText = emailAsValue.textValue();
map.put(keyText, valueText);
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 34d998c

Please sign in to comment.