stratus 1.0.1 → 1.1.0
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.
- data/History.txt +3 -0
- data/README.markdown +9 -1
- data/VERSION +1 -1
- data/lib/stratus/aws/iam.rb +56 -0
- data/spec/stratus/aws/iam_spec.rb +150 -1
- metadata +3 -39
data/History.txt
CHANGED
data/README.markdown
CHANGED
@@ -75,6 +75,13 @@ And put it by PutUserPolicy API.
|
|
75
75
|
>> result['GetUserPolicyResult']['PolicyDocument']
|
76
76
|
"{\"Statement\":[{\"Action\":\"ec2:Describe*\",\"Resource\":\"*\",\"Effect\":\"Allow\"}]}"
|
77
77
|
|
78
|
+
Create login profile to access AWS Management Console.
|
79
|
+
|
80
|
+
>> @iam.create_login_profile(:user_name => 'john', :password => 'new password')
|
81
|
+
>> result = @iam.get_login_profile(:user_name => 'john')
|
82
|
+
>> @iam.update_login_profile(:user_name => 'john', :password => 'changed password')
|
83
|
+
>> @iam.delete_login_profile(:user_name => 'john')
|
84
|
+
|
78
85
|
Delete an user policy and user.
|
79
86
|
|
80
87
|
>> @iam.delete_user_policy :user_name => 'john', :policy_name => 'AllowDescribeEC2'
|
@@ -99,6 +106,7 @@ REFERENCES:
|
|
99
106
|
|
100
107
|
* [Using AWS Identity and Access Management](http://docs.amazonwebservices.com/IAM/latest/UserGuide/)
|
101
108
|
* [AWS Identity and Access Management API Reference](http://docs.amazonwebservices.com/IAM/latest/APIReference/)
|
109
|
+
* [Using AWS Identity and Access Management](http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?Using_AWSManagementConsole.html)
|
102
110
|
|
103
111
|
LICENSE:
|
104
112
|
----
|
@@ -108,4 +116,4 @@ This software is licensed under the MIT licenses.
|
|
108
116
|
COPYRIGHT:
|
109
117
|
----
|
110
118
|
|
111
|
-
Copyright (c)
|
119
|
+
Copyright (c) 2011 Serverworks Co.,Ltd. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/lib/stratus/aws/iam.rb
CHANGED
@@ -422,6 +422,52 @@ module Stratus
|
|
422
422
|
Response.parse(:xml => response.to_str)
|
423
423
|
end
|
424
424
|
|
425
|
+
# Calls get_login_profile API
|
426
|
+
#
|
427
|
+
# @param [Hash] options
|
428
|
+
# @return [Hash]
|
429
|
+
def get_login_profile(options = {})
|
430
|
+
check_user_name(options)
|
431
|
+
params = { 'UserName' => options[:user_name] }
|
432
|
+
response = call_api('GetLoginProfile', params)
|
433
|
+
Response.parse(:xml => response.to_str)
|
434
|
+
end
|
435
|
+
|
436
|
+
# Calls create_login_profile API
|
437
|
+
#
|
438
|
+
# @param [Hash] options
|
439
|
+
# @return [Hash]
|
440
|
+
def create_login_profile(options = {})
|
441
|
+
check_user_name(options)
|
442
|
+
check_password(options)
|
443
|
+
params = { 'UserName' => options[:user_name], 'Password' => options[:password] }
|
444
|
+
response = call_api('CreateLoginProfile', params)
|
445
|
+
Response.parse(:xml => response.to_str)
|
446
|
+
end
|
447
|
+
|
448
|
+
# Calls update_login_profile API
|
449
|
+
#
|
450
|
+
# @param [Hash] options
|
451
|
+
# @return [Hash]
|
452
|
+
def update_login_profile(options = {})
|
453
|
+
check_user_name(options)
|
454
|
+
check_password(options)
|
455
|
+
params = { 'UserName' => options[:user_name], 'Password' => options[:password] }
|
456
|
+
response = call_api('UpdateLoginProfile', params)
|
457
|
+
Response.parse(:xml => response.to_str)
|
458
|
+
end
|
459
|
+
|
460
|
+
# Calls delete_login_profile API
|
461
|
+
#
|
462
|
+
# @param [Hash] options
|
463
|
+
# @return [Hash]
|
464
|
+
def delete_login_profile(options = {})
|
465
|
+
check_user_name(options)
|
466
|
+
params = { 'UserName' => options[:user_name] }
|
467
|
+
response = call_api('DeleteLoginProfile', params)
|
468
|
+
Response.parse(:xml => response.to_str)
|
469
|
+
end
|
470
|
+
|
425
471
|
# @param [String] action AWS IAM API action name
|
426
472
|
# @param [Hash] params
|
427
473
|
# @return RestClient::Response
|
@@ -567,6 +613,16 @@ module Stratus
|
|
567
613
|
options
|
568
614
|
end
|
569
615
|
|
616
|
+
# Check to be sure the :password option exist
|
617
|
+
#
|
618
|
+
# @param [Hash] options
|
619
|
+
# @return [Hash]
|
620
|
+
# @raise [ArgumentError] throw if the option[:policy_document] is nil or empty.
|
621
|
+
def check_password(options)
|
622
|
+
raise ArgumentError, 'No password provided' if options[:password].nil? || options[:password].empty?
|
623
|
+
options
|
624
|
+
end
|
625
|
+
|
570
626
|
# Make a parameters hash for ***List methos from options
|
571
627
|
#
|
572
628
|
# ex. ListAccessKeys, ListUsers, ListGroups, etc...
|
@@ -751,6 +751,103 @@ describe "Stratus::AWS::IAM::Base" do
|
|
751
751
|
end
|
752
752
|
end
|
753
753
|
|
754
|
+
context '#get_login_profile' do
|
755
|
+
before(:each) do
|
756
|
+
response = stub(RestClient::Response, :code => '200', :to_str => get_login_profile_response, :empty? => false)
|
757
|
+
RestClient.stub!(:get).and_return(response)
|
758
|
+
end
|
759
|
+
|
760
|
+
it "must be able to get the intended user's login profile." do
|
761
|
+
result = @iam.get_login_profile(:user_name => 'User1')
|
762
|
+
result.should have_key('GetLoginProfileResult')
|
763
|
+
result['GetLoginProfileResult'].should have_key('LoginProfile')
|
764
|
+
result['GetLoginProfileResult']['LoginProfile'].should have_key('UserName')
|
765
|
+
result['GetLoginProfileResult']['LoginProfile'].should have_key('CreateDate')
|
766
|
+
end
|
767
|
+
|
768
|
+
it "must raise ArgumentError if the :user_name option haven't been passed." do
|
769
|
+
lambda { @iam.get_login_profile }.should raise_error(ArgumentError)
|
770
|
+
end
|
771
|
+
end
|
772
|
+
|
773
|
+
context '#create_login_profile' do
|
774
|
+
before(:each) do
|
775
|
+
response = stub(RestClient::Response, :code => '200', :to_str => create_login_profile_response)
|
776
|
+
RestClient.stub!(:get).and_return(response)
|
777
|
+
end
|
778
|
+
|
779
|
+
it "must be able to create a login profile" do
|
780
|
+
result = @iam.create_login_profile(:user_name => 'User1', :password => 'new password')
|
781
|
+
result.should have_key('CreateLoginProfileResult')
|
782
|
+
result['CreateLoginProfileResult'].should have_key('LoginProfile')
|
783
|
+
result['CreateLoginProfileResult']['LoginProfile'].should have_key('UserName')
|
784
|
+
result['CreateLoginProfileResult']['LoginProfile'].should have_key('CreateDate')
|
785
|
+
end
|
786
|
+
|
787
|
+
it "must raise ArgumentError if the :user_name option haven't been passed." do
|
788
|
+
lambda { @iam.create_login_profile(:password => 'password') }.should raise_error(ArgumentError)
|
789
|
+
end
|
790
|
+
|
791
|
+
it "must raise ArgumentError if the :password option haven't been passed." do
|
792
|
+
lambda { @iam.create_login_profile(:user_name => 'User1') }.should raise_error(ArgumentError)
|
793
|
+
end
|
794
|
+
end
|
795
|
+
|
796
|
+
context '#update_login_profile' do
|
797
|
+
before(:each) do
|
798
|
+
response = stub(RestClient::Response, :code => '200', :to_str => update_login_profile_response)
|
799
|
+
RestClient.stub!(:get).and_return(response)
|
800
|
+
end
|
801
|
+
|
802
|
+
it "must be able to update the intended user's login password" do
|
803
|
+
result = @iam.update_login_profile(:user_name => 'User1', :password => 'changed password')
|
804
|
+
result.should have_key('ResponseMetadata')
|
805
|
+
end
|
806
|
+
|
807
|
+
it "must raise ArgumentError if the :user_name option haven't been passed." do
|
808
|
+
lambda {
|
809
|
+
@iam.update_login_profile(:password => 'changed password')
|
810
|
+
}.should raise_error(ArgumentError)
|
811
|
+
end
|
812
|
+
|
813
|
+
it "must raise ArgumentError if the :status option haven't been passed." do
|
814
|
+
lambda {
|
815
|
+
@iam.update_login_profile(:user_name => 'User1')
|
816
|
+
}.should raise_error(ArgumentError)
|
817
|
+
end
|
818
|
+
|
819
|
+
it "must call the 'call_api' internally" do
|
820
|
+
@iam.should_receive(:call_api).with(
|
821
|
+
'UpdateLoginProfile', {'UserName' => 'user01', 'Password' => 'pass01'}
|
822
|
+
).once.and_return(update_login_profile_response)
|
823
|
+
@iam.update_login_profile(:user_name => 'user01', :password => 'pass01')
|
824
|
+
end
|
825
|
+
end
|
826
|
+
|
827
|
+
context '#delete_login_profile' do
|
828
|
+
before(:each) do
|
829
|
+
response = stub(RestClient::Response, :code => '200', :to_str => delete_login_profile_response)
|
830
|
+
RestClient.stub!(:get).and_return(response)
|
831
|
+
end
|
832
|
+
|
833
|
+
it "must be able to delete the intended user's login profile" do
|
834
|
+
result = @iam.delete_login_profile(:user_name => 'User1')
|
835
|
+
result.should have_key('ResponseMetadata')
|
836
|
+
end
|
837
|
+
|
838
|
+
it "must raise ArgumentError if the :user_name option haven't been passed." do
|
839
|
+
lambda { @iam.delete_login_profile(:name => 'User1') }.should raise_error(ArgumentError)
|
840
|
+
end
|
841
|
+
|
842
|
+
it "must call the 'call_api' internally." do
|
843
|
+
@iam.should_receive(:call_api).with(
|
844
|
+
'DeleteLoginProfile', {'UserName' => 'user01'}
|
845
|
+
).once.and_return(delete_login_profile_response)
|
846
|
+
@iam.delete_login_profile(:user_name => 'user01')
|
847
|
+
end
|
848
|
+
end
|
849
|
+
|
850
|
+
|
754
851
|
def get_group_response
|
755
852
|
return <<-RES
|
756
853
|
<GetGroupResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
|
@@ -1220,5 +1317,57 @@ nXg=
|
|
1220
1317
|
</ListSigningCertificatesResponse>
|
1221
1318
|
RES
|
1222
1319
|
end
|
1223
|
-
end
|
1224
1320
|
|
1321
|
+
def get_login_profile_response
|
1322
|
+
return <<-RES
|
1323
|
+
<GetLoginProfileResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
|
1324
|
+
<GetLoginProfileResult>
|
1325
|
+
<LoginProfile>
|
1326
|
+
<UserName>User1</UserName>
|
1327
|
+
<CreateDate>2011-04-11T05:23:02Z</CreateDate>
|
1328
|
+
</LoginProfile>
|
1329
|
+
</GetLoginProfileResult>
|
1330
|
+
<ResponseMetadata>
|
1331
|
+
<RequestId>7a8379c0-63fc-11e0-a132-51406a379f1d</RequestId>
|
1332
|
+
</ResponseMetadata>
|
1333
|
+
</GetLoginProfileResponse>
|
1334
|
+
RES
|
1335
|
+
end
|
1336
|
+
|
1337
|
+
def create_login_profile_response
|
1338
|
+
return <<-RES
|
1339
|
+
<CreateLoginProfileResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
|
1340
|
+
<CreateLoginProfileResult>
|
1341
|
+
<LoginProfile>
|
1342
|
+
<UserName>User1</UserName>
|
1343
|
+
<CreateDate>2011-04-11T05:23:02.945Z</CreateDate>
|
1344
|
+
</LoginProfile>
|
1345
|
+
</CreateLoginProfileResult>
|
1346
|
+
<ResponseMetadata>
|
1347
|
+
<RequestId>c5e4018a-63fb-11e0-8b3f-29b8ea28663b</RequestId>
|
1348
|
+
</ResponseMetadata>
|
1349
|
+
</CreateLoginProfileResponse>
|
1350
|
+
RES
|
1351
|
+
end
|
1352
|
+
|
1353
|
+
def update_login_profile_response
|
1354
|
+
return <<-RES
|
1355
|
+
<UpdateLoginProfileResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
|
1356
|
+
<ResponseMetadata>
|
1357
|
+
<RequestId>5af58461-63fd-11e0-ab24-a9776016b3b8</RequestId>
|
1358
|
+
</ResponseMetadata>
|
1359
|
+
</UpdateLoginProfileResponse>
|
1360
|
+
RES
|
1361
|
+
end
|
1362
|
+
|
1363
|
+
def delete_login_profile_response
|
1364
|
+
return <<-RES
|
1365
|
+
<DeleteLoginProfileResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
|
1366
|
+
<ResponseMetadata>
|
1367
|
+
<RequestId>9650fb39-63fd-11e0-833a-8f61616d730e</RequestId>
|
1368
|
+
</ResponseMetadata>
|
1369
|
+
</DeleteLoginProfileResponse>
|
1370
|
+
RES
|
1371
|
+
end
|
1372
|
+
|
1373
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stratus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 21
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 1.0.1
|
5
|
+
version: 1.1.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Serverworks Co.,Ltd.
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-
|
13
|
+
date: 2011-04-11 00:00:00 +09:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
@@ -26,11 +21,6 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ">="
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 23
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 3
|
33
|
-
- 10
|
34
24
|
version: 2.3.10
|
35
25
|
type: :runtime
|
36
26
|
version_requirements: *id001
|
@@ -42,11 +32,6 @@ dependencies:
|
|
42
32
|
requirements:
|
43
33
|
- - ">="
|
44
34
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 15
|
46
|
-
segments:
|
47
|
-
- 1
|
48
|
-
- 0
|
49
|
-
- 12
|
50
35
|
version: 1.0.12
|
51
36
|
type: :runtime
|
52
37
|
version_requirements: *id002
|
@@ -58,11 +43,6 @@ dependencies:
|
|
58
43
|
requirements:
|
59
44
|
- - ">="
|
60
45
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 13
|
62
|
-
segments:
|
63
|
-
- 1
|
64
|
-
- 6
|
65
|
-
- 1
|
66
46
|
version: 1.6.1
|
67
47
|
type: :runtime
|
68
48
|
version_requirements: *id003
|
@@ -74,11 +54,6 @@ dependencies:
|
|
74
54
|
requirements:
|
75
55
|
- - ">="
|
76
56
|
- !ruby/object:Gem::Version
|
77
|
-
hash: 55
|
78
|
-
segments:
|
79
|
-
- 0
|
80
|
-
- 9
|
81
|
-
- 6
|
82
57
|
version: 0.9.6
|
83
58
|
type: :development
|
84
59
|
version_requirements: *id004
|
@@ -90,11 +65,6 @@ dependencies:
|
|
90
65
|
requirements:
|
91
66
|
- - ">="
|
92
67
|
- !ruby/object:Gem::Version
|
93
|
-
hash: 13
|
94
|
-
segments:
|
95
|
-
- 1
|
96
|
-
- 2
|
97
|
-
- 9
|
98
68
|
version: 1.2.9
|
99
69
|
type: :development
|
100
70
|
version_requirements: *id005
|
@@ -141,23 +111,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
111
|
requirements:
|
142
112
|
- - ">="
|
143
113
|
- !ruby/object:Gem::Version
|
144
|
-
hash: 3
|
145
|
-
segments:
|
146
|
-
- 0
|
147
114
|
version: "0"
|
148
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
116
|
none: false
|
150
117
|
requirements:
|
151
118
|
- - ">="
|
152
119
|
- !ruby/object:Gem::Version
|
153
|
-
hash: 3
|
154
|
-
segments:
|
155
|
-
- 0
|
156
120
|
version: "0"
|
157
121
|
requirements: []
|
158
122
|
|
159
123
|
rubyforge_project:
|
160
|
-
rubygems_version: 1.
|
124
|
+
rubygems_version: 1.5.0
|
161
125
|
signing_key:
|
162
126
|
specification_version: 3
|
163
127
|
summary: Interface classes for the AWS Identity and Access Management (IAM)
|