Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@ log/

# localstack
localstack/.localstack/

# VS Code
.vscode/

# Results
results/
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
robotframework>=6.1.1
boto3>=1.34.125
boto3>=1.40.30
robotframework-pythonlibcore>=4.4.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ def readme():
],
packages=find_packages('src'),
package_dir={'': 'src'},
install_requires=['boto3 >= 1.34.125', 'robotframework >= 6.1.1', 'robotframework-pythonlibcore>=4.4.1']
install_requires=['boto3 >= 1.40.30', 'robotframework >= 6.1.1', 'robotframework-pythonlibcore>=4.4.1']
)
26 changes: 26 additions & 0 deletions src/AWSLibrary/keywords/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,32 @@ def s3_upload_file(self, bucket, key, local_path):
except botocore.exceptions.ClientError as e:
raise Exception(e)

@keyword('S3 Put Object With Checksum')
def s3_put_object_with_checksum(self, bucket, key, body, checksum_algorithm='SHA256'):
""" Put an object to the bucket with checksum validation for integrity.

| =Arguments= | =Description= |
| ``bucket`` | <str> The bucket name. |
| ``key`` | <str> Complete s3 filepath. |
| ``body`` | <str> The object data. |
| ``checksum_algorithm`` | <str> The checksum algorithm (SHA256, SHA1, CRC32, CRC32C). Default: SHA256. |

*Examples:*
| S3 Put Object With Checksum | bucket_name | s3_file.txt | ${data} |
| S3 Put Object With Checksum | bucket_name | s3_file.txt | ${data} | CRC32 |
"""
client = self.library.session.client('s3', endpoint_url=self.endpoint_url)
try:
response = client.put_object(
Bucket=bucket,
Key=key,
Body=body,
ChecksumAlgorithm=checksum_algorithm
)
logger.info(response)
except botocore.exceptions.ClientError as e:
raise Exception(e)

@keyword('S3 Key Should Exist')
def s3_key_should_exist(self, bucket, key):
""" Check if the s3 object exist inside the bucket
Expand Down
7 changes: 7 additions & 0 deletions tests/robot/s3.robot
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,10 @@ Test Metadata
Dictionary Should Contain Key ${metadata}[ResponseMetadata] RequestId
Dictionary Should Contain Key ${metadata}[ResponseMetadata][HTTPHeaders] last-modified
[Teardown] S3 Delete File ${BUCKET_NAME} s3_file_metadata.txt

Test Put Object With Checksum
[Tags] s3
${data}= Get File ${CURDIR}/data/local_file.txt
S3 Put Object With Checksum ${BUCKET_NAME} s3_file_checksum.txt ${data} SHA256
S3 Key Should Exist ${BUCKET_NAME} s3_file_checksum.txt
[Teardown] S3 Delete File ${BUCKET_NAME} s3_file_checksum.txt
Loading