mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
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.
This commit is contained in:
1 parent
88d429a968
commit
c02c0c7a60
1 file changed
+31
+31
@@ -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
|
||||
|
||||
Reference in new issue
Block a user