Skip to content

Commit f3f8952

Browse files
ericus20Eric OpokustevartzStephen Boakyegithub-actions[bot]
authored
Merge into main (#113)
* upgrade dependencies (#109) Co-authored-by: Eric Opoku <[email protected]> * update exception case for signup (#110) * update exception case for signup * commit badge --------- Co-authored-by: Stephen Boakye <[email protected]> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * upgrade spring boot version (#111) * upgrade spring boot version * update README with spring boot version --------- Co-authored-by: Eric Opoku <[email protected]> * upgrade github actions (#112) Co-authored-by: Eric Opoku <[email protected]> --------- Co-authored-by: Eric Opoku <[email protected]> Co-authored-by: stevartz <[email protected]> Co-authored-by: Stephen Boakye <[email protected]> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 3ab09da commit f3f8952

File tree

9 files changed

+55
-37
lines changed

9 files changed

+55
-37
lines changed

.github/badges/jacoco.svg

Lines changed: 1 addition & 1 deletion
Loading

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
with:
1818
repository: ${{ github.event.pull_request.head.repo.full_name }}
1919
ref: ${{ github.event.pull_request.head.ref }}
20-
- name: Set up JDK 17
20+
- name: Set up JDK 21
2121
uses: actions/setup-java@v4
2222
with:
23-
java-version: '17'
23+
java-version: '21'
2424
distribution: 'temurin'
2525
- name: Grant execute permissions for gradlew
2626
run: chmod +x gradlew
@@ -33,7 +33,7 @@ jobs:
3333
build-root-directory: .
3434
- name: Add coverage to PR
3535
id: jacoco
36-
uses: madrapps/[email protected].1
36+
uses: madrapps/[email protected].2
3737
with:
3838
paths: ${{github.workspace}}/build/reports/jacoco/test/jacocoTestReport.xml
3939
token: ${{secrets.GITHUB_TOKEN}}
@@ -68,7 +68,7 @@ jobs:
6868
username: ${{secrets.DOCKERHUB_USERNAME}}
6969
password: ${{secrets.DOCKERHUB_TOKEN}}
7070
- name: Build and push
71-
uses: docker/build-push-action@v2
71+
uses: docker/build-push-action@v6
7272
with:
7373
push: true
7474
context: "{{defaultContext}}:."

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ A highly opinionated and complete starter for Spring Boot production ready proje
2222

2323
## Built With
2424

25-
* [Spring Boot 3.4.0](https://projects.spring.io/spring-boot/) - Inversion of Control Framework
25+
* [Spring Boot 3.4.5](https://projects.spring.io/spring-boot/) - Inversion of Control Framework
2626
* [Bootstrap 5](https://getbootstrap.com/docs/5.0/getting-started/introduction/) - HTML, CSS, and
2727
JavaScript framework
2828
* [Thymeleaf](https://www.thymeleaf.org/) - Modern server-side Java template engine

build.gradle

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
plugins {
2-
id 'org.springframework.boot' version '3.4.0'
3-
id 'io.spring.dependency-management' version '1.1.6'
4-
id 'org.owasp.dependencycheck' version '11.1.0'
5-
id 'com.diffplug.spotless' version '6.25.0'
2+
id 'org.springframework.boot' version '3.4.5'
3+
id 'io.spring.dependency-management' version '1.1.7'
4+
id 'org.owasp.dependencycheck' version '12.1.1'
5+
id 'com.diffplug.spotless' version '7.0.3'
66
id 'eclipse'
77
id 'jacoco'
88
id 'idea'
@@ -36,9 +36,10 @@ repositories {
3636

3737
ext {
3838
set('jjwtVersion', '0.12.6')
39-
set('springDocVersion', '2.7.0')
39+
set('springDocVersion', '2.8.8')
4040
set('javadocScribeVersion', '0.15.0')
4141
set('mapstructVersion', '1.6.3')
42+
set('awsSdkS3Version', '2.31.45')
4243
}
4344

4445
dependencies {
@@ -62,15 +63,15 @@ dependencies {
6263
implementation 'org.ehcache:ehcache-transactions:3.10.8'
6364

6465
// Utilities
65-
implementation 'org.jsoup:jsoup:1.18.3'
66+
implementation 'org.jsoup:jsoup:1.20.1'
6667
implementation "io.jsonwebtoken:jjwt-api:${jjwtVersion}"
6768
runtimeOnly "io.jsonwebtoken:jjwt-impl:${jjwtVersion}"
6869
runtimeOnly "io.jsonwebtoken:jjwt-jackson:${jjwtVersion}"
69-
implementation 'commons-io:commons-io:2.18.0'
70-
implementation 'net.datafaker:datafaker:2.4.2'
71-
implementation 'com.google.code.gson:gson:2.11.0'
70+
implementation 'commons-io:commons-io:2.19.0'
71+
implementation 'net.datafaker:datafaker:2.4.3'
72+
implementation 'com.google.code.gson:gson:2.13.1'
7273
implementation 'commons-validator:commons-validator:1.9.0'
73-
implementation 'com.github.darrachequesne:spring-data-jpa-datatables:6.0.4'
74+
implementation 'com.github.darrachequesne:spring-data-jpa-datatables:7.0.1'
7475

7576
// Documentation and API Tools
7677
implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:${springDocVersion}"
@@ -83,7 +84,7 @@ dependencies {
8384
runtimeOnly 'org.postgresql:postgresql'
8485
implementation 'org.liquibase:liquibase-core'
8586
implementation 'org.hibernate.orm:hibernate-envers'
86-
implementation 'software.amazon.awssdk:s3:2.29.34'
87+
implementation "software.amazon.awssdk:s3:${awsSdkS3Version}"
8788
implementation files('libs/hypersistence-optimizer-2.6.3-jakarta.jar')
8889

8990
// MapStruct for Object Mapping
@@ -92,11 +93,10 @@ dependencies {
9293

9394
// Webjars
9495
implementation 'org.webjars:jquery:3.7.1'
95-
implementation 'org.webjars:bootstrap:5.3.3'
96-
implementation 'org.webjars:popper.js:2.11.7'
97-
implementation 'org.webjars:jquery-ui:1.14.0'
98-
implementation 'org.webjars:datatables:2.1.8'
99-
implementation 'org.webjars:font-awesome:6.7.1'
96+
implementation 'org.webjars:bootstrap:5.3.5'
97+
implementation 'org.webjars:jquery-ui:1.14.1'
98+
implementation 'org.webjars:datatables:2.3.0'
99+
implementation 'org.webjars:font-awesome:6.7.2'
100100
implementation 'org.webjars:webjars-locator:0.52'
101101
}
102102

@@ -109,11 +109,10 @@ testing {
109109
dependencies {
110110
compileOnly 'org.projectlombok:lombok'
111111
annotationProcessor 'org.projectlombok:lombok'
112-
implementation 'org.mockito:mockito-core:5.14.2'
113112
implementation 'io.findify:s3mock_2.13:0.2.6'
114-
implementation 'com.icegreen:greenmail-junit5:2.1.2'
113+
implementation 'com.icegreen:greenmail-junit5:2.1.3'
115114
implementation 'com.jparams:to-string-verifier:1.4.8'
116-
implementation 'nl.jqno.equalsverifier:equalsverifier:3.17.5'
115+
implementation 'nl.jqno.equalsverifier:equalsverifier:4.0'
117116
implementation 'org.springframework.security:spring-security-test'
118117
implementation 'org.springframework.boot:spring-boot-starter-test'
119118
runtimeOnly 'org.junit.platform:junit-platform-launcher'
@@ -128,7 +127,7 @@ testing {
128127
implementation sourceSets.test.output
129128

130129
implementation 'org.springframework.boot:spring-boot-testcontainers'
131-
implementation 'software.amazon.awssdk:s3:2.29.34'
130+
implementation "software.amazon.awssdk:s3:${awsSdkS3Version}"
132131
implementation 'org.testcontainers:junit-jupiter'
133132
implementation 'org.testcontainers:postgresql'
134133
}
@@ -195,21 +194,16 @@ spotless {
195194

196195
// define the steps to apply to those files
197196
trimTrailingWhitespace()
198-
indentWithSpaces()
197+
leadingTabsToSpaces()
199198
endWithNewline()
200199
}
201200

202201
java {
203202

204203
// define the steps to apply to those files
205204
trimTrailingWhitespace()
206-
indentWithSpaces()
205+
leadingTabsToSpaces()
207206
endWithNewline()
208207
removeUnusedImports()
209-
googleJavaFormat()
210208
}
211209
}
212-
213-
jacoco {
214-
toolVersion = "0.8.12"
215-
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/integrationTest/java/com/developersboard/backend/service/user/UserServiceIntegrationTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ void createUserAlreadyExistingAndNotEnabled(TestInfo testInfo) {
5858
Assertions.assertEquals(userDto, existingUser);
5959
}
6060

61+
/** Creating a user who exists and not enabled
62+
* and register again with changed username should throw exception. */
63+
@Test
64+
void createUserAlreadyExistingAndNotEnabledChangedUsername() {
65+
assertThrows(UserAlreadyExistsException.class, () -> {
66+
// Create a new user with the test name as username
67+
var userDto = createAndAssertUser(FAKER.internet().username(), false);
68+
69+
userDto.setUsername("testUsername");
70+
// create another user using the same details from the first user "userDto"
71+
createAndAssertUser(userDto);
72+
});
73+
}
74+
6175
/** Creating a user who exists and enabled should return null. */
6276
@Test
6377
void createUserAlreadyExistingAndEnabled(TestInfo testInfo) {

src/main/java/com/developersboard/SpringBootStarterApplication.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class SpringBootStarterApplication {
2121
* @param args an array of command-line arguments for the application
2222
*/
2323
public static void main(final String[] args) {
24+
String name;
2425
SpringApplication.run(SpringBootStarterApplication.class, args);
2526
}
2627
}

src/main/java/com/developersboard/backend/service/user/impl/UserServiceImpl.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,17 @@ public UserDto saveOrUpdate(final User user, final boolean isUpdate) {
106106
if (Objects.nonNull(localUser)) {
107107
// If the user exists but has not been verified, then treat this as a new sign-up.
108108
if (!localUser.isEnabled()) {
109-
LOG.debug(UserConstants.USER_EXIST_BUT_NOT_ENABLED, userDto.getEmail(), localUser);
110-
return UserUtils.convertToUserDto(localUser);
109+
// check if the email in the localUser is the same as the email ini userDto,
110+
// then it's the same account creation being recreated.
111+
if (localUser.getUsername().equals(userDto.getUsername()) && localUser.getEmail().equals(userDto.getEmail())) {
112+
LOG.debug(UserConstants.USER_EXIST_BUT_NOT_ENABLED, userDto.getEmail(), localUser);
113+
return UserUtils.convertToUserDto(localUser);
114+
}
115+
116+
// user signed up
117+
// and could not verify and attempting sign up with either email or username but not both.
118+
LOG.warn("Username or email already exists and either user is using different credentials.");
119+
throw new UserAlreadyExistsException(UserConstants.USERNAME_OR_EMAIL_EXISTS);
111120
}
112121

113122
LOG.warn(UserConstants.USER_ALREADY_EXIST, userDto.getEmail());

src/main/java/com/developersboard/exception/user/UserAlreadyExistsException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.io.Serial;
44

55
/**
6-
* Responsible for user already exists exception specifically.
6+
* Responsible for user already exists an exception specifically.
77
*
88
* @author Eric Opoku
99
* @version 1.0

0 commit comments

Comments
 (0)