From 34d998c0282bf6b2ef09dffa4736779d74e46fd5 Mon Sep 17 00:00:00 2001 From: Valentyn Grygoriev Date: Wed, 13 Dec 2023 18:19:30 +0200 Subject: [PATCH] Fixed typo in the adm_user_selfregistration table and in the classes that depends on it. #1139 --- .../signup/AnonymousSignupCreateService.java | 18 +++--- .../domain/administration/signup/Signup.java | 16 ++--- .../user/UserCreationService.java | 2 +- ...pAdministrationRestControllerMockTest.java | 8 +-- .../model/InternalAccessOpenUserSignup.java | 6 +- .../src/main/resources/reduced-openapi3.json | 64 +++++++++---------- sechub-developertools/scripts/sechub-api.sh | 2 +- ...ministrationRestControllerRestDocTest.java | 8 +-- .../sechub/integrationtest/api/TestAPI.java | 2 +- .../U27__rename_emailAdress_column.sql | 3 + .../V27__rename_emailAdress_column.sql | 3 + 11 files changed, 69 insertions(+), 63 deletions(-) mode change 100755 => 100644 sechub-developertools/scripts/sechub-api.sh create mode 100644 sechub-server/src/main/resources/db/migration/U27__rename_emailAdress_column.sql create mode 100644 sechub-server/src/main/resources/db/migration/V27__rename_emailAdress_column.sql diff --git a/sechub-administration/src/main/java/com/mercedesbenz/sechub/domain/administration/signup/AnonymousSignupCreateService.java b/sechub-administration/src/main/java/com/mercedesbenz/sechub/domain/administration/signup/AnonymousSignupCreateService.java index e89d1806e8..63f346783f 100644 --- a/sechub-administration/src/main/java/com/mercedesbenz/sechub/domain/administration/signup/AnonymousSignupCreateService.java +++ b/sechub-administration/src/main/java/com/mercedesbenz/sechub/domain/administration/signup/AnonymousSignupCreateService.java @@ -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); @@ -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); diff --git a/sechub-administration/src/main/java/com/mercedesbenz/sechub/domain/administration/signup/Signup.java b/sechub-administration/src/main/java/com/mercedesbenz/sechub/domain/administration/signup/Signup.java index 1ae5683dd4..031b8359ae 100644 --- a/sechub-administration/src/main/java/com/mercedesbenz/sechub/domain/administration/signup/Signup.java +++ b/sechub-administration/src/main/java/com/mercedesbenz/sechub/domain/administration/signup/Signup.java @@ -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"; /* +-----------------------------------------------------------------------+ */ @@ -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() { diff --git a/sechub-administration/src/main/java/com/mercedesbenz/sechub/domain/administration/user/UserCreationService.java b/sechub-administration/src/main/java/com/mercedesbenz/sechub/domain/administration/user/UserCreationService.java index fd5ae0be1c..f492ebbd4d 100644 --- a/sechub-administration/src/main/java/com/mercedesbenz/sechub/domain/administration/user/UserCreationService.java +++ b/sechub-administration/src/main/java/com/mercedesbenz/sechub/domain/administration/user/UserCreationService.java @@ -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); diff --git a/sechub-administration/src/test/java/com/mercedesbenz/sechub/domain/administration/signup/SignupAdministrationRestControllerMockTest.java b/sechub-administration/src/test/java/com/mercedesbenz/sechub/domain/administration/signup/SignupAdministrationRestControllerMockTest.java index d5eec56574..bfe18f5c7e 100644 --- a/sechub-administration/src/test/java/com/mercedesbenz/sechub/domain/administration/signup/SignupAdministrationRestControllerMockTest.java +++ b/sechub-administration/src/test/java/com/mercedesbenz/sechub/domain/administration/signup/SignupAdministrationRestControllerMockTest.java @@ -69,11 +69,11 @@ public void listUserSignups_results_in_a_filled_list_when_2_signups_exist() thro /* prepare */ List 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); @@ -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")) ); diff --git a/sechub-api-java/src/main/java/com/mercedesbenz/sechub/api/internal/model/InternalAccessOpenUserSignup.java b/sechub-api-java/src/main/java/com/mercedesbenz/sechub/api/internal/model/InternalAccessOpenUserSignup.java index 7a9f062cfd..0a3e84eb10 100644 --- a/sechub-api-java/src/main/java/com/mercedesbenz/sechub/api/internal/model/InternalAccessOpenUserSignup.java +++ b/sechub-api-java/src/main/java/com/mercedesbenz/sechub/api/internal/model/InternalAccessOpenUserSignup.java @@ -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) { diff --git a/sechub-api-java/src/main/resources/reduced-openapi3.json b/sechub-api-java/src/main/resources/reduced-openapi3.json index dd10836526..ca98d26622 100644 --- a/sechub-api-java/src/main/resources/reduced-openapi3.json +++ b/sechub-api-java/src/main/resources/reduced-openapi3.json @@ -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", @@ -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.", @@ -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": { @@ -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", diff --git a/sechub-developertools/scripts/sechub-api.sh b/sechub-developertools/scripts/sechub-api.sh old mode 100755 new mode 100644 index fc7e8f18b9..a09e69ec1c --- a/sechub-developertools/scripts/sechub-api.sh +++ b/sechub-developertools/scripts/sechub-api.sh @@ -799,7 +799,7 @@ function generate_sechub_user_signup_data { { "apiVersion":"$SECHUB_API_VERSION", "userId":"$1", - "emailAdress":"$2" + "emailAddress":"$2" } EOF } diff --git a/sechub-doc/src/test/java/com/mercedesbenz/sechub/restdoc/SignupAdministrationRestControllerRestDocTest.java b/sechub-doc/src/test/java/com/mercedesbenz/sechub/restdoc/SignupAdministrationRestControllerRestDocTest.java index bc8f25c7fa..9b646168ad 100644 --- a/sechub-doc/src/test/java/com/mercedesbenz/sechub/restdoc/SignupAdministrationRestControllerRestDocTest.java +++ b/sechub-doc/src/test/java/com/mercedesbenz/sechub/restdoc/SignupAdministrationRestControllerRestDocTest.java @@ -78,11 +78,11 @@ public void restdoc_list_user_signups() throws Exception { Class 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 signupList = new ArrayList<>(); @@ -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). @@ -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") ) ) ); diff --git a/sechub-integrationtest/src/main/java/com/mercedesbenz/sechub/integrationtest/api/TestAPI.java b/sechub-integrationtest/src/main/java/com/mercedesbenz/sechub/integrationtest/api/TestAPI.java index 77cd98cbc1..49f71af73d 100644 --- a/sechub-integrationtest/src/main/java/com/mercedesbenz/sechub/integrationtest/api/TestAPI.java +++ b/sechub-integrationtest/src/main/java/com/mercedesbenz/sechub/integrationtest/api/TestAPI.java @@ -1079,7 +1079,7 @@ public static SortedMap 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); diff --git a/sechub-server/src/main/resources/db/migration/U27__rename_emailAdress_column.sql b/sechub-server/src/main/resources/db/migration/U27__rename_emailAdress_column.sql new file mode 100644 index 0000000000..179bfdec39 --- /dev/null +++ b/sechub-server/src/main/resources/db/migration/U27__rename_emailAdress_column.sql @@ -0,0 +1,3 @@ +-- SPDX-License-Identifier: MIT +ALTER TABLE adm_user_selfregistration + RENAME COLUMN email_address TO email_adress; diff --git a/sechub-server/src/main/resources/db/migration/V27__rename_emailAdress_column.sql b/sechub-server/src/main/resources/db/migration/V27__rename_emailAdress_column.sql new file mode 100644 index 0000000000..bb7a404751 --- /dev/null +++ b/sechub-server/src/main/resources/db/migration/V27__rename_emailAdress_column.sql @@ -0,0 +1,3 @@ +-- SPDX-License-Identifier: MIT +ALTER TABLE adm_user_selfregistration + RENAME COLUMN email_adress TO email_address;