feat: Add S3 hook support for upload, download, and list operations #745
Closed
therev2 wants to merge 2 commits intoauthorjapps:masterfrom
Closed
feat: Add S3 hook support for upload, download, and list operations #745therev2 wants to merge 2 commits intoauthorjapps:masterfrom
therev2 wants to merge 2 commits intoauthorjapps:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class S3 step-hook support to Zerocode scenarios by introducing an s3-bucket: URL prefix that routes steps to a new S3 client implementation backed by AWS SDK v2.
Changes:
- Add AWS SDK v2 S3 dependency (managed in parent POM; optional in
core). - Introduce S3 execution path end-to-end (API type detection → scenario runner routing → executor → S3 client → upload/download/list handlers).
- Add Mockito-backed unit tests covering API type mapping, S3 client dispatching, and handler behavior.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pom.xml | Adds AWS SDK version property and dependencyManagement entry for software.amazon.awssdk:s3. |
| core/pom.xml | Adds optional AWS S3 SDK dependency to the core module. |
| core/src/main/java/org/jsmart/zerocode/core/constants/ZerocodeConstants.java | Adds S3 and S3_BUCKET constants to support URL prefixing. |
| core/src/main/java/org/jsmart/zerocode/core/utils/ApiType.java | Adds new S3_CALL enum value. |
| core/src/main/java/org/jsmart/zerocode/core/utils/ApiTypeUtils.java | Detects s3-bucket: URLs and maps them to S3_CALL. |
| core/src/main/java/org/jsmart/zerocode/core/runner/ZeroCodeMultiStepsScenarioRunnerImpl.java | Routes S3_CALL steps to the executor and extracts bucket name from s3-bucket: URL. |
| core/src/main/java/org/jsmart/zerocode/core/engine/executor/ApiServiceExecutor.java | Adds executeS3Service(...) API. |
| core/src/main/java/org/jsmart/zerocode/core/engine/executor/ApiServiceExecutorImpl.java | Wires S3 execution via injected BasicS3Client. |
| core/src/main/java/org/jsmart/zerocode/core/s3/client/BasicS3Client.java | Implements S3 credential resolution + dispatch to upload/download/list handlers. |
| core/src/main/java/org/jsmart/zerocode/core/s3/upload/S3Uploader.java | Upload handler using PutObject with file resolution. |
| core/src/main/java/org/jsmart/zerocode/core/s3/download/S3Downloader.java | Download handler using GetObject to local path. |
| core/src/main/java/org/jsmart/zerocode/core/s3/list/S3Lister.java | List handler with metadata mapping and manual/auto pagination behavior. |
| core/src/main/java/org/jsmart/zerocode/core/s3/domain/S3Request.java | Defines S3 request payload fields (key/file/localPath/prefix/maxKeys/continuationToken). |
| core/src/main/java/org/jsmart/zerocode/core/s3/domain/S3Response.java | Defines S3 response payload (status/s3Url/objects/truncated/nextContinuationToken). |
| core/src/main/java/org/jsmart/zerocode/core/s3/domain/ObjectInfo.java | Defines list-object metadata model returned in responses. |
| core/src/test/java/org/jsmart/zerocode/core/utils/ApiTypeUtilsTest.java | Adds tests for mapping s3-bucket: to S3_CALL. |
| core/src/test/java/org/jsmart/zerocode/core/s3/client/BasicS3ClientTest.java | Adds dispatch tests for upload/download/list and unsupported operations. |
| core/src/test/java/org/jsmart/zerocode/core/s3/S3IntegrationTest.java | Adds mocked AWS SDK tests validating handler requests/responses and pagination behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import java.io.File; | ||
| import java.io.FileWriter; | ||
| import java.lang.reflect.Field; | ||
| import java.nio.file.Files; |
Comment on lines
+503
to
+508
| String bucketName = url.substring(S3_BUCKET.length()); | ||
| String s3Operation = operationName; | ||
| if (s3Operation.toUpperCase().startsWith("S3.")) { | ||
| s3Operation = s3Operation.substring(3); | ||
| } | ||
| executionResult = apiExecutor.executeS3Service(bucketName, s3Operation, resolvedRequestJsonMaskRemoved); |
Comment on lines
37
to
+41
| } else if (serviceName.contains("://") && !serviceName.startsWith("http")) { | ||
| apiType = ApiType.JAVA_CALL; | ||
|
|
||
| } else if (serviceName != null && serviceName.startsWith(S3_BUCKET)) { | ||
| apiType = ApiType.S3_CALL; |
| <dependency> | ||
| <groupId>software.amazon.awssdk</groupId> | ||
| <artifactId>s3</artifactId> | ||
| <optional>true</optional> |
Comment on lines
+25
to
+27
| @Inject(optional = true) | ||
| private BasicS3Client s3Client; | ||
|
|
Comment on lines
+80
to
+85
| try { | ||
| return Paths.get(resource.toURI()).toString(); | ||
| } catch (java.net.URISyntaxException e) { | ||
| LOGGER.warn("Could not convert resource URL to URI: {}", resource, e); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds S3 support via the s3-bucket: prefix.
Supports S3.UPLOAD, S3.DOWNLOAD, S3.LIST operations.
Uses AWS_ACCESS_KEY_ID > s3.accessKey > AWS Default profile.
AWS SDK is to avoid bloat.
100% Mockito-backed tests added (Java 8 compatible).
Fixes #742