Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/badges/jacoco.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Grant execute permissions for gradlew
run: chmod +x gradlew
Expand All @@ -33,7 +33,7 @@ jobs:
build-root-directory: .
- name: Add coverage to PR
id: jacoco
uses: madrapps/[email protected].1
uses: madrapps/[email protected].2
with:
paths: ${{github.workspace}}/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{secrets.GITHUB_TOKEN}}
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v6
with:
push: true
context: "{{defaultContext}}:."
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A highly opinionated and complete starter for Spring Boot production ready proje

## Built With

* [Spring Boot 3.4.0](https://projects.spring.io/spring-boot/) - Inversion of Control Framework
* [Spring Boot 3.4.5](https://projects.spring.io/spring-boot/) - Inversion of Control Framework
* [Bootstrap 5](https://getbootstrap.com/docs/5.0/getting-started/introduction/) - HTML, CSS, and
JavaScript framework
* [Thymeleaf](https://www.thymeleaf.org/) - Modern server-side Java template engine
Expand Down
48 changes: 21 additions & 27 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id 'org.springframework.boot' version '3.4.0'
id 'io.spring.dependency-management' version '1.1.6'
id 'org.owasp.dependencycheck' version '11.1.0'
id 'com.diffplug.spotless' version '6.25.0'
id 'org.springframework.boot' version '3.4.5'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.owasp.dependencycheck' version '12.1.1'
id 'com.diffplug.spotless' version '7.0.3'
id 'eclipse'
id 'jacoco'
id 'idea'
Expand Down Expand Up @@ -36,9 +36,10 @@ repositories {

ext {
set('jjwtVersion', '0.12.6')
set('springDocVersion', '2.7.0')
set('springDocVersion', '2.8.8')
set('javadocScribeVersion', '0.15.0')
set('mapstructVersion', '1.6.3')
set('awsSdkS3Version', '2.31.45')
}

dependencies {
Expand All @@ -62,15 +63,15 @@ dependencies {
implementation 'org.ehcache:ehcache-transactions:3.10.8'

// Utilities
implementation 'org.jsoup:jsoup:1.18.3'
implementation 'org.jsoup:jsoup:1.20.1'
implementation "io.jsonwebtoken:jjwt-api:${jjwtVersion}"
runtimeOnly "io.jsonwebtoken:jjwt-impl:${jjwtVersion}"
runtimeOnly "io.jsonwebtoken:jjwt-jackson:${jjwtVersion}"
implementation 'commons-io:commons-io:2.18.0'
implementation 'net.datafaker:datafaker:2.4.2'
implementation 'com.google.code.gson:gson:2.11.0'
implementation 'commons-io:commons-io:2.19.0'
implementation 'net.datafaker:datafaker:2.4.3'
implementation 'com.google.code.gson:gson:2.13.1'
implementation 'commons-validator:commons-validator:1.9.0'
implementation 'com.github.darrachequesne:spring-data-jpa-datatables:6.0.4'
implementation 'com.github.darrachequesne:spring-data-jpa-datatables:7.0.1'

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

// MapStruct for Object Mapping
Expand All @@ -92,11 +93,10 @@ dependencies {

// Webjars
implementation 'org.webjars:jquery:3.7.1'
implementation 'org.webjars:bootstrap:5.3.3'
implementation 'org.webjars:popper.js:2.11.7'
implementation 'org.webjars:jquery-ui:1.14.0'
implementation 'org.webjars:datatables:2.1.8'
implementation 'org.webjars:font-awesome:6.7.1'
implementation 'org.webjars:bootstrap:5.3.5'
implementation 'org.webjars:jquery-ui:1.14.1'
implementation 'org.webjars:datatables:2.3.0'
implementation 'org.webjars:font-awesome:6.7.2'
implementation 'org.webjars:webjars-locator:0.52'
}

Expand All @@ -109,11 +109,10 @@ testing {
dependencies {
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
implementation 'org.mockito:mockito-core:5.14.2'
implementation 'io.findify:s3mock_2.13:0.2.6'
implementation 'com.icegreen:greenmail-junit5:2.1.2'
implementation 'com.icegreen:greenmail-junit5:2.1.3'
implementation 'com.jparams:to-string-verifier:1.4.8'
implementation 'nl.jqno.equalsverifier:equalsverifier:3.17.5'
implementation 'nl.jqno.equalsverifier:equalsverifier:4.0'
implementation 'org.springframework.security:spring-security-test'
implementation 'org.springframework.boot:spring-boot-starter-test'
runtimeOnly 'org.junit.platform:junit-platform-launcher'
Expand All @@ -128,7 +127,7 @@ testing {
implementation sourceSets.test.output

implementation 'org.springframework.boot:spring-boot-testcontainers'
implementation 'software.amazon.awssdk:s3:2.29.34'
implementation "software.amazon.awssdk:s3:${awsSdkS3Version}"
implementation 'org.testcontainers:junit-jupiter'
implementation 'org.testcontainers:postgresql'
}
Expand Down Expand Up @@ -195,21 +194,16 @@ spotless {

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces()
leadingTabsToSpaces()
endWithNewline()
}

java {

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces()
leadingTabsToSpaces()
endWithNewline()
removeUnusedImports()
googleJavaFormat()
}
}

jacoco {
toolVersion = "0.8.12"
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ void createUserAlreadyExistingAndNotEnabled(TestInfo testInfo) {
Assertions.assertEquals(userDto, existingUser);
}

/** Creating a user who exists and not enabled
* and register again with changed username should throw exception. */
@Test
void createUserAlreadyExistingAndNotEnabledChangedUsername() {
assertThrows(UserAlreadyExistsException.class, () -> {
// Create a new user with the test name as username
var userDto = createAndAssertUser(FAKER.internet().username(), false);

userDto.setUsername("testUsername");
// create another user using the same details from the first user "userDto"
createAndAssertUser(userDto);
});
}

/** Creating a user who exists and enabled should return null. */
@Test
void createUserAlreadyExistingAndEnabled(TestInfo testInfo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class SpringBootStarterApplication {
* @param args an array of command-line arguments for the application
*/
public static void main(final String[] args) {
String name;
SpringApplication.run(SpringBootStarterApplication.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,17 @@ public UserDto saveOrUpdate(final User user, final boolean isUpdate) {
if (Objects.nonNull(localUser)) {
// If the user exists but has not been verified, then treat this as a new sign-up.
if (!localUser.isEnabled()) {
LOG.debug(UserConstants.USER_EXIST_BUT_NOT_ENABLED, userDto.getEmail(), localUser);
return UserUtils.convertToUserDto(localUser);
// check if the email in the localUser is the same as the email ini userDto,
// then it's the same account creation being recreated.
if (localUser.getUsername().equals(userDto.getUsername()) && localUser.getEmail().equals(userDto.getEmail())) {
LOG.debug(UserConstants.USER_EXIST_BUT_NOT_ENABLED, userDto.getEmail(), localUser);
return UserUtils.convertToUserDto(localUser);
}

// user signed up
// and could not verify and attempting sign up with either email or username but not both.
LOG.warn("Username or email already exists and either user is using different credentials.");
throw new UserAlreadyExistsException(UserConstants.USERNAME_OR_EMAIL_EXISTS);
}

LOG.warn(UserConstants.USER_ALREADY_EXIST, userDto.getEmail());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.Serial;

/**
* Responsible for user already exists exception specifically.
* Responsible for user already exists an exception specifically.
*
* @author Eric Opoku
* @version 1.0
Expand Down
Loading