Skip to content

Commit

Permalink
Prepare change to SIT
Browse files Browse the repository at this point in the history
  • Loading branch information
sayoungestguy committed Nov 3, 2024
1 parent d53a77f commit 68a217e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public User createUser(AdminUserDTO userDTO) {
if (userDTO.getEmail() != null) {
user.setEmail(userDTO.getEmail().toLowerCase());
}
// user.setImageUrl(userDTO.getImageUrl());

if (userDTO.getLangKey() == null) {
user.setLangKey(Constants.DEFAULT_LANGUAGE); // default language
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ public User userDTOToUser(AdminUserDTO userDTO) {
User user = new User();
user.setId(userDTO.getId());
user.setLogin(userDTO.getLogin());
// user.setFirstName(userDTO.getFirstName());
// user.setLastName(userDTO.getLastName());
user.setEmail(userDTO.getEmail());
// user.setImageUrl(userDTO.getImageUrl());
user.setCreatedBy(userDTO.getCreatedBy());
user.setCreatedDate(userDTO.getCreatedDate());
user.setLastModifiedBy(userDTO.getLastModifiedBy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,7 @@ public void saveAccount(@Valid @RequestBody AdminUserDTO userDTO) {
if (!user.isPresent()) {
throw new AccountResourceException("User could not be found");
}
userService.updateUser(
// userDTO.getFirstName(),
// userDTO.getLastName(),
userDTO.getEmail(),
userDTO.getLangKey()
// userDTO.getImageUrl()
);
userService.updateUser(userDTO.getEmail(), userDTO.getLangKey());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/config/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spring:
enabled: false
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://terraform-20241008143513166800000005.cxq0oswgswef.ap-southeast-1.rds.amazonaws.com:3306/scaleup?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&createDatabaseIfNotExist=true
url: jdbc:mysql://terraform-20241004101126193600000005.cxq0oswgswef.ap-southeast-1.rds.amazonaws.com:3306/scaleup?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&createDatabaseIfNotExist=true
username: admin
password: teamsixnusscaleup # send to secrets
hikari:
Expand Down Expand Up @@ -121,7 +121,7 @@ jhipster:
token-validity-in-seconds: 86400
token-validity-in-seconds-for-remember-me: 2592000
mail: # specific JHipster mail property, for standard properties see MailProperties
base-url: http://ec2-54-255-11-22.ap-southeast-1.compute.amazonaws.com # Modify according to your server's URL
base-url: http://ec2-52-77-34-58.ap-southeast-1.compute.amazonaws.com # Modify according to your server's URL
logging:
use-json-format: false # By default, logs are not in Json format
logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ void testRegisterValid() throws Exception {
ManagedUserVM validUser = new ManagedUserVM();
validUser.setLogin("test-register-valid");
validUser.setPassword("password");
// validUser.setFirstName("Alice");
// validUser.setLastName("Test");
validUser.setEmail("[email protected]");
// validUser.setImageUrl("http://placehold.it/50x50");
validUser.setLangKey(Constants.DEFAULT_LANGUAGE);
validUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
assertThat(userRepository.findOneByLogin("test-register-valid")).isEmpty();
Expand All @@ -156,11 +153,8 @@ void testRegisterInvalidLogin() throws Exception {
ManagedUserVM invalidUser = new ManagedUserVM();
invalidUser.setLogin("funky-log(n"); // <-- invalid
invalidUser.setPassword("password");
// invalidUser.setFirstName("Funky");
// invalidUser.setLastName("One");
invalidUser.setEmail("[email protected]");
invalidUser.setActivated(true);
// invalidUser.setImageUrl("http://placehold.it/50x50");
invalidUser.setLangKey(Constants.DEFAULT_LANGUAGE);
invalidUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));

Expand Down Expand Up @@ -203,11 +197,8 @@ private static ManagedUserVM createInvalidUser(
ManagedUserVM invalidUser = new ManagedUserVM();
invalidUser.setLogin(login);
invalidUser.setPassword(password);
// invalidUser.setFirstName(firstName);
// invalidUser.setLastName(lastName);
invalidUser.setEmail(email);
invalidUser.setActivated(activated);
// invalidUser.setImageUrl("http://placehold.it/50x50");
invalidUser.setLangKey(Constants.DEFAULT_LANGUAGE);
invalidUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
return invalidUser;
Expand All @@ -220,21 +211,15 @@ void testRegisterDuplicateLogin() throws Exception {
ManagedUserVM firstUser = new ManagedUserVM();
firstUser.setLogin("alice");
firstUser.setPassword("password");
// firstUser.setFirstName("Alice");
// firstUser.setLastName("Something");
firstUser.setEmail("[email protected]");
// firstUser.setImageUrl("http://placehold.it/50x50");
firstUser.setLangKey(Constants.DEFAULT_LANGUAGE);
firstUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));

// Duplicate login, different email
ManagedUserVM secondUser = new ManagedUserVM();
secondUser.setLogin(firstUser.getLogin());
secondUser.setPassword(firstUser.getPassword());
// secondUser.setFirstName(firstUser.getFirstName());
// secondUser.setLastName(firstUser.getLastName());
secondUser.setEmail("[email protected]");
// secondUser.setImageUrl(firstUser.getImageUrl());
secondUser.setLangKey(firstUser.getLangKey());
secondUser.setCreatedBy(firstUser.getCreatedBy());
secondUser.setCreatedDate(firstUser.getCreatedDate());
Expand Down Expand Up @@ -272,10 +257,7 @@ void testRegisterDuplicateEmail() throws Exception {
ManagedUserVM firstUser = new ManagedUserVM();
firstUser.setLogin("test-register-duplicate-email");
firstUser.setPassword("password");
// firstUser.setFirstName("Alice");
// firstUser.setLastName("Test");
firstUser.setEmail("[email protected]");
// firstUser.setImageUrl("http://placehold.it/50x50");
firstUser.setLangKey(Constants.DEFAULT_LANGUAGE);
firstUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));

Expand All @@ -291,10 +273,7 @@ void testRegisterDuplicateEmail() throws Exception {
ManagedUserVM secondUser = new ManagedUserVM();
secondUser.setLogin("test-register-duplicate-email-2");
secondUser.setPassword(firstUser.getPassword());
// secondUser.setFirstName(firstUser.getFirstName());
// secondUser.setLastName(firstUser.getLastName());
secondUser.setEmail(firstUser.getEmail());
// secondUser.setImageUrl(firstUser.getImageUrl());
secondUser.setLangKey(firstUser.getLangKey());
secondUser.setAuthorities(new HashSet<>(firstUser.getAuthorities()));

Expand All @@ -314,10 +293,7 @@ void testRegisterDuplicateEmail() throws Exception {
userWithUpperCaseEmail.setId(firstUser.getId());
userWithUpperCaseEmail.setLogin("test-register-duplicate-email-3");
userWithUpperCaseEmail.setPassword(firstUser.getPassword());
// userWithUpperCaseEmail.setFirstName(firstUser.getFirstName());
// userWithUpperCaseEmail.setLastName(firstUser.getLastName());
userWithUpperCaseEmail.setEmail("[email protected]");
// userWithUpperCaseEmail.setImageUrl(firstUser.getImageUrl());
userWithUpperCaseEmail.setLangKey(firstUser.getLangKey());
userWithUpperCaseEmail.setAuthorities(new HashSet<>(firstUser.getAuthorities()));

Expand Down Expand Up @@ -347,11 +323,8 @@ void testRegisterAdminIsIgnored() throws Exception {
ManagedUserVM validUser = new ManagedUserVM();
validUser.setLogin("badguy");
validUser.setPassword("password");
// validUser.setFirstName("Bad");
// validUser.setLastName("Guy");
validUser.setEmail("[email protected]");
validUser.setActivated(true);
// validUser.setImageUrl("http://placehold.it/50x50");
validUser.setLangKey(Constants.DEFAULT_LANGUAGE);
validUser.setAuthorities(Collections.singleton(AuthoritiesConstants.ADMIN));

Expand Down Expand Up @@ -408,11 +381,8 @@ void testSaveAccount() throws Exception {

AdminUserDTO userDTO = new AdminUserDTO();
userDTO.setLogin("not-used");
// userDTO.setFirstName("firstname");
// userDTO.setLastName("lastname");
userDTO.setEmail("[email protected]");
userDTO.setActivated(false);
// userDTO.setImageUrl("http://placehold.it/50x50");
userDTO.setLangKey(Constants.DEFAULT_LANGUAGE);
userDTO.setAuthorities(Collections.singleton(AuthoritiesConstants.ADMIN));

Expand All @@ -421,12 +391,11 @@ void testSaveAccount() throws Exception {
.andExpect(status().isOk());

User updatedUser = userRepository.findOneWithAuthoritiesByLogin(user.getLogin()).orElse(null);
// assertThat(updatedUser.getFirstName()).isEqualTo(userDTO.getFirstName());
// assertThat(updatedUser.getLastName()).isEqualTo(userDTO.getLastName());

assertThat(updatedUser.getEmail()).isEqualTo(userDTO.getEmail());
assertThat(updatedUser.getLangKey()).isEqualTo(userDTO.getLangKey());
assertThat(updatedUser.getPassword()).isEqualTo(user.getPassword());
// assertThat(updatedUser.getImageUrl()).isEqualTo(userDTO.getImageUrl());

assertThat(updatedUser.isActivated()).isTrue();
assertThat(updatedUser.getAuthorities()).isEmpty();

Expand All @@ -447,11 +416,10 @@ void testSaveInvalidEmail() throws Exception {

AdminUserDTO userDTO = new AdminUserDTO();
userDTO.setLogin("not-used");
// userDTO.setFirstName("firstname");
// userDTO.setLastName("lastname");

userDTO.setEmail("invalid email");
userDTO.setActivated(false);
// userDTO.setImageUrl("http://placehold.it/50x50");

userDTO.setLangKey(Constants.DEFAULT_LANGUAGE);
userDTO.setAuthorities(Collections.singleton(AuthoritiesConstants.ADMIN));

Expand Down Expand Up @@ -485,11 +453,10 @@ void testSaveExistingEmail() throws Exception {

AdminUserDTO userDTO = new AdminUserDTO();
userDTO.setLogin("not-used");
// userDTO.setFirstName("firstname");
// userDTO.setLastName("lastname");

userDTO.setEmail("[email protected]");
userDTO.setActivated(false);
// userDTO.setImageUrl("http://placehold.it/50x50");

userDTO.setLangKey(Constants.DEFAULT_LANGUAGE);
userDTO.setAuthorities(Collections.singleton(AuthoritiesConstants.ADMIN));

Expand Down Expand Up @@ -517,11 +484,10 @@ void testSaveExistingEmailAndLogin() throws Exception {

AdminUserDTO userDTO = new AdminUserDTO();
userDTO.setLogin("not-used");
// userDTO.setFirstName("firstname");
// userDTO.setLastName("lastname");

userDTO.setEmail("[email protected]");
userDTO.setActivated(false);
// userDTO.setImageUrl("http://placehold.it/50x50");

userDTO.setLangKey(Constants.DEFAULT_LANGUAGE);
userDTO.setAuthorities(Collections.singleton(AuthoritiesConstants.ADMIN));

Expand Down
18 changes: 3 additions & 15 deletions src/test/java/com/teamsixnus/scaleup/web/rest/UserResourceIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,9 @@ class UserResourceIT {

private static final Long DEFAULT_ID = 1L;

private static final String DEFAULT_PASSWORD = "passjohndoe";
private static final String UPDATED_PASSWORD = "passjhipster";

private static final String DEFAULT_EMAIL = "johndoe@localhost";
private static final String UPDATED_EMAIL = "jhipster@localhost";

private static final String DEFAULT_FIRSTNAME = "john";
private static final String UPDATED_FIRSTNAME = "jhipsterFirstName";

private static final String DEFAULT_LASTNAME = "doe";
private static final String UPDATED_LASTNAME = "jhipsterLastName";

private static final String DEFAULT_IMAGEURL = "http://placehold.it/50x50";
private static final String UPDATED_IMAGEURL = "http://placehold.it/40x40";

private static final String DEFAULT_LANGKEY = "en";
private static final String UPDATED_LANGKEY = "fr";

Expand Down Expand Up @@ -146,7 +134,7 @@ void createUser() throws Exception {
userDTO.setLogin(DEFAULT_LOGIN);
userDTO.setEmail(DEFAULT_EMAIL);
userDTO.setActivated(true);
// userDTO.setImageUrl(DEFAULT_IMAGEURL);

userDTO.setLangKey(DEFAULT_LANGKEY);
userDTO.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));

Expand All @@ -164,7 +152,7 @@ void createUser() throws Exception {
// Validate the returned User
assertThat(convertedUser.getLogin()).isEqualTo(DEFAULT_LOGIN);
assertThat(convertedUser.getEmail()).isEqualTo(DEFAULT_EMAIL);
// assertThat(convertedUser.getImageUrl()).isEqualTo(DEFAULT_IMAGEURL);

assertThat(convertedUser.getLangKey()).isEqualTo(DEFAULT_LANGKEY);
}

Expand Down Expand Up @@ -202,7 +190,7 @@ void createUserWithExistingLogin() throws Exception {
userDTO.setLogin(DEFAULT_LOGIN); // this login should already be used
userDTO.setEmail("anothermail@localhost");
userDTO.setActivated(true);
// userDTO.setImageUrl(DEFAULT_IMAGEURL);

userDTO.setLangKey(DEFAULT_LANGKEY);
userDTO.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));

Expand Down

0 comments on commit 68a217e

Please sign in to comment.