nephophobia 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/nephophobia/project.rb +5 -2
- data/lib/nephophobia/role.rb +1 -1
- data/lib/nephophobia/version.rb +1 -1
- data/test/cassettes/compute_all.yml +4 -4
- data/test/cassettes/compute_all_with_filter.yml +3 -3
- data/test/cassettes/compute_all_with_string_into_int_error.yml +1 -1
- data/test/cassettes/compute_create.yml +4 -4
- data/test/cassettes/compute_create_with_optional_params.yml +4 -4
- data/test/cassettes/compute_destroy.yml +3 -3
- data/test/cassettes/compute_find.yml +4 -4
- data/test/cassettes/compute_reboot.yml +3 -3
- data/test/cassettes/image_all.yml +4 -4
- data/test/cassettes/image_all_with_filter.yml +4 -4
- data/test/cassettes/image_all_with_string_into_int_error.yml +1 -1
- data/test/cassettes/image_find.yml +4 -4
- data/test/cassettes/project_add_member.yml +3 -3
- data/test/cassettes/project_all.yml +3 -3
- data/test/cassettes/project_create.yml +4 -4
- data/test/cassettes/project_destroy.yml +3 -3
- data/test/cassettes/project_find.yml +4 -4
- data/test/cassettes/{project_find_with_invalid_username.yml → project_find_with_invalid_project_name.yml} +0 -0
- data/test/cassettes/project_members.yml +4 -4
- data/test/cassettes/project_members_with_invalid_project_name.yml +30 -0
- data/test/cassettes/project_members_with_no_members.yml +28 -0
- data/test/cassettes/project_members_with_string_into_int_error.yml +28 -0
- data/test/cassettes/project_remove_member.yml +3 -3
- data/test/cassettes/role_all.yml +3 -3
- data/test/cassettes/role_all_with_no_roles.yml +3 -3
- data/test/cassettes/role_all_with_string_into_int_error.yml +1 -1
- data/test/cassettes/role_create.yml +3 -3
- data/test/cassettes/role_create_with_project_name.yml +3 -3
- data/test/cassettes/role_create_with_project_name_and_role_name.yml +3 -3
- data/test/cassettes/role_destroy.yml +3 -3
- data/test/cassettes/role_destroy_with_project_name.yml +27 -0
- data/test/cassettes/role_destroy_with_project_name_and_role_name.yml +27 -0
- data/test/cassettes/user_create.yml +4 -4
- data/test/cassettes/user_credentials.yml +8 -6
- data/test/cassettes/user_destroy.yml +3 -3
- data/test/cassettes/user_find.yml +4 -4
- data/test/cassettes/user_find_with_invalid_user_name.yml +2 -31
- data/test/lib/hashify_test.rb +2 -2
- data/test/lib/nephophobia/compute_test.rb +33 -27
- data/test/lib/nephophobia/image_test.rb +14 -8
- data/test/lib/nephophobia/project_test.rb +31 -19
- data/test/lib/nephophobia/role_test.rb +7 -5
- data/test/lib/nephophobia/user_test.rb +6 -8
- data/test/test_helper.rb +17 -15
- metadata +10 -8
- data/test/cassettes/compute_start.yml +0 -30
- data/test/cassettes/compute_stop.yml +0 -30
@@ -1,14 +1,20 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
describe Nephophobia::Image do
|
4
|
-
before
|
4
|
+
before do
|
5
|
+
@image = ::Client.with(:user,
|
6
|
+
:access_key => "57c971e9-0225-4fa4-8969-60b880e9f827",
|
7
|
+
:secret_key => "86a6a123-2d11-4e99-9931-20b01f6fb236",
|
8
|
+
:project => "vcr_project"
|
9
|
+
).image
|
10
|
+
end
|
5
11
|
|
6
12
|
describe "#all" do
|
7
13
|
it "returns all images" do
|
8
14
|
VCR.use_cassette "image_all" do
|
9
15
|
response = @image.all
|
10
16
|
|
11
|
-
response.size.must_equal
|
17
|
+
response.size.must_equal 10
|
12
18
|
end
|
13
19
|
end
|
14
20
|
|
@@ -16,7 +22,7 @@ describe Nephophobia::Image do
|
|
16
22
|
VCR.use_cassette "image_all_with_filter" do
|
17
23
|
response = @image.all "ExecutableBy.1" => "self"
|
18
24
|
|
19
|
-
response.size.must_equal
|
25
|
+
response.size.must_equal 10
|
20
26
|
end
|
21
27
|
end
|
22
28
|
|
@@ -31,7 +37,7 @@ describe Nephophobia::Image do
|
|
31
37
|
|
32
38
|
describe "#find" do
|
33
39
|
before do
|
34
|
-
@image_id = "ami-
|
40
|
+
@image_id = "ami-d0f0o14c"
|
35
41
|
|
36
42
|
VCR.use_cassette "image_find" do
|
37
43
|
@response = @image.find @image_id
|
@@ -46,12 +52,12 @@ describe Nephophobia::Image do
|
|
46
52
|
image = @response
|
47
53
|
|
48
54
|
image.architecture.must_equal "x86_64"
|
49
|
-
image.image_id.must_equal
|
50
|
-
image.image_location.must_equal "ttylinx-bucket/ttylinux-uec-amd64-12.1_2.6.35-22_1.
|
55
|
+
image.image_id.must_equal @image_id
|
56
|
+
image.image_location.must_equal "ttylinx-bucket/ttylinux-uec-amd64-12.1_2.6.35-22_1-vmlinuz.manifest.xml"
|
51
57
|
image.image_owner_id.must_equal "production"
|
52
|
-
image.image_type.must_equal "
|
58
|
+
image.image_type.must_equal "kernel"
|
53
59
|
image.is_public.must_equal "false"
|
54
|
-
image.kernel_id.must_equal "
|
60
|
+
image.kernel_id.must_equal "true"
|
55
61
|
image.state.must_equal "available"
|
56
62
|
end
|
57
63
|
end
|
@@ -2,13 +2,15 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
describe Nephophobia::Project do
|
4
4
|
before do
|
5
|
-
@project =
|
6
|
-
@user =
|
7
|
-
@user_name = "
|
8
|
-
@project_name = "
|
5
|
+
@project = ::Client.with(:admin).project
|
6
|
+
@user = ::Client.with(:admin).user
|
7
|
+
@user_name = "vcr"
|
8
|
+
@project_name = "vcr_project"
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#add_member" do
|
12
|
+
before { @project_name = "vcr_secondary_project" }
|
13
|
+
|
12
14
|
it "adds the given 'user_name' to the specified 'project_name'" do
|
13
15
|
VCR.use_cassette "project_add_member" do
|
14
16
|
response = @project.add_member @user_name, @project_name
|
@@ -23,7 +25,7 @@ describe Nephophobia::Project do
|
|
23
25
|
VCR.use_cassette "project_all" do
|
24
26
|
response = @project.all
|
25
27
|
|
26
|
-
response.size.must_equal
|
28
|
+
response.size.must_equal 5
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
@@ -59,14 +61,11 @@ describe Nephophobia::Project do
|
|
59
61
|
|
60
62
|
describe "#find" do
|
61
63
|
before do
|
62
|
-
@project_name = "production"
|
63
|
-
|
64
64
|
VCR.use_cassette "project_find" do
|
65
65
|
@response = @project.find @project_name
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
|
70
69
|
it "returns the given 'project_name'" do
|
71
70
|
@response.name.must_equal @project_name
|
72
71
|
end
|
@@ -74,15 +73,15 @@ describe Nephophobia::Project do
|
|
74
73
|
it "contains the project data" do
|
75
74
|
project = @response
|
76
75
|
|
77
|
-
project.name.must_equal "
|
78
|
-
project.manager_id.must_equal "
|
79
|
-
project.description.must_equal "
|
76
|
+
project.name.must_equal "vcr_project"
|
77
|
+
project.manager_id.must_equal "vcr"
|
78
|
+
project.description.must_equal "vcr_project"
|
80
79
|
end
|
81
80
|
end
|
82
81
|
|
83
82
|
describe "#find with invalid project_name" do
|
84
83
|
it "rescues Hugs::Errors::BadRequest" do
|
85
|
-
VCR.use_cassette "
|
84
|
+
VCR.use_cassette "project_find_with_invalid_project_name" do
|
86
85
|
@response = @project.find "invalid_project_name"
|
87
86
|
end
|
88
87
|
|
@@ -91,23 +90,34 @@ describe Nephophobia::Project do
|
|
91
90
|
end
|
92
91
|
|
93
92
|
describe "#members" do
|
94
|
-
before { @project_name = "production" }
|
95
|
-
|
96
93
|
it "returns all project members for the given 'project_name'" do
|
97
94
|
VCR.use_cassette "project_members" do
|
98
95
|
response = @project.members @project_name
|
99
96
|
|
100
|
-
response.size.must_equal
|
97
|
+
response.size.must_equal 2
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
it "has a 'TypeError: can't convert String into Integer' error" do
|
102
|
+
VCR.use_cassette "project_members_with_string_into_int_error" do
|
103
|
+
response = @project.members @project_name
|
104
|
+
|
105
|
+
response.size.must_equal 1
|
101
106
|
end
|
102
107
|
end
|
103
108
|
end
|
104
109
|
|
105
|
-
describe "#
|
106
|
-
|
107
|
-
|
108
|
-
|
110
|
+
describe "#members with invalid 'project_name'" do
|
111
|
+
it "rescues Hugs::Errors::BadRequest" do
|
112
|
+
VCR.use_cassette "project_members_with_invalid_project_name" do
|
113
|
+
@response = @project.members "invalid_project_name"
|
114
|
+
end
|
115
|
+
|
116
|
+
@response.must_be_nil
|
109
117
|
end
|
118
|
+
end
|
110
119
|
|
120
|
+
describe "#member?" do
|
111
121
|
it "returns true if the given 'user_name' is a member of the specified 'project_name'" do
|
112
122
|
VCR.use_cassette "project_members" do
|
113
123
|
response = @project.member? @user_name, @project_name
|
@@ -118,6 +128,8 @@ describe Nephophobia::Project do
|
|
118
128
|
end
|
119
129
|
|
120
130
|
describe "#remove_member" do
|
131
|
+
before { @project_name = "vcr_secondary_project" }
|
132
|
+
|
121
133
|
it "removes the given 'user_name' from the specified 'project_name'" do
|
122
134
|
VCR.use_cassette "project_remove_member" do
|
123
135
|
response = @project.remove_member @user_name, @project_name
|
@@ -2,13 +2,14 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
describe Nephophobia::Role do
|
4
4
|
before do
|
5
|
-
@role =
|
6
|
-
@user_name = "
|
7
|
-
@project_name = "
|
8
|
-
@role_name = "netadmin"
|
5
|
+
@role = ::Client.with(:admin).role
|
6
|
+
@user_name = "vcr"
|
7
|
+
@project_name = "vcr_project"
|
9
8
|
end
|
10
9
|
|
11
10
|
describe "#create" do
|
11
|
+
before { @role_name = "netadmin" }
|
12
|
+
|
12
13
|
it "adds the default global role to the given 'user_name'" do
|
13
14
|
VCR.use_cassette "role_create" do
|
14
15
|
response = @role.create @user_name
|
@@ -32,10 +33,11 @@ describe Nephophobia::Role do
|
|
32
33
|
response.return.must_equal true
|
33
34
|
end
|
34
35
|
end
|
35
|
-
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "#destroy" do
|
39
|
+
before { @role_name = "netadmin" }
|
40
|
+
|
39
41
|
it "removes the default global role to the given 'user_name'" do
|
40
42
|
VCR.use_cassette "role_destroy" do
|
41
43
|
response = @role.destroy @user_name
|
@@ -2,8 +2,8 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
describe Nephophobia::User do
|
4
4
|
before do
|
5
|
-
@user =
|
6
|
-
@user_name = "
|
5
|
+
@user = ::Client.with(:admin).user
|
6
|
+
@user_name = "vcr"
|
7
7
|
end
|
8
8
|
|
9
9
|
describe "#create" do
|
@@ -17,7 +17,7 @@ describe Nephophobia::User do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#credentials" do
|
20
|
-
before { @project_name = "
|
20
|
+
before { @project_name = "vcr_project" }
|
21
21
|
|
22
22
|
it "returns the credentials for a given 'user_name' for the specified 'project_name'." do
|
23
23
|
VCR.use_cassette "user_credentials" do
|
@@ -40,8 +40,6 @@ describe Nephophobia::User do
|
|
40
40
|
|
41
41
|
describe "#find" do
|
42
42
|
before do
|
43
|
-
@user_name = "jdewey"
|
44
|
-
|
45
43
|
VCR.use_cassette "user_find" do
|
46
44
|
@response = @user.find @user_name
|
47
45
|
end
|
@@ -54,9 +52,9 @@ describe Nephophobia::User do
|
|
54
52
|
it "contains the user data" do
|
55
53
|
user = @response
|
56
54
|
|
57
|
-
user.username.must_equal "
|
58
|
-
user.secretkey.must_equal "
|
59
|
-
user.accesskey.must_equal "
|
55
|
+
user.username.must_equal "vcr"
|
56
|
+
user.secretkey.must_equal "a0d9ff15-2b76-416c-b6fb-03f63c4b8413"
|
57
|
+
user.accesskey.must_equal "285db1a2-4c3b-4f35-a36f-1e5495fa94f2"
|
60
58
|
end
|
61
59
|
end
|
62
60
|
|
data/test/test_helper.rb
CHANGED
@@ -8,20 +8,6 @@ require "nokogiri"
|
|
8
8
|
require "vcr"
|
9
9
|
|
10
10
|
class MiniTest::Unit::TestCase
|
11
|
-
USER_CLIENT = Nephophobia::Client.new(
|
12
|
-
:host => "10.1.170.32",
|
13
|
-
:access_key => "9c01b833-3047-4f2e-bb2a-5c8dc7c8ae9c",
|
14
|
-
:secret_key => "3ae9d9f0-2723-480a-99eb-776f05950506",
|
15
|
-
:project => "production"
|
16
|
-
)
|
17
|
-
|
18
|
-
ADMIN_CLIENT = Nephophobia::Client.new(
|
19
|
-
:host => "10.1.170.32",
|
20
|
-
:access_key => "1d7a687b-0065-44d6-9611-5bf6c6c72424",
|
21
|
-
:secret_key => "fd3053fd-25c2-48f8-b893-9f22661ec63c",
|
22
|
-
:project => "production"
|
23
|
-
)
|
24
|
-
|
25
11
|
def cassette_for cassette
|
26
12
|
c = VCR::Cassette.new(cassette).send :recorded_interactions
|
27
13
|
|
@@ -32,7 +18,23 @@ end
|
|
32
18
|
VCR.config do |c|
|
33
19
|
c.stub_with :fakeweb
|
34
20
|
c.cassette_library_dir = "test/cassettes"
|
35
|
-
c.default_cassette_options = { :record => :
|
21
|
+
c.default_cassette_options = { :record => :new_episodes }
|
22
|
+
end
|
23
|
+
|
24
|
+
class Client
|
25
|
+
def self.with type, options = {}
|
26
|
+
client_options = case type
|
27
|
+
when :user
|
28
|
+
{ :project => "vcr_project" }
|
29
|
+
when :admin ; {
|
30
|
+
:access_key => "1d7a687b-0065-44d6-9611-5bf6c6c72424",
|
31
|
+
:secret_key => "fd3053fd-25c2-48f8-b893-9f22661ec63c",
|
32
|
+
:project => "production"
|
33
|
+
}
|
34
|
+
end.merge(:host => "10.1.170.32")
|
35
|
+
|
36
|
+
Nephophobia::Client.new client_options.merge options
|
37
|
+
end
|
36
38
|
end
|
37
39
|
|
38
40
|
class Time
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: nephophobia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- John Dewey
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-03-
|
14
|
+
date: 2011-03-15 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -128,8 +128,6 @@ files:
|
|
128
128
|
- test/cassettes/compute_destroy.yml
|
129
129
|
- test/cassettes/compute_find.yml
|
130
130
|
- test/cassettes/compute_reboot.yml
|
131
|
-
- test/cassettes/compute_start.yml
|
132
|
-
- test/cassettes/compute_stop.yml
|
133
131
|
- test/cassettes/image_all.yml
|
134
132
|
- test/cassettes/image_all_with_filter.yml
|
135
133
|
- test/cassettes/image_all_with_string_into_int_error.yml
|
@@ -140,8 +138,11 @@ files:
|
|
140
138
|
- test/cassettes/project_create.yml
|
141
139
|
- test/cassettes/project_destroy.yml
|
142
140
|
- test/cassettes/project_find.yml
|
143
|
-
- test/cassettes/
|
141
|
+
- test/cassettes/project_find_with_invalid_project_name.yml
|
144
142
|
- test/cassettes/project_members.yml
|
143
|
+
- test/cassettes/project_members_with_invalid_project_name.yml
|
144
|
+
- test/cassettes/project_members_with_no_members.yml
|
145
|
+
- test/cassettes/project_members_with_string_into_int_error.yml
|
145
146
|
- test/cassettes/project_remove_member.yml
|
146
147
|
- test/cassettes/role_all.yml
|
147
148
|
- test/cassettes/role_all_with_no_roles.yml
|
@@ -203,8 +204,6 @@ test_files:
|
|
203
204
|
- test/cassettes/compute_destroy.yml
|
204
205
|
- test/cassettes/compute_find.yml
|
205
206
|
- test/cassettes/compute_reboot.yml
|
206
|
-
- test/cassettes/compute_start.yml
|
207
|
-
- test/cassettes/compute_stop.yml
|
208
207
|
- test/cassettes/image_all.yml
|
209
208
|
- test/cassettes/image_all_with_filter.yml
|
210
209
|
- test/cassettes/image_all_with_string_into_int_error.yml
|
@@ -215,8 +214,11 @@ test_files:
|
|
215
214
|
- test/cassettes/project_create.yml
|
216
215
|
- test/cassettes/project_destroy.yml
|
217
216
|
- test/cassettes/project_find.yml
|
218
|
-
- test/cassettes/
|
217
|
+
- test/cassettes/project_find_with_invalid_project_name.yml
|
219
218
|
- test/cassettes/project_members.yml
|
219
|
+
- test/cassettes/project_members_with_invalid_project_name.yml
|
220
|
+
- test/cassettes/project_members_with_no_members.yml
|
221
|
+
- test/cassettes/project_members_with_string_into_int_error.yml
|
220
222
|
- test/cassettes/project_remove_member.yml
|
221
223
|
- test/cassettes/role_all.yml
|
222
224
|
- test/cassettes/role_all_with_no_roles.yml
|
@@ -1,30 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::HTTPInteraction
|
3
|
-
request: !ruby/struct:VCR::Request
|
4
|
-
method: :get
|
5
|
-
uri: http://10.1.170.32:8773/services/Cloud?AWSAccessKeyId=9c01b833-3047-4f2e-bb2a-5c8dc7c8ae9c%3Aproduction&Action=StopInstances&InstanceId.1=i-00000471&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=1999-12-31T19%3A59%3A59Z&Version=2010-11-15&Signature=f2ca4u3DErKzJVpi7zl49x4ePTYvUpLt1gSssEuGB%2B8%3D
|
6
|
-
body:
|
7
|
-
headers:
|
8
|
-
accept:
|
9
|
-
- application/xml
|
10
|
-
connection:
|
11
|
-
- keep-alive
|
12
|
-
keep-alive:
|
13
|
-
- 30
|
14
|
-
response: !ruby/struct:VCR::Response
|
15
|
-
status: !ruby/struct:VCR::ResponseStatus
|
16
|
-
code: 400
|
17
|
-
message: Bad Request
|
18
|
-
headers:
|
19
|
-
content-type:
|
20
|
-
- text/xml
|
21
|
-
content-length:
|
22
|
-
- "223"
|
23
|
-
date:
|
24
|
-
- Sun, 27 Feb 2011 05:55:56 GMT
|
25
|
-
connection:
|
26
|
-
- keep-alive
|
27
|
-
body: |-
|
28
|
-
<?xml version="1.0"?>
|
29
|
-
<Response><Errors><Error><Code>UnknownError</Code><Message>An unknown error has occurred. Please try your request again.</Message></Error></Errors><RequestID>J5RD33FVSRL2YKUWPU7Z</RequestID></Response>
|
30
|
-
http_version: "1.1"
|
@@ -1,30 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::HTTPInteraction
|
3
|
-
request: !ruby/struct:VCR::Request
|
4
|
-
method: :get
|
5
|
-
uri: http://10.1.170.32:8773/services/Cloud?AWSAccessKeyId=9c01b833-3047-4f2e-bb2a-5c8dc7c8ae9c%3Aproduction&Action=StartInstances&InstanceId.1=i-00000471&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=1999-12-31T19%3A59%3A59Z&Version=2010-11-15&Signature=aoyZPkC2nBT%2BFLRlVxn5m%2F66N3TMFQg%2FU3n6UtKq%2BMY%3D
|
6
|
-
body:
|
7
|
-
headers:
|
8
|
-
accept:
|
9
|
-
- application/xml
|
10
|
-
connection:
|
11
|
-
- keep-alive
|
12
|
-
keep-alive:
|
13
|
-
- 30
|
14
|
-
response: !ruby/struct:VCR::Response
|
15
|
-
status: !ruby/struct:VCR::ResponseStatus
|
16
|
-
code: 400
|
17
|
-
message: Bad Request
|
18
|
-
headers:
|
19
|
-
content-type:
|
20
|
-
- text/xml
|
21
|
-
content-length:
|
22
|
-
- "223"
|
23
|
-
date:
|
24
|
-
- Sun, 27 Feb 2011 05:55:56 GMT
|
25
|
-
connection:
|
26
|
-
- keep-alive
|
27
|
-
body: |-
|
28
|
-
<?xml version="1.0"?>
|
29
|
-
<Response><Errors><Error><Code>UnknownError</Code><Message>An unknown error has occurred. Please try your request again.</Message></Error></Errors><RequestID>SCZZWFV5UOSSRFBOGAG4</RequestID></Response>
|
30
|
-
http_version: "1.1"
|