Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/functional/route53/test_resource_id.py
1567 views
1
#!/usr/bin/env python
2
# Copyright 2012-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
CHANGEBATCH_JSON = ('{"Comment":"string","Changes":['
18
'{"Action":"CREATE","ResourceRecordSet":{'
19
'"Name":"test-foo.bar.com",'
20
'"Type":"CNAME",'
21
'"TTL":300,'
22
'"ResourceRecords":['
23
'{"Value":"foo-bar-com"}'
24
']}}]}')
25
26
27
class TestGetHostedZone(BaseAWSCommandParamsTest):
28
29
prefix = 'route53 get-hosted-zone'
30
31
def setUp(self):
32
super(TestGetHostedZone, self).setUp()
33
34
def test_full_resource_id(self):
35
args = ' --id /hostedzone/ZD3IYMVP1KDDM'
36
cmdline = self.prefix + args
37
self.assert_params_for_cmd(
38
cmdline, {'Id': 'ZD3IYMVP1KDDM'}, expected_rc=0)
39
40
def test_short_resource_id(self):
41
args = ' --id ZD3IYMVP1KDDM'
42
cmdline = self.prefix + args
43
self.assert_params_for_cmd(
44
cmdline, {'Id': 'ZD3IYMVP1KDDM'},
45
expected_rc=0)
46
47
48
class TestChangeResourceRecord(BaseAWSCommandParamsTest):
49
50
prefix = 'route53 change-resource-record-sets'
51
52
def setUp(self):
53
super(TestChangeResourceRecord, self).setUp()
54
55
def test_full_resource_id(self):
56
args = ' --hosted-zone-id /change/ZD3IYMVP1KDDM'
57
args += ' --change-batch %s' % CHANGEBATCH_JSON
58
cmdline = self.prefix + args
59
expected = {
60
"HostedZoneId": "ZD3IYMVP1KDDM",
61
"ChangeBatch": {
62
"Comment": "string",
63
"Changes": [
64
{
65
"Action": "CREATE",
66
"ResourceRecordSet": {
67
"Name": "test-foo.bar.com",
68
"Type": "CNAME",
69
"TTL": 300,
70
"ResourceRecords": [
71
{
72
"Value": "foo-bar-com"
73
}
74
]
75
}
76
}
77
]
78
}
79
}
80
self.assert_params_for_cmd(cmdline, expected, expected_rc=0)
81
82
83
class TestGetChange(BaseAWSCommandParamsTest):
84
85
prefix = 'route53 get-change'
86
87
def setUp(self):
88
super(TestGetChange, self).setUp()
89
90
def test_full_resource_id(self):
91
args = ' --id /change/ZD3IYMVP1KDDM'
92
cmdline = self.prefix + args
93
expected = {'Id': 'ZD3IYMVP1KDDM'}
94
self.assert_params_for_cmd(cmdline, expected, expected_rc=0)
95
96
def test_short_resource_id(self):
97
args = ' --id ZD3IYMVP1KDDM'
98
cmdline = self.prefix + args
99
expected = {'Id': 'ZD3IYMVP1KDDM'}
100
self.assert_params_for_cmd(cmdline, expected, expected_rc=0)
101
102
103
class TestReusableDelegationSet(BaseAWSCommandParamsTest):
104
105
prefix = 'route53 get-reusable-delegation-set'
106
107
def setUp(self):
108
super(TestReusableDelegationSet, self).setUp()
109
110
def test_full_resource_id(self):
111
args = ' --id /delegationset/N9INWVYQ6Q0FN'
112
cmdline = self.prefix + args
113
self.assert_params_for_cmd(cmdline, {'Id': 'N9INWVYQ6Q0FN'},
114
expected_rc=0)
115
116
def test_short_resource_id(self):
117
args = ' --id N9INWVYQ6Q0FN'
118
cmdline = self.prefix + args
119
self.assert_params_for_cmd(cmdline, {'Id': 'N9INWVYQ6Q0FN'},
120
expected_rc=0)
121
122
123
class TestMaxItems(BaseAWSCommandParamsTest):
124
125
prefix = 'route53 list-resource-record-sets'
126
127
def test_full_resource_id(self):
128
args = ' --hosted-zone-id /hostedzone/ABCD --max-items 1'
129
cmdline = self.prefix + args
130
expected = {'HostedZoneId': 'ABCD'}
131
self.assert_params_for_cmd(cmdline, expected, expected_rc=0)
132
133