Unverified Commit 3a54b913 authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Enable presigning for two more S3 operations (#1242)

parent 11a5691a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -16,3 +16,9 @@ message = "`DynMiddleware` is now `clone`able"
references = ["smithy-rs#1225"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "Velfi"

[[aws-sdk-rust]]
message = "Enable presigning for S3 operations UploadPart and DeleteObject"
references = ["aws-sdk-rust#475", "aws-sdk-rust#473"]
meta = { "breaking" = false, "tada" = true, "bug" = false }
author = "rcoh"
+3 −0
Original line number Diff line number Diff line
@@ -63,8 +63,11 @@ private val SYNTHESIZE_SPEECH_OP = ShapeId.from("com.amazonaws.polly#SynthesizeS
internal val PRESIGNABLE_OPERATIONS by lazy {
    mapOf(
        // S3
        // TODO(https://github.com/awslabs/aws-sdk-rust/issues/488) Technically, all S3 operations support presigning
        ShapeId.from("com.amazonaws.s3#GetObject") to PresignableOperation(PayloadSigningType.UNSIGNED_PAYLOAD),
        ShapeId.from("com.amazonaws.s3#PutObject") to PresignableOperation(PayloadSigningType.UNSIGNED_PAYLOAD),
        ShapeId.from("com.amazonaws.s3#UploadPart") to PresignableOperation(PayloadSigningType.UNSIGNED_PAYLOAD),
        ShapeId.from("com.amazonaws.s3#DeleteObject") to PresignableOperation(PayloadSigningType.UNSIGNED_PAYLOAD),

        // Polly
        SYNTHESIZE_SPEECH_OP to PresignableOperation(
+16 −0
Original line number Diff line number Diff line
@@ -112,3 +112,19 @@ async fn test_presigning_with_payload_headers() -> Result<(), Box<dyn Error>> {

    Ok(())
}

#[tokio::test]
async fn test_presigned_upload_part() -> Result<(), Box<dyn Error>> {
    let presigned = presign_input!(s3::input::UploadPartInput::builder()
        .content_length(12345)
        .bucket("bucket")
        .key("key")
        .part_number(0)
        .upload_id("upload-id")
        .build()?);
    assert_eq!(
        presigned.uri().to_string(),
        "https://s3.us-east-1.amazonaws.com/bucket/key?x-id=UploadPart&uploadId=upload-id&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ANOTREAL%2F20090213%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20090213T233131Z&X-Amz-Expires=30&X-Amz-SignedHeaders=content-length%3Bhost&X-Amz-Signature=e50e1a4d1dae7465bb7731863a565bdf4137393e3ab4119b5764fb49f5f60b14&X-Amz-Security-Token=notarealsessiontoken"
    );
    Ok(())
}