diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java index 64a8e648d..89428220e 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java @@ -510,7 +510,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" + cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant()).content(feedback) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isForbidden()); + .andExpect(status().isTooManyRequests()); } /** diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java index 8ee790e67..0b66f205f 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java @@ -158,7 +158,7 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest { mvc.perform(put(TARGET1_CONFIG_DATA_PATH, tenantAware.getCurrentTenant()) .content(JsonBuilder.configData(Map.of("on too many", "sdsds")).toString()) .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isForbidden()) + .andExpect(status().isTooManyRequests()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); } diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java index 7ca11907b..bf0dc06cd 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java @@ -472,7 +472,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { postDeploymentFeedback(DEFAULT_CONTROLLER_ID, action.getId(), feedback, status().isOk()); } - postDeploymentFeedback(DEFAULT_CONTROLLER_ID, action.getId(), feedback, status().isForbidden()); + postDeploymentFeedback(DEFAULT_CONTROLLER_ID, action.getId(), feedback, status().isTooManyRequests()); } /** @@ -493,7 +493,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { } final String feedback = getJsonActionFeedback(DdiStatus.ExecutionStatus.PROCEEDING, DdiResult.FinalResult.NONE, null, messages); - postDeploymentFeedback(DEFAULT_CONTROLLER_ID, action.getId(), feedback, status().isForbidden()); + postDeploymentFeedback(DEFAULT_CONTROLLER_ID, action.getId(), feedback, status().isTooManyRequests()); } /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java index 4172f51b8..9d9c95c4a 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java @@ -263,7 +263,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .contentType(APPLICATION_JSON) .content(toJson(Stream.of(moduleIDs.get(moduleIDs.size() - 1)).map(MgmtId::new).toList()))) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isForbidden()) + .andExpect(status().isTooManyRequests()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -272,7 +272,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet2.getId() + "/assignedSM") .contentType(APPLICATION_JSON).content(toJson(moduleIDs.stream().map(MgmtId::new).toList()))) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isForbidden()) + .andExpect(status().isTooManyRequests()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -415,7 +415,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + ds.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(payload.toString())) - .andExpect(status().isForbidden()); + .andExpect(status().isTooManyRequests()); assertThat(targetManagement.findByAssignedDistributionSet(ds.getId(), PAGE).getContent()).isEmpty(); } @@ -444,7 +444,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe final String json = new JSONArray().put(new JSONObject().put("id", testTarget.getControllerId())).toString(); mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + ds3.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(json)) - .andExpect(status().isForbidden()); + .andExpect(status().isTooManyRequests()); } /** @@ -1190,7 +1190,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .contentType(APPLICATION_JSON) .content(metaData2.toString())) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isForbidden()); + .andExpect(status().isTooManyRequests()); // verify that the number of meta-data entries has not changed (we cannot use the PAGE constant here as it tries to sort by ID) assertThat(distributionSetManagement.getMetadata(testDS.getId())).hasSize(metaData1.length()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java index fe04dd298..6996ef6d4 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java @@ -246,7 +246,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati .content("{\"id\":" + moduleTypeIds.get(moduleTypeIds.size() - 1) + "}") .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isForbidden()) + .andExpect(status().isTooManyRequests()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -268,7 +268,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati .content("{\"id\":" + moduleTypeIds.get(moduleTypeIds.size() - 1) + "}") .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isForbidden()) + .andExpect(status().isTooManyRequests()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); } diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java index 579c57b41..48ef96a65 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java @@ -433,7 +433,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { new RolloutGroupConditionBuilder().withDefaults().build())) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isForbidden()) + .andExpect(status().isTooManyRequests()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -454,7 +454,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { new RolloutGroupConditionBuilder().withDefaults().build())) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isForbidden()) + .andExpect(status().isTooManyRequests()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java index a30c0e677..cf3f473e2 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java @@ -427,7 +427,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isForbidden()) + .andExpect(status().isTooManyRequests()) .andExpect(jsonPath("$.exceptionClass", equalTo(FileSizeQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_FILE_SIZE_QUOTA_EXCEEDED.getKey()))); } @@ -620,7 +620,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isForbidden()) + .andExpect(status().isTooManyRequests()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -670,7 +670,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isForbidden()) + .andExpect(status().isTooManyRequests()) .andExpect(jsonPath("$.exceptionClass", equalTo(StorageQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_STORAGE_QUOTA_EXCEEDED.getKey()))); @@ -1437,7 +1437,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes mvc.perform(post("/rest/v1/softwaremodules/{swId}/metadata", sm.getId()).accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON).content(metaData2.toString())) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isForbidden()); + .andExpect(status().isTooManyRequests()); // verify that the number of meta data entries has not changed (we cannot use the PAGE constant here as it tries to sort by ID) assertThat(softwareModuleManagement.getMetadata(sm.getId()).size()).isEqualTo(metaData1.length()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java index aac2368e4..bf1eb2522 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java @@ -464,7 +464,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .andDo(print()) - .andExpect(status().isForbidden()) + .andExpect(status().isTooManyRequests()) .andExpect( jsonPath(JSON_PATH_EXCEPTION_CLASS, equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath(JSON_PATH_ERROR_CODE, equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -502,7 +502,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId()) .content("{\"query\":\"controllerId==target*\"}").contentType(MediaType.APPLICATION_JSON)) .andDo(print()) - .andExpect(status().isForbidden()) + .andExpect(status().isTooManyRequests()) .andExpect( jsonPath(JSON_PATH_EXCEPTION_CLASS, equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath(JSON_PATH_ERROR_CODE, equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java index 48869ed73..791fa180d 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java @@ -2039,7 +2039,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .accept(APPLICATION_JSON) .contentType(APPLICATION_JSON).content(metaData2.toString())) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isForbidden()); + .andExpect(status().isTooManyRequests()); // verify that the number of meta-data entries has not changed (we cannot use the PAGE constant here as it tries to sort by ID) assertThat(targetManagement.getMetadata(knownControllerId)).hasSize(metaData1.length()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java index 3c0dc870d..3078a8866 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java @@ -652,7 +652,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { .content("[{\"id\":" + dsTypeIds.get(dsTypeIds.size() - 1) + "}]") .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isForbidden()) + .andExpect(status().isTooManyRequests()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); } diff --git a/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/RestConfiguration.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/RestConfiguration.java index ca2f90bd1..f5bf1da28 100644 --- a/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/RestConfiguration.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/RestConfiguration.java @@ -117,9 +117,9 @@ public class RestConfiguration { ERROR_TO_HTTP_STATUS.put(SpServerError.SP_ARTIFACT_DELETE_FAILED, HttpStatus.INTERNAL_SERVER_ERROR); ERROR_TO_HTTP_STATUS.put(SpServerError.SP_ARTIFACT_BINARY_DELETED, HttpStatus.GONE); ERROR_TO_HTTP_STATUS.put(SpServerError.SP_ARTIFACT_LOAD_FAILED, HttpStatus.INTERNAL_SERVER_ERROR); - ERROR_TO_HTTP_STATUS.put(SpServerError.SP_QUOTA_EXCEEDED, HttpStatus.FORBIDDEN); - ERROR_TO_HTTP_STATUS.put(SpServerError.SP_FILE_SIZE_QUOTA_EXCEEDED, HttpStatus.FORBIDDEN); - ERROR_TO_HTTP_STATUS.put(SpServerError.SP_STORAGE_QUOTA_EXCEEDED, HttpStatus.FORBIDDEN); + ERROR_TO_HTTP_STATUS.put(SpServerError.SP_QUOTA_EXCEEDED, HttpStatus.TOO_MANY_REQUESTS); + ERROR_TO_HTTP_STATUS.put(SpServerError.SP_FILE_SIZE_QUOTA_EXCEEDED, HttpStatus.TOO_MANY_REQUESTS); + ERROR_TO_HTTP_STATUS.put(SpServerError.SP_STORAGE_QUOTA_EXCEEDED, HttpStatus.TOO_MANY_REQUESTS); ERROR_TO_HTTP_STATUS.put(SpServerError.SP_ACTION_NOT_CANCELABLE, HttpStatus.METHOD_NOT_ALLOWED); ERROR_TO_HTTP_STATUS.put(SpServerError.SP_ACTION_NOT_FORCE_QUITABLE, HttpStatus.METHOD_NOT_ALLOWED); ERROR_TO_HTTP_STATUS.put(SpServerError.SP_DS_CREATION_FAILED_MISSING_MODULE, HttpStatus.BAD_REQUEST);