From c02c0c7a6028443765ab6f3fc165ef68c515fa43 Mon Sep 17 00:00:00 2001 From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com> Date: Thu, 8 Oct 2026 23:15:22 -0400 Subject: [PATCH] test(codeartifact): cover DescribePackage's required-field and unknown-format rejections (#5309) The service's existing validation (domain/repository/package required, format must be recognized) had no regression test for DescribePackage specifically. Confirms each rejection is a ValidationException, that it happens before reaching a repository or sidecar lookup, and that none of the three sidecar clients see an interaction from a rejected call. --- .../codeartifact/CodeArtifactServiceTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/test/java/io/github/hectorvent/floci/services/codeartifact/CodeArtifactServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/codeartifact/CodeArtifactServiceTest.java index 892ff5f4be..db4ed3ad6d 100644 --- a/src/test/java/io/github/hectorvent/floci/services/codeartifact/CodeArtifactServiceTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/codeartifact/CodeArtifactServiceTest.java @@ -35,11 +35,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -1055,6 +1057,35 @@ class CodeArtifactServiceTest { assertEquals("ValidationException", missingNamespaceForMaven.getErrorCode()); } + /** + * {@code domain}/{@code repository}/{@code package} being required, and an unrecognized format + * being rejected, are not new behavior (every other action in this file already enforces them), + * but {@code describePackage} had no regression test proving any of them, and none of these + * rejections may start a sidecar or otherwise touch state before failing. + */ + @Test + void describePackageRejectsMissingRequiredFieldsAndUnknownFormatsWithoutTouchingAnyState() { + AwsException missingDomain = assertThrows(AwsException.class, () -> service.describePackage(REGION, null, + null, "repo", "generic", "ns", "my-pkg")); + assertEquals("ValidationException", missingDomain.getErrorCode()); + + AwsException missingRepository = assertThrows(AwsException.class, () -> service.describePackage(REGION, + "dom", null, null, "generic", "ns", "my-pkg")); + assertEquals("ValidationException", missingRepository.getErrorCode()); + + AwsException missingPackageName = assertThrows(AwsException.class, () -> service.describePackage(REGION, + "dom", null, "repo", "generic", "ns", null)); + assertEquals("ValidationException", missingPackageName.getErrorCode()); + + AwsException unknownFormat = assertThrows(AwsException.class, () -> service.describePackage(REGION, "dom", + null, "repo", "not-a-real-format", "ns", "my-pkg")); + assertEquals("ValidationException", unknownFormat.getErrorCode()); + + verify(verdaccioClient, never()).packageExists(any(), any(), any(), any(), any()); + verify(reposiliteClient, never()).packageExists(any(), any(), any(), any(), any()); + verify(pypiserverClient, never()).packageExists(any(), any(), any(), any(), any()); + } + /** * pypi packages have no namespace at all (confirmed against the API reference): the sidecar * check genuinely ignores whatever namespace is supplied, so without this rejection the response