Skip to content

Commit

Permalink
Add "uri other chars" test
Browse files Browse the repository at this point in the history
  • Loading branch information
castaway committed Mar 16, 2020
1 parent 96f3778 commit 8329499
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
25 changes: 15 additions & 10 deletions auto-lib/Paws/SQS/SendMessage.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ You shouldn't make instances of this class. Each attribute should be used as a n
# Results:
my $MD5OfMessageAttributes = $SendMessageResult->MD5OfMessageAttributes;
my $MD5OfMessageBody = $SendMessageResult->MD5OfMessageBody;
my $MessageId = $SendMessageResult->MessageId;
my $SequenceNumber = $SendMessageResult->SequenceNumber;
my $MD5OfMessageBody = $SendMessageResult->MD5OfMessageBody;
my $MessageId = $SendMessageResult->MessageId;
Expand Down Expand Up @@ -79,8 +81,8 @@ You can set this parameter only on a queue level.
=head2 MessageAttributes => L<Paws::SQS::MessageBodyAttributeMap>
Each message attribute consists of a C<Name>, C<Type>, and C<Value>.
For more information, see Message Attribute Items and Validation
(http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-attributes.html#message-attributes-items-validation)
For more information, see Amazon SQS Message Attributes
(https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-attributes.html)
in the I<Amazon Simple Queue Service Developer Guide>.
Expand Down Expand Up @@ -110,7 +112,7 @@ particular C<MessageDeduplicationId> is sent successfully, any messages
sent with the same C<MessageDeduplicationId> are accepted successfully
but aren't delivered during the 5-minute deduplication interval. For
more information, see Exactly-Once Processing
(http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing)
(https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing)
in the I<Amazon Simple Queue Service Developer Guide>.
=over
Expand Down Expand Up @@ -160,21 +162,24 @@ delivered.
=back
The C<MessageDeduplicationId> is available to the recipient of the
The C<MessageDeduplicationId> is available to the consumer of the
message (this can be useful for troubleshooting delivery issues).
If a message is sent successfully but the acknowledgement is lost and
the message is resent with the same C<MessageDeduplicationId> after the
deduplication interval, Amazon SQS can't detect duplicate messages.
Amazon SQS continues to keep track of the message deduplication ID even
after the message is received and deleted.
The length of C<MessageDeduplicationId> is 128 characters.
C<MessageDeduplicationId> can contain alphanumeric characters (C<a-z>,
C<A-Z>, C<0-9>) and punctuation
(C<!"#$%&'()*+,-./:;E<lt>=E<gt>?@[\]^_`{|}~>).
For best practices of using C<MessageDeduplicationId>, see Using the
MessageDeduplicationId Property
(http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queue-recommendations.html#using-messagededuplicationid-property)
(https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-messagededuplicationid-property.html)
in the I<Amazon Simple Queue Service Developer Guide>.
Expand All @@ -188,8 +193,8 @@ group. Messages that belong to the same message group are processed in
a FIFO manner (however, messages in different message groups might be
processed out of order). To interleave multiple ordered streams within
a single queue, use C<MessageGroupId> values (for example, session data
for multiple users). In this scenario, multiple readers can process the
queue, but the session data of each user is processed in a FIFO
for multiple users). In this scenario, multiple consumers can process
the queue, but the session data of each user is processed in a FIFO
fashion.
=over
Expand All @@ -207,13 +212,13 @@ sent. The caller can't specify a C<MessageGroupId>.
=back
The length of C<MessageGroupId> is 128 characters. Valid values are
The length of C<MessageGroupId> is 128 characters. Valid values:
alphanumeric characters and punctuation
C<(!"#$%&'()*+,-./:;E<lt>=E<gt>?@[\]^_`{|}~)>.
For best practices of using C<MessageGroupId>, see Using the
MessageGroupId Property
(http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queue-recommendations.html#using-messagegroupid-property)
(https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-messagegroupid-property.html)
in the I<Amazon Simple Queue Service Developer Guide>.
C<MessageGroupId> is required for FIFO queues. You can't use it for
Expand All @@ -225,7 +230,7 @@ Standard queues.
The URL of the Amazon SQS queue to which a message is sent.
Queue URLs are case-sensitive.
Queue URLs and names are case-sensitive.
Expand Down
2 changes: 2 additions & 0 deletions lib/Paws/Net/Caller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package Paws::Net::Caller;
# HTTP::Tiny derives the Host header from the URL. It's an error to set it.
delete $headers->{Host};

# print STDERR Data::Dumper::Dumper($requestObj);
my $response = $self->ua->request(
$requestObj->method,
$requestObj->url,
Expand All @@ -30,6 +31,7 @@ package Paws::Net::Caller;
(defined $requestObj->content)?(content => $requestObj->content):(),
}
);
print STDERR Data::Dumper::Dumper($response);
return Paws::Net::APIResponse->new(
status => $response->{status},
content => $response->{content},
Expand Down
4 changes: 1 addition & 3 deletions t/s3/uri_avoid_chars.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ my $paws = Paws->new(config => {
caller => Paws::Net::MockCaller->new(
mock_dir => 't/s3/uri_avoid_chars',
mock_mode => 'REPLAY',
mock_mode => 'RECORD',
# mock_mode => 'RECORD',
),
# credentials => 'Test::CustomCredentials'
});
Expand Down Expand Up @@ -55,8 +55,6 @@ foreach my $char (@to_encode) {
);
};

## The URI should contain a once-encoded character:
# is($s3->caller->actual_request->url, 'https://s3-us-west-2.amazonaws.com/test-uri-paws/test' . uri_escape($char), "S3 uri encoded correctly");
}

done_testing;
21 changes: 13 additions & 8 deletions t/s3/uri_other_chars.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ use Test::More;
use URI::Escape;

use Paws;
#use Paws::Net::MockCaller;
use TestRequestCaller;
use Paws::Net::MockCaller;

Paws->default_config->caller(TestRequestCaller->new);
Paws->default_config->credentials('Test::CustomCredentials');
my $paws = Paws->new(config => {
caller => Paws::Net::MockCaller->new(
mock_dir => 't/s3/uri_other_chars',
mock_mode => 'REPLAY',
# mock_mode => 'RECORD',
),
# credentials => 'Test::CustomCredentials'
});

my $bucketname = 'test-uri-paws';
my $s3 = Paws->service('S3', region => 'us-west-2');
my $bucketname = 'shadowcatjesstest';
my $s3 = $paws->service('S3', region => 'us-west-2');

my @to_encode = ("\0243", # GBP currency sign
"\0251", # copyright symbol
Expand All @@ -34,11 +39,11 @@ foreach my $char (@to_encode) {
"Body" => 'Blub',
);
} or do {
diag qq[Error creating object: $@];
warn qq[Error creating object: $@];
};

## The URI should contain a once-encoded character:
is($response->url, 'https://s3-us-west-2.amazonaws.com/test-uri-paws/test' . uri_escape($char), "S3 uri encoded correctly");
is($s3->caller->actual_request->url, 'https://s3-us-west-2.amazonaws.com/test-uri-paws/test' . uri_escape($char), "S3 uri encoded correctly");
}

done_testing;
1 change: 1 addition & 0 deletions t/s3/uri_other_chars/0001.response
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"request":{"params":{"Bucket":"shadowcatjesstest","Key":"test\0243","Body":"Blub"},"call":"PutObject","service":"s3"},"response":{"headers":{"etag":"\"964410c877790f4044fac96b253f8b2a\"","connection":"close","x-amz-request-id":"000000000000000000000000000000000000","date":"Thu, 14 Jun 2018 12:08:54 GMT","x-amz-id-2":"aa/eaWwr6j0ZQNyQLQffMBrrfimONvjXzDnFI6n/QQneY7XUSMnxO4yUPhA4KUcKumxqf+SAemo=","server":"AmazonS3","content-length":"0"},"status":"200","content":""}}
1 change: 1 addition & 0 deletions t/s3/uri_other_chars/0002.response
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"request":{"params":{"Bucket":"shadowcatjesstest","Key":"test\0251","Body":"Blub"},"call":"PutObject","service":"s3"},"response":{"headers":{"etag":"\"964410c877790f4044fac96b253f8b2a\"","connection":"close","x-amz-request-id":"000000000000000000000000000000000000","date":"Thu, 14 Jun 2018 12:08:55 GMT","x-amz-id-2":"IqJFZjEHrDSPZsD4ZGaobaAPzh6BXj5Y6VytfxlElJeD5HDoEyrmL9IYRLeUXEkLOQoty4W4Kl8=","server":"AmazonS3","content-length":"0"},"status":"200","content":""}}

0 comments on commit 8329499

Please sign in to comment.