From 16a674f0a8fabe512f5049ad8489b5dc0d70238d Mon Sep 17 00:00:00 2001 From: Kilemonn Date: Thu, 14 May 2026 19:02:03 +0900 Subject: [PATCH 1/4] First remove all entries from the subqueue if requested before removing the restriction. --- .../rest/controller/AuthController.kt | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/au/kilemon/messagequeue/rest/controller/AuthController.kt b/src/main/kotlin/au/kilemon/messagequeue/rest/controller/AuthController.kt index c05a3fc..d7761d4 100644 --- a/src/main/kotlin/au/kilemon/messagequeue/rest/controller/AuthController.kt +++ b/src/main/kotlin/au/kilemon/messagequeue/rest/controller/AuthController.kt @@ -139,24 +139,18 @@ open class AuthController : HasLogger { if (multiQueueAuthenticator.isRestricted(subQueue)) { - return if (multiQueueAuthenticator.removeRestriction(subQueue)) + if (clearQueue == true) { - if (clearQueue == true) - { - LOG.info("Restriction removed and clearing sub-queue [{}].", subQueue) - multiQueue.clearSubQueue(subQueue) - } - else - { - LOG.info("Removed restriction from sub-queue [{}] without clearing stored messages.", subQueue) - } - ResponseEntity.ok().build() + LOG.info("Removing restriction and clearing sub-queue [{}].", subQueue) + multiQueue.clearSubQueue(subQueue) } else { - LOG.error("Failed to remove restriction for sub-queue [{}].", subQueue) - ResponseEntity.internalServerError().build() + LOG.info("Removing restriction from sub-queue [{}] without clearing stored messages.", subQueue) } + + multiQueueAuthenticator.removeRestriction(subQueue) + return ResponseEntity.ok().build() } else { From 1a0c13103e005b155325e0e66c751ae14a8464ec Mon Sep 17 00:00:00 2001 From: Kilemonn Date: Thu, 14 May 2026 19:06:07 +0900 Subject: [PATCH 2/4] Remove invalid test. --- .../rest/controller/AuthControllerTest.kt | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/src/test/kotlin/au/kilemon/messagequeue/rest/controller/AuthControllerTest.kt b/src/test/kotlin/au/kilemon/messagequeue/rest/controller/AuthControllerTest.kt index 89350b5..b608dfb 100644 --- a/src/test/kotlin/au/kilemon/messagequeue/rest/controller/AuthControllerTest.kt +++ b/src/test/kotlin/au/kilemon/messagequeue/rest/controller/AuthControllerTest.kt @@ -285,33 +285,6 @@ class AuthControllerTest .andExpect(MockMvcResultMatchers.status().isNoContent) } - /** - * Ensure [AuthController.removeRestrictionFromSubQueue] returns - * [org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR] when there is an error when attempting to remove - * the restriction on the sub-queue. - */ - @Test - fun testRemoveRestrictionFromSubQueue_failedToRemoveRestriction() - { - Mockito.doReturn(RestrictionMode.HYBRID).`when`(multiQueueAuthenticator).getRestrictionMode() - Assertions.assertEquals(RestrictionMode.HYBRID, multiQueueAuthenticator.getRestrictionMode()) - - val subQueue = "testRemoveRestrictionFromSubQueue_failedToRemoveRestriction" - val token = jwtTokenProvider.createTokenForSubQueue(subQueue) - Assertions.assertTrue(token.isPresent) - - Assertions.assertTrue(multiQueueAuthenticator.addRestrictedEntry(subQueue)) - Assertions.assertTrue(multiQueueAuthenticator.isRestricted(subQueue)) - - Mockito.doReturn(false).`when`(multiQueueAuthenticator).removeRestriction(subQueue) - - mockMvc.perform( - MockMvcRequestBuilders.delete("${AuthController.AUTH_PATH}/${subQueue}") - .header(JwtAuthenticationFilter.AUTHORIZATION_HEADER, "${JwtAuthenticationFilter.BEARER_HEADER_VALUE}${token.get()}") - .contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(MockMvcResultMatchers.status().isInternalServerError) - } - /** * Ensure [AuthController.removeRestrictionFromSubQueue] returns [org.springframework.http.HttpStatus.OK] when * the sub-queue restriction is removed BUT the sub-queue is not cleared when the query parameter From 3c36a223b60f01864de5605ea298f495b9bd7df6 Mon Sep 17 00:00:00 2001 From: Kilemonn Date: Thu, 14 May 2026 19:43:35 +0900 Subject: [PATCH 3/4] Run compilation and unit test pipeline as part of the PR to "main", but do not update coverage. --- .github/workflows/gradle-on-pull-request.yml | 32 +++++++++++++++++++ ...{gradle.yml => gradle-on-push-to-main.yml} | 4 ++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/gradle-on-pull-request.yml rename .github/workflows/{gradle.yml => gradle-on-push-to-main.yml} (94%) diff --git a/.github/workflows/gradle-on-pull-request.yml b/.github/workflows/gradle-on-pull-request.yml new file mode 100644 index 0000000..1ed85db --- /dev/null +++ b/.github/workflows/gradle-on-pull-request.yml @@ -0,0 +1,32 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Build and test + +on: + pull_request: + branches: [ "main" ] + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Build with Gradle + uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 + with: + arguments: build diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle-on-push-to-main.yml similarity index 94% rename from .github/workflows/gradle.yml rename to .github/workflows/gradle-on-push-to-main.yml index caffc18..c26deaa 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle-on-push-to-main.yml @@ -5,11 +5,13 @@ # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle -name: CI Build +name: Build, test and update coverage badge on: push: branches: [ "main" ] + pull_request: + branches: [ "main" ] permissions: contents: write From 59e8dc6c34ffa4824c9ca0a4f2775faba1377e45 Mon Sep 17 00:00:00 2001 From: Kilemonn Date: Thu, 14 May 2026 19:44:51 +0900 Subject: [PATCH 4/4] Only run on push to main. --- .github/workflows/gradle-on-push-to-main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/gradle-on-push-to-main.yml b/.github/workflows/gradle-on-push-to-main.yml index c26deaa..57493f4 100644 --- a/.github/workflows/gradle-on-push-to-main.yml +++ b/.github/workflows/gradle-on-push-to-main.yml @@ -10,8 +10,6 @@ name: Build, test and update coverage badge on: push: branches: [ "main" ] - pull_request: - branches: [ "main" ] permissions: contents: write