Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

test(codeartifact): cover DescribePackage's required-field and unknown-format rejections (#5309)

Priamo Germosenc02c0c7a6028
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