aws-sdk-core 2.0.0.rc6 → 2.0.0.rc7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +48 -18
- data/apis/AutoScaling-2011-01-01.json +14 -6
- data/apis/CloudFormation-2010-05-15.json +6 -6
- data/apis/CloudFront-2012-05-05.json +5 -6
- data/apis/CloudFront-2013-05-12.json +5 -6
- data/apis/CloudFront-2013-08-26.json +5 -6
- data/apis/CloudFront-2013-11-11.json +5 -6
- data/apis/CloudFront-2013-11-22.json +5557 -0
- data/apis/CloudFront-2014-01-31.json +5627 -0
- data/apis/CloudSearch-2011-02-01.json +136 -4
- data/apis/CloudSearch-2013-01-01.json +3515 -0
- data/apis/CloudTrail-2013-11-01.json +288 -0
- data/apis/CloudWatch-2010-08-01.json +6 -6
- data/apis/DataPipeline-2012-10-29.json +0 -1
- data/apis/DirectConnect-2012-10-25.json +5 -6
- data/apis/DynamoDB-2011-12-05.json +6 -6
- data/apis/DynamoDB-2012-08-10.json +307 -6
- data/apis/EC2-2013-06-15.json +6 -6
- data/apis/EC2-2013-10-01.json +6 -6
- data/apis/EC2-2013-10-15.json +6 -6
- data/apis/EC2-2014-02-01.json +15189 -0
- data/apis/EMR-2009-03-31.json +8 -8
- data/apis/ElastiCache-2012-11-15.json +6 -6
- data/apis/ElastiCache-2013-06-15.json +6 -6
- data/apis/ElastiCache-2014-03-24.json +4344 -0
- data/apis/ElasticBeanstalk-2010-12-01.json +6 -7
- data/apis/ElasticLoadBalancing-2012-06-01.json +216 -6
- data/apis/ElasticTranscoder-2012-09-25.json +4 -5
- data/apis/Glacier-2012-06-01.json +5 -5
- data/apis/IAM-2010-05-08.json +6 -6
- data/apis/ImportExport-2010-06-01.json +5 -6
- data/apis/Kinesis-2013-12-02.json +2 -3
- data/apis/OpsWorks-2013-02-18.json +149 -2
- data/apis/RDS-2013-01-10.json +6 -6
- data/apis/RDS-2013-02-12.json +6 -6
- data/apis/RDS-2013-05-15.json +6 -6
- data/apis/RDS-2013-09-09.json +6 -6
- data/apis/Redshift-2012-12-01.json +64 -5
- data/apis/Route53-2012-12-12.json +5 -6
- data/apis/Route53-2013-04-01.json +37 -6
- data/apis/S3-2006-03-01.json +8 -7
- data/apis/SDB-2009-04-15.json +5 -6
- data/apis/SES-2010-12-01.json +0 -1
- data/apis/SNS-2010-03-31.json +6 -6
- data/apis/SQS-2012-11-05.json +154 -6
- data/apis/STS-2011-06-15.json +14 -6
- data/apis/SWF-2012-01-25.json +6 -6
- data/apis/StorageGateway-2012-06-30.json +16 -16
- data/apis/StorageGateway-2013-06-30.json +21 -21
- data/apis/Support-2013-04-15.json +0 -1
- data/apis/configuration/endpoints.json +258 -154
- data/apis/source/autoscaling-2011-01-01.json +19 -19
- data/apis/source/cloudformation-2010-05-15.json +17 -17
- data/apis/source/cloudfront-2013-11-22.json +8898 -0
- data/apis/source/cloudfront-2013-11-22.paginators.json +32 -0
- data/apis/source/cloudfront-2013-11-22.waiters.json +29 -0
- data/apis/source/cloudfront-2014-01-31.json +8975 -0
- data/apis/source/cloudfront-2014-01-31.normal.json +2905 -0
- data/apis/source/cloudfront-2014-01-31.paginators.json +32 -0
- data/apis/source/cloudfront-2014-01-31.waiters.json +29 -0
- data/apis/source/cloudsearch-2011-02-01.json +286 -8
- data/apis/source/cloudsearch-2013-01-01.json +5547 -0
- data/apis/source/cloudsearch-2013-01-01.paginators.json +20 -0
- data/apis/source/cloudtrail-2013-11-01.json +539 -0
- data/apis/source/cloudtrail-2013-11-01.paginators.json +7 -0
- data/apis/source/dynamodb-2011-12-05.json +19 -0
- data/apis/source/dynamodb-2012-08-10.json +415 -2
- data/apis/source/ec2-2014-02-01.json +20576 -0
- data/apis/source/ec2-2014-02-01.paginators.json +126 -0
- data/apis/source/ec2-2014-02-01.waiters.json +146 -0
- data/apis/source/elasticache-2014-03-24.json +6463 -0
- data/apis/source/elasticache-2014-03-24.paginators.json +70 -0
- data/apis/source/elasticloadbalancing-2012-06-01.json +455 -164
- data/apis/source/elasticloadbalancing-2012-06-01.normal.json +2107 -0
- data/apis/source/kinesis-2013-12-02.json +5 -5
- data/apis/source/kinesis-2013-12-02.normal.json +761 -0
- data/apis/source/kinesis-2013-12-02.paginators.json +6 -6
- data/apis/source/opsworks-2013-02-18.json +242 -39
- data/apis/source/opsworks-2013-02-18.paginators.json +3 -0
- data/apis/source/redshift-2012-12-01.json +180 -91
- data/apis/source/route53-2013-04-01.json +68 -4
- data/apis/source/sqs-2012-11-05.json +237 -7
- data/apis/source/sts-2011-06-15.json +18 -2
- data/bin/aws.rb +7 -7
- data/doc-src/plugins/apis.rb +1 -1
- data/features/cloudtrail/client.feature +17 -0
- data/features/cloudtrail/step_definitions.rb +6 -0
- data/features/datapipeline/client.feature +1 -1
- data/lib/aws.rb +21 -5
- data/lib/aws/api/service_translators/s3.rb +1 -0
- data/lib/aws/api/translator.rb +1 -2
- data/lib/aws/credential_provider_chain.rb +62 -0
- data/lib/aws/credentials.rb +4 -1
- data/lib/aws/errors.rb +4 -0
- data/lib/aws/plugins/credentials.rb +24 -31
- data/lib/aws/plugins/s3_location_constraint.rb +38 -0
- data/lib/aws/shared_credentials.rb +105 -0
- data/lib/aws/structure.rb +1 -0
- data/lib/aws/util.rb +18 -19
- data/lib/aws/version.rb +1 -1
- data/spec/aws/credentials_spec.rb +8 -0
- data/spec/aws/plugins/credentials_spec.rb +71 -15
- data/spec/aws/plugins/s3_location_constraint_spec.rb +48 -0
- data/spec/aws/shared_credentials_spec.rb +68 -0
- data/spec/aws/util_spec.rb +107 -0
- data/spec/aws_spec.rb +6 -0
- data/spec/fixtures/credentials/mock_shared_credentials +14 -0
- data/spec/fixtures/operations/s3/create_bucket_with_implied_location_constraint.yml +23 -0
- data/spec/spec_helper.rb +4 -0
- data/tasks/test.rake +10 -7
- data/vendor/seahorse/lib/seahorse/client/param_converter.rb +2 -2
- metadata +43 -3
- data/lib/aws/plugins/instance_profile_credentials.rb +0 -14
data/lib/aws/structure.rb
CHANGED
data/lib/aws/util.rb
CHANGED
@@ -4,28 +4,27 @@ module Aws
|
|
4
4
|
# @api private
|
5
5
|
module Util
|
6
6
|
|
7
|
+
# @api private
|
8
|
+
IRREGULAR_INFLECTIONS = {
|
9
|
+
'ARNs' => 'arns',
|
10
|
+
'CNAMEs' => 'cnames',
|
11
|
+
'Ec2' => 'ec2',
|
12
|
+
'ElastiCache' => 'elasticache',
|
13
|
+
'ETag' => 'etag',
|
14
|
+
'iSCSI' => 'iscsi',
|
15
|
+
}
|
16
|
+
|
17
|
+
# @api private
|
18
|
+
IRREGULAR_REGEX = Regexp.new(IRREGULAR_INFLECTIONS.keys.join('|'))
|
19
|
+
|
7
20
|
# @param [String] string
|
8
21
|
# @return [String] Returns the underscored version of the given string.
|
9
22
|
def underscore(string)
|
10
|
-
|
11
|
-
|
12
|
-
gsub(/([A-Z0-9]+)([A-Z][a-z])/, '\1_\2').
|
13
|
-
scan(/[a-
|
14
|
-
join('_').downcase
|
15
|
-
end
|
16
|
-
|
17
|
-
# add a few irregular inflections
|
18
|
-
inflector['ETag'] = 'etag'
|
19
|
-
inflector['s3Bucket'] = 's3_bucket'
|
20
|
-
inflector['s3Key'] = 's3_key'
|
21
|
-
inflector['Ec2KeyName'] = 'ec2_key_name'
|
22
|
-
inflector['Ec2SubnetId'] = 'ec2_subnet_id'
|
23
|
-
inflector['Ec2VolumeId'] = 'ec2_volume_id'
|
24
|
-
inflector['Ec2InstanceId'] = 'ec2_instance_id'
|
25
|
-
inflector['ElastiCache'] = 'elasticache'
|
26
|
-
inflector['NotificationARNs'] = 'notification_arns'
|
27
|
-
|
28
|
-
inflector[string]
|
23
|
+
string.
|
24
|
+
gsub(IRREGULAR_REGEX) { |word| '_' + IRREGULAR_INFLECTIONS[word] }.
|
25
|
+
gsub(/([A-Z0-9]+)([A-Z][a-z])/, '\1_\2').
|
26
|
+
scan(/[a-z0-9]+|\d+|[A-Z0-9]+[a-z]*/).
|
27
|
+
join('_').downcase
|
29
28
|
end
|
30
29
|
module_function :underscore
|
31
30
|
|
data/lib/aws/version.rb
CHANGED
@@ -34,6 +34,14 @@ module Aws
|
|
34
34
|
expect(Credentials.new('akid', nil).set?).to be(false)
|
35
35
|
end
|
36
36
|
|
37
|
+
it 'returns false if the key is an empty string' do
|
38
|
+
expect(Credentials.new('', 'secret').set?).to be(false)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns false if the secret is an empty string' do
|
42
|
+
expect(Credentials.new('akid', '').set?).to be(false)
|
43
|
+
end
|
44
|
+
|
37
45
|
end
|
38
46
|
end
|
39
47
|
end
|
@@ -8,8 +8,19 @@ module Aws
|
|
8
8
|
|
9
9
|
let(:plugin) { Plugins::Credentials.new }
|
10
10
|
|
11
|
+
|
11
12
|
before do
|
13
|
+
|
14
|
+
# remove all
|
12
15
|
stub_const("ENV", env)
|
16
|
+
|
17
|
+
# disable loading credentials from shared file
|
18
|
+
allow(Dir).to receive(:home).and_raise(ArgumentError)
|
19
|
+
|
20
|
+
# disable instance profile credentials
|
21
|
+
path = '/latest/meta-data/iam/security-credentials/'
|
22
|
+
stub_request(:get, "http://169.254.169.254#{path}").to_raise(SocketError)
|
23
|
+
|
13
24
|
end
|
14
25
|
|
15
26
|
describe 'configuration' do
|
@@ -26,19 +37,20 @@ module Aws
|
|
26
37
|
expect(config.build!.credentials).to be(nil)
|
27
38
|
end
|
28
39
|
|
29
|
-
it 'hydrates credentials from
|
30
|
-
|
31
|
-
|
32
|
-
|
40
|
+
it 'hydrates credentials from config options' do
|
41
|
+
options = {}
|
42
|
+
options[:access_key_id] = 'akid'
|
43
|
+
options[:secret_access_key] = 'secret'
|
44
|
+
options[:session_token] = 'session'
|
33
45
|
plugin.add_options(config)
|
34
|
-
cfg = config.build!
|
46
|
+
cfg = config.build!(options)
|
35
47
|
expect(cfg.credentials.set?).to be(true)
|
36
48
|
expect(cfg.credentials.access_key_id).to eq('akid')
|
37
49
|
expect(cfg.credentials.secret_access_key).to eq('secret')
|
38
|
-
expect(cfg.credentials.session_token).to eq('
|
50
|
+
expect(cfg.credentials.session_token).to eq('session')
|
39
51
|
end
|
40
52
|
|
41
|
-
it 'hydrates credentials from
|
53
|
+
it 'hydrates credentials from ENV with prefix AWS_' do
|
42
54
|
env['AWS_ACCESS_KEY_ID'] = 'akid'
|
43
55
|
env['AWS_SECRET_ACCESS_KEY'] = 'secret'
|
44
56
|
env['AWS_SESSION_TOKEN'] = 'token'
|
@@ -50,7 +62,7 @@ module Aws
|
|
50
62
|
expect(cfg.credentials.session_token).to eq('token')
|
51
63
|
end
|
52
64
|
|
53
|
-
it 'hydrates credentials from
|
65
|
+
it 'hydrates credentials from ENV with prefix AMAZON_' do
|
54
66
|
env['AMAZON_ACCESS_KEY_ID'] = 'akid2'
|
55
67
|
env['AMAZON_SECRET_ACCESS_KEY'] = 'secret2'
|
56
68
|
env['AMAZON_SESSION_TOKEN'] = 'token2'
|
@@ -62,17 +74,61 @@ module Aws
|
|
62
74
|
expect(cfg.credentials.session_token).to eq('token2')
|
63
75
|
end
|
64
76
|
|
65
|
-
it 'hydrates credentials
|
66
|
-
|
67
|
-
|
68
|
-
options[:secret_access_key] = 'secret'
|
69
|
-
options[:session_token] = 'session'
|
77
|
+
it 'hydrates credentials from ENV at AWS_ACCESS_KEY & AWS_SECRET_KEY' do
|
78
|
+
env['AWS_ACCESS_KEY'] = 'akid3'
|
79
|
+
env['AWS_SECRET_KEY'] = 'secret3'
|
70
80
|
plugin.add_options(config)
|
71
|
-
cfg = config.build!
|
81
|
+
cfg = config.build!
|
82
|
+
expect(cfg.credentials.set?).to be(true)
|
83
|
+
expect(cfg.credentials.access_key_id).to eq('akid3')
|
84
|
+
expect(cfg.credentials.secret_access_key).to eq('secret3')
|
85
|
+
expect(cfg.credentials.session_token).to be(nil)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'hydrates credentials from the shared credentials file' do
|
89
|
+
mock_path = File.join(
|
90
|
+
File.dirname(__FILE__), '..', '..', 'fixtures', 'credentials',
|
91
|
+
'mock_shared_credentials')
|
92
|
+
path = File.join('HOME', '.aws', 'credentials')
|
93
|
+
allow(Dir).to receive(:home).and_return('HOME')
|
94
|
+
allow(File).to receive(:exists?).with(path).and_return(true)
|
95
|
+
allow(File).to receive(:readable?).with(path).and_return(true)
|
96
|
+
expect(File).to receive(:read).with(path).and_return(File.read(mock_path))
|
97
|
+
plugin.add_options(config)
|
98
|
+
cfg = config.build!
|
99
|
+
cfg.credentials
|
100
|
+
expect(cfg.credentials).to be_kind_of(SharedCredentials)
|
101
|
+
expect(cfg.credentials.set?).to be(true)
|
102
|
+
expect(cfg.credentials.access_key_id).to eq('ACCESS_KEY_0')
|
103
|
+
expect(cfg.credentials.secret_access_key).to eq('SECRET_KEY_0')
|
104
|
+
expect(cfg.credentials.session_token).to eq('TOKEN_0')
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'hydrates credentials from the instance profile service' do
|
108
|
+
path = '/latest/meta-data/iam/security-credentials/'
|
109
|
+
resp = <<-JSON.strip
|
110
|
+
{
|
111
|
+
"Code" : "Success",
|
112
|
+
"LastUpdated" : "2013-11-22T20:03:48Z",
|
113
|
+
"Type" : "AWS-HMAC",
|
114
|
+
"AccessKeyId" : "akid",
|
115
|
+
"SecretAccessKey" : "secret",
|
116
|
+
"Token" : "token",
|
117
|
+
"Expiration" : "#{Time.now.strftime('%Y-%m-%dT%H:%M:%SZ')}"
|
118
|
+
}
|
119
|
+
JSON
|
120
|
+
stub_request(:get, "http://169.254.169.254#{path}").
|
121
|
+
to_return(:status => 200, :body => "profile-name\n")
|
122
|
+
stub_request(:get, "http://169.254.169.254#{path}profile-name").
|
123
|
+
to_return(:status => 200, :body => resp)
|
124
|
+
plugin.add_options(config)
|
125
|
+
cfg = config.build!
|
126
|
+
cfg.credentials
|
127
|
+
expect(cfg.credentials).to be_kind_of(InstanceProfileCredentials)
|
72
128
|
expect(cfg.credentials.set?).to be(true)
|
73
129
|
expect(cfg.credentials.access_key_id).to eq('akid')
|
74
130
|
expect(cfg.credentials.secret_access_key).to eq('secret')
|
75
|
-
expect(cfg.credentials.session_token).to eq('
|
131
|
+
expect(cfg.credentials.session_token).to eq('token')
|
76
132
|
end
|
77
133
|
|
78
134
|
it 'raises an error if you construct a client without credentials' do
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Plugins
|
5
|
+
describe S3LocationConstraint do
|
6
|
+
|
7
|
+
let(:config_region) {
|
8
|
+
cfg = Seahorse::Client::Configuration.new
|
9
|
+
cfg.add_option(:region, 'sa-east-1')
|
10
|
+
cfg.add_option(:endpoint, 's3-sa-east-1.amazonaws.com')
|
11
|
+
}
|
12
|
+
|
13
|
+
let(:params_with_constraint) {
|
14
|
+
{create_bucket_configuration: {location_constraint: 'my-fake-1'}}
|
15
|
+
}
|
16
|
+
|
17
|
+
let(:config_default) {
|
18
|
+
cfg = Seahorse::Client::Configuration.new
|
19
|
+
cfg.add_option(:region, 'us-east-1')
|
20
|
+
cfg.add_option(:endpoint, 's3.amazonaws.com')
|
21
|
+
}
|
22
|
+
|
23
|
+
it 'coerces the location constraint from the S3 region' do
|
24
|
+
resp = call_handler(S3LocationConstraint::Handler,
|
25
|
+
params: {}, config: config_region)
|
26
|
+
expect(resp.context
|
27
|
+
.params[:create_bucket_configuration][:location_constraint])
|
28
|
+
.to eq('sa-east-1')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'does not set location constraint when no region is specified' do
|
32
|
+
resp = call_handler(S3LocationConstraint::Handler,
|
33
|
+
params: {}, config: config_default)
|
34
|
+
expect(resp.context
|
35
|
+
.params[:create_bucket_configuration]).to be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'does not override a specified location constraint' do
|
39
|
+
resp = call_handler(S3LocationConstraint::Handler,
|
40
|
+
params: params_with_constraint,
|
41
|
+
config: config_region)
|
42
|
+
expect(resp.context
|
43
|
+
.params[:create_bucket_configuration][:location_constraint])
|
44
|
+
.to eq('my-fake-1')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
describe SharedCredentials do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
stub_const('ENV', {})
|
8
|
+
allow(Dir).to receive(:home).and_raise(ArgumentError)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:mock_credential_file) {
|
12
|
+
File.expand_path(File.join(File.dirname(__FILE__),
|
13
|
+
'..', 'fixtures', 'credentials', 'mock_shared_credentials'))
|
14
|
+
}
|
15
|
+
|
16
|
+
it 'defaults path to Dir.home/.aws/credentials' do
|
17
|
+
expect(Dir).to receive(:home).and_return('HOME')
|
18
|
+
credentials = SharedCredentials.new
|
19
|
+
expect(credentials.path).to eq(File.join('HOME', '.aws', 'credentials'))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'reads the correct default credentials from a credentials file' do
|
23
|
+
creds = SharedCredentials.new(path:mock_credential_file)
|
24
|
+
expect(creds.access_key_id).to eq('ACCESS_KEY_0')
|
25
|
+
expect(creds.secret_access_key).to eq('SECRET_KEY_0')
|
26
|
+
expect(creds.session_token).to eq('TOKEN_0')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'supports fetching profiles from ENV' do
|
30
|
+
stub_const('ENV', { 'AWS_PROFILE' => 'barprofile' })
|
31
|
+
creds = SharedCredentials.new(path:mock_credential_file)
|
32
|
+
expect(creds.access_key_id).to eq('ACCESS_KEY_2')
|
33
|
+
expect(creds.secret_access_key).to eq('SECRET_KEY_2')
|
34
|
+
expect(creds.session_token).to eq('TOKEN_2')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'supports a manually specified profile' do
|
38
|
+
stub_const('ENV', { 'AWS_PROFILE' => 'barporfile' })
|
39
|
+
creds = SharedCredentials.new(
|
40
|
+
path: mock_credential_file,
|
41
|
+
profile_name: 'fooprofile')
|
42
|
+
expect(creds.access_key_id).to eq('ACCESS_KEY_1')
|
43
|
+
expect(creds.secret_access_key).to eq('SECRET_KEY_1')
|
44
|
+
expect(creds.session_token).to eq('TOKEN_1')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'raises when a profile does not exist' do
|
48
|
+
msg = /^Profile `bazprofile' not found in .+mock_shared_credentials/
|
49
|
+
expect {
|
50
|
+
SharedCredentials.new(
|
51
|
+
path: mock_credential_file,
|
52
|
+
profile_name: 'bazprofile'
|
53
|
+
)
|
54
|
+
}.to raise_error(Errors::NoSuchProfileError, msg)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'is set when credentails is valid' do
|
58
|
+
creds = SharedCredentials.new(path:mock_credential_file)
|
59
|
+
expect(creds.set?).to eq(true)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'is not set when key_id or access_key is missing' do
|
63
|
+
creds = SharedCredentials.new(path:'/no/file/here')
|
64
|
+
expect(creds.set?).to eq(false)
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
require 'spec_helper'
|
15
|
+
|
16
|
+
module Aws::Util
|
17
|
+
describe 'underscore' do
|
18
|
+
|
19
|
+
include Aws::Util
|
20
|
+
|
21
|
+
it 'downcases titleized words' do
|
22
|
+
expect(underscore('Foo')).to eq('foo')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'breaks compound titleized words with underscores' do
|
26
|
+
expect(underscore('FooBarYuck')).to eq('foo_bar_yuck')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'treats acronyms as a single word' do
|
30
|
+
expect(underscore('AWS')).to eq('aws')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'preserves leading acronyms' do
|
34
|
+
expect(underscore('AWSAccount')).to eq('aws_account')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'preserves trailing acronyms' do
|
38
|
+
expect(underscore('SimpleDB')).to eq('simple_db')
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'preserves nested acronyms' do
|
42
|
+
expect(underscore('MySUPERWord')).to eq('my_super_word')
|
43
|
+
expect(underscore('AWSAccountID')).to eq('aws_account_id')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'treats trailing numbers as a part of acronyms' do
|
47
|
+
expect(underscore('MD5OfBody')).to eq('md5_of_body')
|
48
|
+
expect(underscore('S3Bucket')).to eq('s3_bucket')
|
49
|
+
expect(underscore('EC2Instance')).to eq('ec2_instance')
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'does not include leading numbers as part of a word' do
|
53
|
+
expect(underscore('SentLast24Hours')).to eq('sent_last_24_hours')
|
54
|
+
expect(underscore('24MIN')).to eq('24_min')
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'accepts words that start with a lower case letter' do
|
58
|
+
expect(underscore('s3Key')).to eq('s3_key')
|
59
|
+
expect(underscore('s3Bucket')).to eq('s3_bucket')
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'irregular inflections' do
|
63
|
+
# A known list of irregular strings that need to inflect correctly
|
64
|
+
{
|
65
|
+
'ETag' => 'etag',
|
66
|
+
's3Bucket' => 's3_bucket',
|
67
|
+
's3Key' => 's3_key',
|
68
|
+
'Ec2KeyName' => 'ec2_key_name',
|
69
|
+
'Ec2SubnetId' => 'ec2_subnet_id',
|
70
|
+
'Ec2VolumeId' => 'ec2_volume_id',
|
71
|
+
'Ec2InstanceId' => 'ec2_instance_id',
|
72
|
+
'ElastiCache' => 'elasticache',
|
73
|
+
'NotificationARNs' => 'notification_arns',
|
74
|
+
'SentLast24Hours' => 'sent_last_24_hours',
|
75
|
+
'Max24HourSend' => 'max_24_hour_send',
|
76
|
+
'AuthenticationCode1' => 'authentication_code_1',
|
77
|
+
'AuthenticationCode2' => 'authentication_code_2',
|
78
|
+
'SwapEnvironmentCNAMEs' => 'swap_environment_cnames',
|
79
|
+
'CachediSCSIVolume' => 'cached_iscsi_volume',
|
80
|
+
'CachediSCSIVolumeInformation' => 'cached_iscsi_volume_information',
|
81
|
+
'CachediSCSIVolumes' => 'cached_iscsi_volumes',
|
82
|
+
'CreateCachediSCSIVolume' => 'create_cached_iscsi_volume',
|
83
|
+
'CreateCachediSCSIVolumeInput' => 'create_cached_iscsi_volume_input',
|
84
|
+
'CreateCachediSCSIVolumeOutput' => 'create_cached_iscsi_volume_output',
|
85
|
+
'CreateStorediSCSIVolume' => 'create_stored_iscsi_volume',
|
86
|
+
'CreateStorediSCSIVolumeInput' => 'create_stored_iscsi_volume_input',
|
87
|
+
'CreateStorediSCSIVolumeOutput' => 'create_stored_iscsi_volume_output',
|
88
|
+
'DescribeCachediSCSIVolumes' => 'describe_cached_iscsi_volumes',
|
89
|
+
'DescribeCachediSCSIVolumesInput' => 'describe_cached_iscsi_volumes_input',
|
90
|
+
'DescribeCachediSCSIVolumesOutput' => 'describe_cached_iscsi_volumes_output',
|
91
|
+
'DescribeStorediSCSIVolumes' => 'describe_stored_iscsi_volumes',
|
92
|
+
'DescribeStorediSCSIVolumesInput' => 'describe_stored_iscsi_volumes_input',
|
93
|
+
'DescribeStorediSCSIVolumesOutput' => 'describe_stored_iscsi_volumes_output',
|
94
|
+
'DeviceiSCSIAttributes' => 'device_iscsi_attributes',
|
95
|
+
'StorediSCSIVolume' => 'stored_iscsi_volume',
|
96
|
+
'StorediSCSIVolumeInformation' => 'stored_iscsi_volume_information',
|
97
|
+
'StorediSCSIVolumes' => 'stored_iscsi_volumes',
|
98
|
+
'VolumeiSCSIAttributes' => 'volume_iscsi_attributes'
|
99
|
+
}.each do |camel_case, underscored|
|
100
|
+
it "inflects #{camel_case} to #{underscored}" do
|
101
|
+
expect(underscore(camel_case)).to eq(underscored)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
data/spec/aws_spec.rb
CHANGED
@@ -68,6 +68,12 @@ module Aws
|
|
68
68
|
expect(svc.config.http_wire_trace).to be(true)
|
69
69
|
end
|
70
70
|
|
71
|
+
it 'adds the helper method to Aws (not Module)' do
|
72
|
+
Aws.add_service(:DummyService, ['apis/S3-2006-03-01.json'])
|
73
|
+
expect(Aws).to respond_to(:dummyservice)
|
74
|
+
expect(Aws.class).not_to respond_to(:dummyservice)
|
75
|
+
end
|
76
|
+
|
71
77
|
it 'filters the :api_version option from the client constructor' do
|
72
78
|
Aws.add_service(:DummyService, ['apis/S3-2006-03-01.json'])
|
73
79
|
Aws.config[:api_version] = '2007-01-01'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
[default]
|
2
|
+
aws_access_key_id = ACCESS_KEY_0
|
3
|
+
aws_secret_access_key = SECRET_KEY_0
|
4
|
+
aws_session_token = TOKEN_0
|
5
|
+
|
6
|
+
[fooprofile]
|
7
|
+
aws_access_key_id = ACCESS_KEY_1
|
8
|
+
aws_secret_access_key = SECRET_KEY_1
|
9
|
+
aws_session_token = TOKEN_1
|
10
|
+
|
11
|
+
[barprofile]
|
12
|
+
aws_access_key_id = ACCESS_KEY_2
|
13
|
+
aws_secret_access_key = SECRET_KEY_2
|
14
|
+
aws_session_token = TOKEN_2
|