nephophobia 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +29 -0
- data/.gitignore +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +35 -0
- data/README.md +23 -0
- data/Rakefile +11 -0
- data/lib/aws.rb +51 -0
- data/lib/hashify.rb +29 -0
- data/lib/nephophobia.rb +30 -0
- data/lib/nephophobia/client.rb +73 -0
- data/lib/nephophobia/compute.rb +150 -0
- data/lib/nephophobia/image.rb +78 -0
- data/lib/nephophobia/project.rb +113 -0
- data/lib/nephophobia/role.rb +5 -0
- data/lib/nephophobia/user.rb +86 -0
- data/lib/nephophobia/version.rb +3 -0
- data/nephophobia.gemspec +30 -0
- data/test/fixtures/cassettes/compute_all.yml +28 -0
- data/test/fixtures/cassettes/compute_all_with_filter.yml +30 -0
- data/test/fixtures/cassettes/compute_all_with_string_into_int_error.yml +28 -0
- data/test/fixtures/cassettes/compute_create.yml +28 -0
- data/test/fixtures/cassettes/compute_create_with_optional_params.yml +28 -0
- data/test/fixtures/cassettes/compute_destroy.yml +28 -0
- data/test/fixtures/cassettes/compute_find.yml +28 -0
- data/test/fixtures/cassettes/compute_reboot.yml +28 -0
- data/test/fixtures/cassettes/compute_start.yml +30 -0
- data/test/fixtures/cassettes/compute_stop.yml +30 -0
- data/test/fixtures/cassettes/image_all.yml +28 -0
- data/test/fixtures/cassettes/image_all_with_filter.yml +28 -0
- data/test/fixtures/cassettes/image_all_with_string_into_int_error.yml +28 -0
- data/test/fixtures/cassettes/image_find.yml +28 -0
- data/test/fixtures/cassettes/project_add_member.yml +28 -0
- data/test/fixtures/cassettes/project_all.yml +28 -0
- data/test/fixtures/cassettes/project_all_with_string_into_int_error.yml +28 -0
- data/test/fixtures/cassettes/project_create.yml +28 -0
- data/test/fixtures/cassettes/project_destroy.yml +28 -0
- data/test/fixtures/cassettes/project_find.yml +28 -0
- data/test/fixtures/cassettes/project_members.yml +28 -0
- data/test/fixtures/cassettes/project_remove_member.yml +28 -0
- data/test/fixtures/cassettes/user_add_role.yml +28 -0
- data/test/fixtures/cassettes/user_create.yml +28 -0
- data/test/fixtures/cassettes/user_destroy.yml +28 -0
- data/test/fixtures/cassettes/user_find.yml +28 -0
- data/test/fixtures/cassettes/user_remove_role.yml +28 -0
- data/test/lib/aws_test.rb +22 -0
- data/test/lib/hashify_test.rb +15 -0
- data/test/lib/nephophobia/compute_test.rb +144 -0
- data/test/lib/nephophobia/image_test.rb +76 -0
- data/test/lib/nephophobia/project_test.rb +104 -0
- data/test/lib/nephophobia/user_test.rb +71 -0
- data/test/lib/nephophobia_test.rb +17 -0
- data/test/test_helper.rb +47 -0
- metadata +221 -0
@@ -0,0 +1,104 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Nephophobia::Project do
|
4
|
+
before do
|
5
|
+
@project = Nephophobia::Project.new ADMIN_CLIENT
|
6
|
+
@user = Nephophobia::User.new ADMIN_CLIENT
|
7
|
+
@user_name = "foobar_user"
|
8
|
+
@project_name = "foobar_project"
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#add_member" do
|
12
|
+
it "adds the given 'user_name' to the specified 'project_name'" do
|
13
|
+
VCR.use_cassette "project_add_member" do
|
14
|
+
response = @project.add_member @user_name, @project_name
|
15
|
+
|
16
|
+
response.return.must_equal true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#all" do
|
22
|
+
it "returns all projects" do
|
23
|
+
VCR.use_cassette "project_all" do
|
24
|
+
response = @project.all
|
25
|
+
|
26
|
+
response.size.must_equal 4
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has a 'TypeError: can't convert String into Integer' error" do
|
31
|
+
VCR.use_cassette "project_all_with_string_into_int_error" do
|
32
|
+
response = @project.all
|
33
|
+
|
34
|
+
response.size.must_equal 1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#create" do
|
40
|
+
it "creates the given 'project_name'" do
|
41
|
+
VCR.use_cassette "project_create" do
|
42
|
+
response = @project.create @project_name, @user_name
|
43
|
+
|
44
|
+
response.name.must_equal @project_name
|
45
|
+
response.manager_id.must_equal @user_name
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#destroy" do
|
51
|
+
it "destroys the given 'project_name'" do
|
52
|
+
VCR.use_cassette "project_destroy" do
|
53
|
+
response = @project.destroy @project_name
|
54
|
+
|
55
|
+
response.return.must_equal true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#find" do
|
61
|
+
before do
|
62
|
+
@project_name = "production"
|
63
|
+
|
64
|
+
VCR.use_cassette "project_find" do
|
65
|
+
@response = @project.find @project_name
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
it "returns the given 'project_name'" do
|
71
|
+
@response.name.must_equal @project_name
|
72
|
+
end
|
73
|
+
|
74
|
+
it "contains the project data" do
|
75
|
+
project = @response
|
76
|
+
|
77
|
+
project.name.must_equal "production"
|
78
|
+
project.manager_id.must_equal "root"
|
79
|
+
project.description.must_equal "production"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#members" do
|
84
|
+
before { @project_name = "production" }
|
85
|
+
|
86
|
+
it "returns all project members for the given 'project_name'" do
|
87
|
+
VCR.use_cassette "project_members" do
|
88
|
+
response = @project.members @project_name
|
89
|
+
|
90
|
+
response.size.must_equal 11
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#remove_member" do
|
96
|
+
it "removes the given 'user_name' from the specified 'project_name'" do
|
97
|
+
VCR.use_cassette "project_remove_member" do
|
98
|
+
response = @project.remove_member @user_name, @project_name
|
99
|
+
|
100
|
+
response.return.must_equal true
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Nephophobia::User do
|
4
|
+
before do
|
5
|
+
@user = Nephophobia::User.new ADMIN_CLIENT
|
6
|
+
@user_name = "foobar_user"
|
7
|
+
@project_name = "foobar_project"
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#add_role" do
|
11
|
+
it "adds the default role to the given 'user_name'" do
|
12
|
+
VCR.use_cassette "user_add_role" do
|
13
|
+
response = @user.add_role @user_name, @project_name
|
14
|
+
|
15
|
+
response.return.must_equal true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#create" do
|
21
|
+
it "creates the given 'user_name'" do
|
22
|
+
VCR.use_cassette "user_create" do
|
23
|
+
response = @user.create @user_name
|
24
|
+
|
25
|
+
response.username.must_equal @user_name
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#destroy" do
|
31
|
+
it "destroys the given 'user_name'" do
|
32
|
+
VCR.use_cassette "user_destroy" do
|
33
|
+
response = @user.destroy @user_name
|
34
|
+
|
35
|
+
response.return.must_equal true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#find" do
|
41
|
+
before do
|
42
|
+
@user_name = "jdewey"
|
43
|
+
|
44
|
+
VCR.use_cassette "user_find" do
|
45
|
+
@response = @user.find @user_name
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns the given 'user_name'" do
|
50
|
+
@response.username.must_equal @user_name
|
51
|
+
end
|
52
|
+
|
53
|
+
it "contains the user data" do
|
54
|
+
user = @response
|
55
|
+
|
56
|
+
user.username.must_equal "jdewey"
|
57
|
+
user.secretkey.must_equal "3ae9d9f0-2723-480a-99eb-776f05950506"
|
58
|
+
user.accesskey.must_equal "9c01b833-3047-4f2e-bb2a-5c8dc7c8ae9c"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#remove_role" do
|
63
|
+
it "removes the default role to the given 'user_name'" do
|
64
|
+
VCR.use_cassette "user_remove_role" do
|
65
|
+
response = @user.remove_role @user_name, @project_name
|
66
|
+
|
67
|
+
response.return.must_equal true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Nephophobia do
|
4
|
+
describe "::coerce" do
|
5
|
+
it "wraps a Hash with an Array" do
|
6
|
+
hash = { :foo => :bar }
|
7
|
+
|
8
|
+
Nephophobia.coerce(hash).must_equal [hash]
|
9
|
+
end
|
10
|
+
|
11
|
+
it "doesn't wrap others" do
|
12
|
+
array = [:foo, :bar]
|
13
|
+
|
14
|
+
Nephophobia.coerce(array).must_equal array
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
Bundler.setup :default, :test
|
2
|
+
|
3
|
+
require "nephophobia"
|
4
|
+
|
5
|
+
require "fakeweb"
|
6
|
+
require "minitest/spec"
|
7
|
+
require "nokogiri"
|
8
|
+
require "vcr"
|
9
|
+
|
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
|
+
:path => "/services/Admin/"
|
24
|
+
)
|
25
|
+
|
26
|
+
def cassette_for cassette
|
27
|
+
c = VCR::Cassette.new(cassette).send :recorded_interactions
|
28
|
+
|
29
|
+
Nokogiri::XML::Document.parse c.first.response.body
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
VCR.config do |c|
|
34
|
+
c.stub_with :fakeweb
|
35
|
+
c.cassette_library_dir = "test/fixtures/cassettes"
|
36
|
+
c.default_cassette_options = { :record => :none }
|
37
|
+
end
|
38
|
+
|
39
|
+
class Time
|
40
|
+
class << self
|
41
|
+
alias_method :real_now, :now
|
42
|
+
def now
|
43
|
+
Time.utc 1999, 12, 31, 19, 59, 59
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
MiniTest::Unit.autorun
|
metadata
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nephophobia
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- John Dewey
|
9
|
+
- Josh Kleinpeter
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2011-03-04 00:00:00 -08:00
|
15
|
+
default_executable:
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: hugs
|
19
|
+
prerelease: false
|
20
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ~>
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 2.5.0
|
26
|
+
type: :runtime
|
27
|
+
version_requirements: *id001
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: autotest-standalone
|
30
|
+
prerelease: false
|
31
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: "0"
|
37
|
+
type: :development
|
38
|
+
version_requirements: *id002
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: fakeweb
|
41
|
+
prerelease: false
|
42
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.0
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id003
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: minitest
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 2.0.2
|
59
|
+
type: :development
|
60
|
+
version_requirements: *id004
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: nokogiri
|
63
|
+
prerelease: false
|
64
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.4.4
|
70
|
+
type: :development
|
71
|
+
version_requirements: *id005
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: rake
|
74
|
+
prerelease: false
|
75
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ~>
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 0.8.7
|
81
|
+
type: :development
|
82
|
+
version_requirements: *id006
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
prerelease: false
|
86
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - "="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 1.5.0
|
92
|
+
type: :development
|
93
|
+
version_requirements: *id007
|
94
|
+
description: This gem is a simple binding to the EC2 API. It has specific extensions to allow extra functionality provided by OpenStack.
|
95
|
+
email:
|
96
|
+
- jdewey@attinteractive.com
|
97
|
+
- jkleinpeter@attinteractive.com
|
98
|
+
executables: []
|
99
|
+
|
100
|
+
extensions: []
|
101
|
+
|
102
|
+
extra_rdoc_files: []
|
103
|
+
|
104
|
+
files:
|
105
|
+
- .autotest
|
106
|
+
- .gitignore
|
107
|
+
- .rvmrc
|
108
|
+
- Gemfile
|
109
|
+
- Gemfile.lock
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- lib/aws.rb
|
113
|
+
- lib/hashify.rb
|
114
|
+
- lib/nephophobia.rb
|
115
|
+
- lib/nephophobia/client.rb
|
116
|
+
- lib/nephophobia/compute.rb
|
117
|
+
- lib/nephophobia/image.rb
|
118
|
+
- lib/nephophobia/project.rb
|
119
|
+
- lib/nephophobia/role.rb
|
120
|
+
- lib/nephophobia/user.rb
|
121
|
+
- lib/nephophobia/version.rb
|
122
|
+
- nephophobia.gemspec
|
123
|
+
- test/fixtures/cassettes/compute_all.yml
|
124
|
+
- test/fixtures/cassettes/compute_all_with_filter.yml
|
125
|
+
- test/fixtures/cassettes/compute_all_with_string_into_int_error.yml
|
126
|
+
- test/fixtures/cassettes/compute_create.yml
|
127
|
+
- test/fixtures/cassettes/compute_create_with_optional_params.yml
|
128
|
+
- test/fixtures/cassettes/compute_destroy.yml
|
129
|
+
- test/fixtures/cassettes/compute_find.yml
|
130
|
+
- test/fixtures/cassettes/compute_reboot.yml
|
131
|
+
- test/fixtures/cassettes/compute_start.yml
|
132
|
+
- test/fixtures/cassettes/compute_stop.yml
|
133
|
+
- test/fixtures/cassettes/image_all.yml
|
134
|
+
- test/fixtures/cassettes/image_all_with_filter.yml
|
135
|
+
- test/fixtures/cassettes/image_all_with_string_into_int_error.yml
|
136
|
+
- test/fixtures/cassettes/image_find.yml
|
137
|
+
- test/fixtures/cassettes/project_add_member.yml
|
138
|
+
- test/fixtures/cassettes/project_all.yml
|
139
|
+
- test/fixtures/cassettes/project_all_with_string_into_int_error.yml
|
140
|
+
- test/fixtures/cassettes/project_create.yml
|
141
|
+
- test/fixtures/cassettes/project_destroy.yml
|
142
|
+
- test/fixtures/cassettes/project_find.yml
|
143
|
+
- test/fixtures/cassettes/project_members.yml
|
144
|
+
- test/fixtures/cassettes/project_remove_member.yml
|
145
|
+
- test/fixtures/cassettes/user_add_role.yml
|
146
|
+
- test/fixtures/cassettes/user_create.yml
|
147
|
+
- test/fixtures/cassettes/user_destroy.yml
|
148
|
+
- test/fixtures/cassettes/user_find.yml
|
149
|
+
- test/fixtures/cassettes/user_remove_role.yml
|
150
|
+
- test/lib/aws_test.rb
|
151
|
+
- test/lib/hashify_test.rb
|
152
|
+
- test/lib/nephophobia/compute_test.rb
|
153
|
+
- test/lib/nephophobia/image_test.rb
|
154
|
+
- test/lib/nephophobia/project_test.rb
|
155
|
+
- test/lib/nephophobia/user_test.rb
|
156
|
+
- test/lib/nephophobia_test.rb
|
157
|
+
- test/test_helper.rb
|
158
|
+
has_rdoc: true
|
159
|
+
homepage: ""
|
160
|
+
licenses: []
|
161
|
+
|
162
|
+
post_install_message:
|
163
|
+
rdoc_options: []
|
164
|
+
|
165
|
+
require_paths:
|
166
|
+
- lib
|
167
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: "0"
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
|
+
none: false
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: "0"
|
179
|
+
requirements: []
|
180
|
+
|
181
|
+
rubyforge_project: nephophobia
|
182
|
+
rubygems_version: 1.5.0
|
183
|
+
signing_key:
|
184
|
+
specification_version: 3
|
185
|
+
summary: Bindings to EC2/OpenStack
|
186
|
+
test_files:
|
187
|
+
- test/fixtures/cassettes/compute_all.yml
|
188
|
+
- test/fixtures/cassettes/compute_all_with_filter.yml
|
189
|
+
- test/fixtures/cassettes/compute_all_with_string_into_int_error.yml
|
190
|
+
- test/fixtures/cassettes/compute_create.yml
|
191
|
+
- test/fixtures/cassettes/compute_create_with_optional_params.yml
|
192
|
+
- test/fixtures/cassettes/compute_destroy.yml
|
193
|
+
- test/fixtures/cassettes/compute_find.yml
|
194
|
+
- test/fixtures/cassettes/compute_reboot.yml
|
195
|
+
- test/fixtures/cassettes/compute_start.yml
|
196
|
+
- test/fixtures/cassettes/compute_stop.yml
|
197
|
+
- test/fixtures/cassettes/image_all.yml
|
198
|
+
- test/fixtures/cassettes/image_all_with_filter.yml
|
199
|
+
- test/fixtures/cassettes/image_all_with_string_into_int_error.yml
|
200
|
+
- test/fixtures/cassettes/image_find.yml
|
201
|
+
- test/fixtures/cassettes/project_add_member.yml
|
202
|
+
- test/fixtures/cassettes/project_all.yml
|
203
|
+
- test/fixtures/cassettes/project_all_with_string_into_int_error.yml
|
204
|
+
- test/fixtures/cassettes/project_create.yml
|
205
|
+
- test/fixtures/cassettes/project_destroy.yml
|
206
|
+
- test/fixtures/cassettes/project_find.yml
|
207
|
+
- test/fixtures/cassettes/project_members.yml
|
208
|
+
- test/fixtures/cassettes/project_remove_member.yml
|
209
|
+
- test/fixtures/cassettes/user_add_role.yml
|
210
|
+
- test/fixtures/cassettes/user_create.yml
|
211
|
+
- test/fixtures/cassettes/user_destroy.yml
|
212
|
+
- test/fixtures/cassettes/user_find.yml
|
213
|
+
- test/fixtures/cassettes/user_remove_role.yml
|
214
|
+
- test/lib/aws_test.rb
|
215
|
+
- test/lib/hashify_test.rb
|
216
|
+
- test/lib/nephophobia/compute_test.rb
|
217
|
+
- test/lib/nephophobia/image_test.rb
|
218
|
+
- test/lib/nephophobia/project_test.rb
|
219
|
+
- test/lib/nephophobia/user_test.rb
|
220
|
+
- test/lib/nephophobia_test.rb
|
221
|
+
- test/test_helper.rb
|