Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.adoc
  • Loading branch information
wimdeblauwe committed Sep 12, 2024
2 parents 724634a + a8ec58e commit 72692e5
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 33 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,11 @@ jobs:
- uses: actions/checkout@v2

- name: Setup java ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
distribution: 'temurin'
cache: maven

- name: Build with Maven
run: ./mvnw -B -ntp clean verify
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release

on:
release:
types: [ published ]

jobs:
release:
name: Release on Sonatype OSS
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Apache Maven Central
uses: actions/setup-java@v4
with: # running setup-java again overwrites the settings.xml
distribution: 'temurin'
java-version: 17
cache: 'maven'
server-id: ossrh
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Publish to Apache Maven Central
run: |
mvn -Prelease \
--no-transfer-progress \
--batch-mode \
deploy
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
33 changes: 17 additions & 16 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ NOTE: Documentation is very important to us, so if you find something missing fr
|===
|error-handling-spring-boot-starter |Spring Boot|Minimum Java version|Docs

|https://github.com/wimdeblauwe/error-handling-spring-boot-starter/releases/tag/4.4.0[4.4.0]
|3.3.x
|17
|https://wimdeblauwe.github.io/error-handling-spring-boot-starter/4.4.0/[Documentation 4.4.0]

|https://github.com/wimdeblauwe/error-handling-spring-boot-starter/releases/tag/4.3.0[4.3.0]
|3.x
|17
Expand Down Expand Up @@ -89,19 +94,15 @@ Blogs and articles about this library:

== Release

Release is done via the Maven Release Plugin:

`mvn release:prepare`

and

`mvn release:perform`

Merge the tag to `master` so the documentation is updated.

Finally, push the local commits and the tag to remote.

[NOTE]
====
Before releasing, run `export GPG_TTY=$(tty)`
====
To release a new version of the project, follow these steps:

1. Update `pom.xml` with the new version (Use `mvn versions:set -DgenerateBackupPoms=false -DnewVersion=<VERSION>`)
2. Commit the changes locally.
3. Tag the commit with the version (e.g. `1.0.0`) and push the tag.
4. Create a new release in GitHub via https://github.com/wimdeblauwe/error-handling-spring-boot-starter/releases/new
- Select the newly pushed tag
- Update the release notes.
This should automatically start the [release action](https://github.com/wimdeblauwe/error-handling-spring-boot-starter/actions).
5. Merge the tag to `master` so the documentation is updated.
6. Update `pom.xml` again with the next `SNAPSHOT` version.
7. Close the milestone in the GitHub issue tracker.
12 changes: 9 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.0</version>
<version>3.3.3</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>io.github.wimdeblauwe</groupId>
<artifactId>error-handling-spring-boot-starter</artifactId>
<version>4.3.0</version>
<version>4.4.0</version>
<name>Error Handling Spring Boot Starter</name>
<description>Spring Boot starter that configures error handling</description>

Expand Down Expand Up @@ -50,7 +50,7 @@
</developerConnection>
<connection>scm:git:[email protected]:wimdeblauwe/error-handling-spring-boot-starter.git</connection>
<url>[email protected]:wimdeblauwe/error-handling-spring-boot-starter.git</url>
<tag>4.3.0</tag>
<tag>HEAD</tag>
</scm>
<issueManagement>
<system>github</system>
Expand Down Expand Up @@ -295,6 +295,12 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.*;
import org.springframework.security.authorization.AuthorizationDeniedException;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import java.util.HashMap;
Expand All @@ -22,6 +23,7 @@ public class SpringSecurityApiExceptionHandler extends AbstractApiExceptionHandl
static {
EXCEPTION_TO_STATUS_MAPPING = new HashMap<>();
EXCEPTION_TO_STATUS_MAPPING.put(AccessDeniedException.class, FORBIDDEN);
EXCEPTION_TO_STATUS_MAPPING.put(AuthorizationDeniedException.class, FORBIDDEN);
EXCEPTION_TO_STATUS_MAPPING.put(AccountExpiredException.class, BAD_REQUEST);
EXCEPTION_TO_STATUS_MAPPING.put(AuthenticationCredentialsNotFoundException.class, UNAUTHORIZED);
EXCEPTION_TO_STATUS_MAPPING.put(AuthenticationServiceException.class, INTERNAL_SERVER_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ void testObjectValidationWithMessageOverride(@Autowired ErrorHandlingProperties
@Test
@WithMockUser
void testTopLevelCodeOverride(@Autowired ErrorHandlingProperties properties) throws Exception {
properties.getCodes().put("org.springframework.validation.BindException", "BIND_FAILED");
properties.getCodes().put("org.springframework.web.bind.MethodArgumentNotValidException", "METHOD_ARG_NOT_VALID");
mockMvc.perform(MockMvcRequestBuilders.get("/test/field-validation")
.queryParam("param1", "foo"))
.andExpect(status().isBadRequest())
.andExpect(jsonPath("code").value("BIND_FAILED"))
.andExpect(jsonPath("code").value("METHOD_ARG_NOT_VALID"))
.andExpect(jsonPath("fieldErrors", hasSize(1)))
.andExpect(jsonPath("fieldErrors[0].code").value("REQUIRED_NOT_NULL"))
.andExpect(jsonPath("fieldErrors[0].message").value("must not be null"))
Expand All @@ -146,12 +146,12 @@ void testTopLevelCodeOverride(@Autowired ErrorHandlingProperties properties) thr
@Test
@WithMockUser
void testDisableAddingPath(@Autowired ErrorHandlingProperties properties) throws Exception {
properties.getCodes().put("org.springframework.validation.BindException", "BIND_FAILED");
properties.getCodes().put("org.springframework.web.bind.MethodArgumentNotValidException", "METHOD_ARG_NOT_VALID");
properties.setAddPathToError(false);
mockMvc.perform(MockMvcRequestBuilders.get("/test/field-validation")
.queryParam("param1", "foo"))
.andExpect(status().isBadRequest())
.andExpect(jsonPath("code").value("BIND_FAILED"))
.andExpect(jsonPath("code").value("METHOD_ARG_NOT_VALID"))
.andExpect(jsonPath("fieldErrors", hasSize(1)))
.andExpect(jsonPath("fieldErrors[0].code").value("REQUIRED_NOT_NULL"))
.andExpect(jsonPath("fieldErrors[0].message").value("must not be null"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void testForbiddenViaSecuredAnnotation() throws Exception {
mockMvc.perform(get("/test/spring-security/admin"))
.andExpect(status().isForbidden())
.andExpect(header().string("Content-Type", "application/json"))
.andExpect(jsonPath("code").value("ACCESS_DENIED"))
.andExpect(jsonPath("code").value("AUTHORIZATION_DENIED"))
.andExpect(jsonPath("message").value("Access Denied"));
}

Expand Down

0 comments on commit 72692e5

Please sign in to comment.