mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(cloudwatch): return ResourceNotFound for SetAlarmState on missing alarm (#1621)
* fix: return ResourceNotFound 400 for SetAlarmState on missing alarm * fix: use CloudWatch ResourceNotFound error code for missing alarm * fix: use HTTP 404 for CloudWatch ResourceNotFound Per @hectorvent's review: the CloudWatch service model (botocore cloudwatch/2010-08-01 service-2.json) declares the ResourceNotFound shape with httpStatusCode 404, so correct the AwsException status from 400 to 404 for the missing-alarm SetAlarmState path and update the test assertion to match. --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
This commit is contained in:
1 parent
7d70f64162
commit
2c746b25a1
2 files changed
+13
-2
No files matched your search
+11
-1
@@ -1,5 +1,6 @@
|
||||
package io.github.hectorvent.floci.services.cloudwatch.metrics;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import io.github.hectorvent.floci.services.cloudwatch.metrics.model.Dimension;
|
||||
@@ -229,6 +230,15 @@ class CloudWatchMetricsServiceTest {
|
||||
assertEquals("Threshold breached", updated.getStateReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
void setAlarmStateOnNonexistentAlarmThrowsResourceNotFound() {
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> service.setAlarmState("missing-alarm", "ALARM", "reason", null, REGION));
|
||||
|
||||
assertEquals(404, ex.getHttpStatus());
|
||||
assertEquals("ResourceNotFound", ex.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildDimKeyIsDeterministic() {
|
||||
List<Dimension> dims1 = List.of(new Dimension("B", "2"), new Dimension("A", "1"));
|
||||
@@ -243,4 +253,4 @@ class CloudWatchMetricsServiceTest {
|
||||
assertEquals("", CloudWatchMetricsService.buildDimKey(List.of()));
|
||||
assertEquals("", CloudWatchMetricsService.buildDimKey(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user