use of org.sonatype.nexus.repository.upload.ComponentUpload in project nexus-repository-r by sonatype-nexus-community.
the class RUploadHandlerTest method testHandleValidationExceptionWrongPath.
@Test
public void testHandleValidationExceptionWrongPath() throws IOException {
ComponentUpload component = createComponentUpload(WRONG_PACKAGE_PATH, PACKAGE_NAME);
checkValidationFailed(component, NOT_VALID_PATH_ERROR_MESSAGE);
}
use of org.sonatype.nexus.repository.upload.ComponentUpload in project nexus-repository-r by sonatype-nexus-community.
the class RUploadHandlerTest method testHandle.
@Test
public void testHandle() throws IOException {
ComponentUpload component = createComponentUpload(PACKAGE_PATH, PACKAGE_NAME);
UploadResponse uploadResponse = underTest.handle(repository, component);
assertThat(uploadResponse.getAssetPaths(), contains(PACKAGE_PATH_FULL));
assertThat(uploadResponse.getComponentId().getValue(), is(NU_ID));
verify(contentPermissionChecker).isPermitted(eq(REPO_NAME), eq(RFormat.NAME), eq(BreadActions.EDIT), captor.capture());
VariableSource source = captor.getValue();
assertThat(source.get("format"), is(Optional.of(RFormat.NAME)));
assertThat(source.get("path"), is(Optional.of(PACKAGE_PATH_FULL)));
}
use of org.sonatype.nexus.repository.upload.ComponentUpload in project nexus-repository-r by sonatype-nexus-community.
the class RUploadHandlerTest method testHandle_unauthorized.
@Test
public void testHandle_unauthorized() throws IOException {
when(contentPermissionChecker.isPermitted(eq(REPO_NAME), eq(RFormat.NAME), eq(BreadActions.EDIT), any())).thenReturn(false);
ComponentUpload component = createComponentUpload(PACKAGE_PATH, PACKAGE_NAME);
checkValidationFailed(component, String.format("Not authorized for requested path '%s'", PACKAGE_PATH_FULL));
}
use of org.sonatype.nexus.repository.upload.ComponentUpload in project nexus-repository-r by sonatype-nexus-community.
the class RUploadHandlerTest method createComponentUpload.
private ComponentUpload createComponentUpload(final String packagePath, final String packageName) {
when(payload.getName()).thenReturn(packageName);
ComponentUpload component = new ComponentUpload();
AssetUpload asset = new AssetUpload();
asset.setFields(Collections.singletonMap(RUploadHandler.PATH_ID, packagePath));
asset.setPayload(payload);
component.getAssetUploads().add(asset);
return component;
}
use of org.sonatype.nexus.repository.upload.ComponentUpload in project nexus-repository-r by sonatype-nexus-community.
the class RUploadHandlerTest method testHandleValidationExceptionWrongExtension.
@Test
public void testHandleValidationExceptionWrongExtension() throws IOException {
ComponentUpload component = createComponentUpload(PACKAGE_PATH, WRONG_PACKAGE_NAME);
checkValidationFailed(component, NOT_VALID_EXTENSION_ERROR_MESSAGE);
}
Aggregations