test(codeartifact): pin ResourceNotFoundException on DeleteDomain of a missing domain (#4107)

AWS returns ResourceNotFoundException (404) when DeleteDomain targets a
domain that does not exist, even though the API reference leaves it out
of the operation's error list. Keep that behaviour, pin it with unit and
integration tests, and note it in the docs and next to requireDomain.

Closes #4000
This commit is contained in:
Matheus André authored and GitHub committed 2026-09-21 18:00:27 -04:00
1 parent 98ffdc2af4
commit 2e038b5cfb
4 files changed
+26 -2

No files matched your search

@@ -58,7 +58,12 @@ class CodeArtifactIntegrationTest {
given().header("Authorization", AUTH)
.delete("/v1/domain?domain=lifecycle-domain")
.then().statusCode(200);
.then().statusCode(200).body("domain.name", equalTo("lifecycle-domain"));
// AWS returns ResourceNotFoundException here although the API reference does not list it on DeleteDomain.
given().header("Authorization", AUTH)
.delete("/v1/domain?domain=lifecycle-domain")
.then().statusCode(404).body("__type", equalTo("ResourceNotFoundException"));
}
@Test
@@ -163,6 +163,19 @@ class CodeArtifactServiceTest {
assertEquals("with-repo", deleted.domain().getName());
}
@Test
void deleteDomainOfMissingDomainReturnsResourceNotFound() {
// AWS returns this even though the API reference does not list it on DeleteDomain.
AwsException e = assertThrows(AwsException.class, () -> service.deleteDomain(REGION, "never-created", null));
assertEquals("ResourceNotFoundException", e.getErrorCode());
assertEquals(404, e.getHttpStatus());
service.createDomain(REGION, "once", null, Map.of());
service.deleteDomain(REGION, "once", null);
AwsException again = assertThrows(AwsException.class, () -> service.deleteDomain(REGION, "once", null));
assertEquals("ResourceNotFoundException", again.getErrorCode());
}
@Test
void describeDomainReflectsLiveRepositoryCount() {
service.createDomain(REGION, "counted", null, Map.of());