Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/functional/s3/test_s3_object_lambda.py
1567 views
1
#!/usr/bin/env python
2
# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License"). You
5
# may not use this file except in compliance with the License. A copy of
6
# the License is located at
7
#
8
# http://aws.amazon.com/apache2.0/
9
#
10
# or in the "license" file accompanying this file. This file is
11
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12
# ANY KIND, either express or implied. See the License for the specific
13
# language governing permissions and limitations under the License.
14
from awscli.testutils import BaseAWSCommandParamsTest
15
16
17
class TestBannerResourcesHandling(BaseAWSCommandParamsTest):
18
19
prefixes = [
20
's3 ls s3://{banner_arn}',
21
's3 cp s3://{banner_arn} .',
22
's3 mv s3://{banner_arn} .',
23
's3 sync s3://{banner_arn} .',
24
's3 rm s3://{banner_arn}',
25
's3 mb s3://{banner_arn}',
26
's3 presign s3://{banner_arn}',
27
's3 rb s3://{banner_arn}',
28
's3 website s3://{banner_arn}',
29
]
30
31
def test_banner_arn_with_colon_raises_exception(self):
32
banner_arn = ('arn:aws:s3-object-lambda:us-west-2:123456789012:'
33
'accesspoint:my-accesspoint')
34
banner_arn_with_key = '%s/my-key' % banner_arn
35
for prefix in self.prefixes:
36
cmdline = prefix.format(banner_arn=banner_arn)
37
_, stderr, _ = self.run_cmd(cmdline, 255)
38
self.assertIn('s3 commands do not support', stderr)
39
cmdline = prefix.format(banner_arn=banner_arn_with_key)
40
_, stderr, _ = self.run_cmd(cmdline, 255)
41
self.assertIn('s3 commands do not support', stderr)
42
43
def test_banner_arn_with_slash_raises_exception(self):
44
banner_arn = ('arn:aws:s3-object-lambda:us-west-2:123456789012:'
45
'accesspoint/my-accesspoint')
46
banner_arn_with_key = '%s/my-key' % banner_arn
47
for prefix in self.prefixes:
48
cmdline = prefix.format(banner_arn=banner_arn)
49
_, stderr, _ = self.run_cmd(cmdline, 255)
50
self.assertIn('s3 commands do not support', stderr)
51
cmdline = prefix.format(banner_arn=banner_arn_with_key)
52
_, stderr, _ = self.run_cmd(cmdline, 255)
53
self.assertIn('s3 commands do not support', stderr)
54
55