ruby-atmos 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -0,0 +1 @@
1
+ binary isn't happy, is it?
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/atmos'
4
+
5
+
6
+ class AtmosUtilTest < Test::Unit::TestCase
7
+
8
+ def dont_test_signature_calculation
9
+ headers = {}
10
+
11
+ verb = 'post'
12
+ uid = '6039ac182f194e15b9261d73ce044939/user1'
13
+ url = "https://mgmt.atmosonline.com/rest/objects"
14
+ secret = 'LJLuryj6zs8ste6Y3jTGQp71xq0='
15
+
16
+ headers['Date'] = 'Thu, 05 Jun 2008 16:38:19 GMT'
17
+ headers['Content-Type'] = 'application/octet-stream'
18
+ headers['x-emc-date'] = 'Thu, 05 Jun 2008 16:38:19 GMT'
19
+ headers['x-emc-groupacl'] = 'other=NONE'
20
+ headers['x-emc-listable-meta'] = 'part4/part7/part8=quick'
21
+ headers['x-emc-meta'] = 'part1=buy'
22
+ headers['x-emc-uid'] = uid
23
+ headers['x-emc-useracl'] = 'john=FULL_CONTROL,mary=WRITE'
24
+
25
+ assert_equal('WHJo1MFevMnK4jCthJ974L3YHoo=', Atmos::Request::calculate_signature(verb, secret, url, headers))
26
+ end
27
+
28
+
29
+ def test_something_or_other
30
+
31
+
32
+ store = Atmos::Store.new(:url => 'https://10.5.113.71',
33
+ :uid =>'69eb3dc3bf9746f895d1ce12ae1d9589/dragaf-test',
34
+ :secret => 'p97mki4AkiAyVi+/7QpdxFAU/jY=',
35
+ :unsupported => true
36
+ )
37
+
38
+ end
39
+
40
+
41
+ def test_http_bad_signature
42
+ store = Atmos::Store.new(:url => 'http://10.5.113.71',
43
+ :uid => '69eb3dc3bf9746f895d1ce12ae1d9589/dragaf-test',
44
+ :secret => 'p97mki4AkiAyVi+/7QpdxFAU/jY=',
45
+ :unsupported => true
46
+ )
47
+ print "#{store.server_version}\n"
48
+
49
+ end
50
+ end
data/test/suite.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'test/unit'
2
+
3
+ require File.dirname(__FILE__) + '/test_util'
4
+ require File.dirname(__FILE__) + '/test_acl'
5
+ require File.dirname(__FILE__) + '/test_metadata'
6
+ require File.dirname(__FILE__) + '/test_object_create'
7
+ require File.dirname(__FILE__) + '/test_object_update'
8
+ require File.dirname(__FILE__) + '/test_object_misc'
9
+ require File.dirname(__FILE__) + '/test_store'
@@ -0,0 +1,12 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/credentials'
3
+
4
+ Atmos::Test::Util.use_proxy = false
5
+ puts "testing against: #{Atmos::Test::Util.server}"
6
+
7
+ require File.dirname(__FILE__) + '/test_util'
8
+ require File.dirname(__FILE__) + '/test_acl'
9
+ require File.dirname(__FILE__) + '/test_metadata'
10
+ require File.dirname(__FILE__) + '/test_object_create'
11
+ require File.dirname(__FILE__) + '/test_object_misc'
12
+ require File.dirname(__FILE__) + '/test_store'
@@ -0,0 +1,14 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/credentials'
3
+
4
+ Atmos::Test::Util.use_proxy = true
5
+ puts "testing against: #{Atmos::Test::Util.server}"
6
+
7
+ require File.dirname(__FILE__) + '/test_util'
8
+ require File.dirname(__FILE__) + '/test_acl'
9
+ require File.dirname(__FILE__) + '/test_metadata'
10
+ require File.dirname(__FILE__) + '/test_object_create'
11
+ require File.dirname(__FILE__) + '/test_object_misc'
12
+ require File.dirname(__FILE__) + '/test_store'
13
+
14
+
data/test/test_acl.rb ADDED
@@ -0,0 +1,283 @@
1
+ require 'credentials'
2
+ require 'test/unit'
3
+ require 'atmos'
4
+
5
+
6
+ class AtmosACLCreateTest < Test::Unit::TestCase
7
+ @cleanup = []
8
+
9
+
10
+ def initialize(id)
11
+ super(id)
12
+ @cleanup = []
13
+ end
14
+
15
+ def setup
16
+ @s = Atmos::Test::Util.static_store
17
+ @obj = @s.create()
18
+ @cleanup.push(@obj)
19
+ end
20
+
21
+ def teardown
22
+ @cleanup.each do |obj|
23
+ obj.delete
24
+ end
25
+ end
26
+
27
+ def test_create_acl_nil_obj
28
+ assert_raise Atmos::Exceptions::ArgumentException do
29
+ Atmos::ACL.new(nil, Atmos::ACL::USER)
30
+ end
31
+ end
32
+
33
+ def test_create_acl_nil_type
34
+ assert_raise Atmos::Exceptions::ArgumentException do
35
+ Atmos::ACL.new(@obj, nil)
36
+ end
37
+ end
38
+
39
+ def test_create_acl_bad_type
40
+ assert_raise Atmos::Exceptions::ArgumentException do
41
+ Atmos::ACL.new(@obj, 42)
42
+ end
43
+ end
44
+
45
+ def test_create_acl_invalid_options
46
+ assert_raise Atmos::Exceptions::ArgumentException do
47
+ Atmos::ACL.new(@obj, 'group')
48
+ end
49
+
50
+ assert_raise Atmos::Exceptions::ArgumentException do
51
+ Atmos::ACL.new(@obj, 'user')
52
+ end
53
+ end
54
+
55
+ def test_create_acl_valid_options
56
+ acl = Atmos::ACL.new(@obj, Atmos::ACL::GROUP)
57
+ assert_equal('x-emc-groupacl', acl.header_name)
58
+ assert(!acl.user?)
59
+ assert(acl.group?)
60
+
61
+ acl = Atmos::ACL.new(@obj, Atmos::ACL::USER)
62
+ assert_equal('x-emc-useracl', acl.header_name)
63
+ assert(acl.user?)
64
+ assert(!acl.group?)
65
+ end
66
+
67
+ end
68
+
69
+
70
+ class AtmosACLUpdateTest < Test::Unit::TestCase
71
+ @cleanup = []
72
+
73
+ def initialize(id)
74
+ super(id)
75
+ @cleanup = []
76
+ end
77
+
78
+ def setup
79
+ @s = Atmos::Store.new(:url => Atmos::Test::Util.url,
80
+ :uid => "#{Atmos::Test::Util.tenant}/#{Atmos::Test::Util.user}",
81
+ :secret => Atmos::Test::Util.secret)
82
+ @obj = @s.create()
83
+ @cleanup.push(@obj)
84
+ end
85
+
86
+ def teardown
87
+ @cleanup.each do |obj|
88
+ obj.delete
89
+ end
90
+ $stdout.flush
91
+ end
92
+
93
+ def test_add_user_acl_with_bad_value_symbol
94
+ assert_raise Atmos::Exceptions::ArgumentException do
95
+ @obj.user_acl[Atmos::Test::Util.other_user] = :whatever
96
+ end
97
+ end
98
+
99
+ def test_add_user_acl_with_bad_value_string
100
+ assert_raise Atmos::Exceptions::ArgumentException do
101
+ @obj.user_acl[Atmos::Test::Util.other_user] = 'read'
102
+ end
103
+ end
104
+
105
+ def test_add_group_acl_with_bad_value_symbol
106
+ assert_raise Atmos::Exceptions::ArgumentException do
107
+ @obj.user_acl[Atmos::Test::Util.other_group] = :whatever
108
+ end
109
+ end
110
+
111
+ def test_add_group_acl_with_bad_value_string
112
+ assert_raise Atmos::Exceptions::ArgumentException do
113
+ @obj.user_acl[Atmos::Test::Util.other_group] = 'write'
114
+ end
115
+ end
116
+
117
+ def test_add_user_acl_with_bad_user
118
+ end
119
+
120
+ def test_add_group_acl_with_bad_group
121
+ end
122
+
123
+ def test_add_user_acl_good_values
124
+ @obj.user_acl[Atmos::Test::Util.other_user] = :read
125
+ assert_equal({Atmos::Test::Util.user => :full, Atmos::Test::Util.other_user => :read}, @obj.user_acl)
126
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.user))
127
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.other_user))
128
+ assert_equal(:full, @obj.user_acl[Atmos::Test::Util.user])
129
+ assert_equal(:read, @obj.user_acl[Atmos::Test::Util.other_user])
130
+ end
131
+
132
+ def test_add_group_acl_good_values
133
+ end
134
+
135
+ def test_change_default_user_permissions
136
+ end
137
+
138
+ def test_change_default_group_permissions
139
+ assert_equal({Atmos::Test::Util.group => :none}, @obj.group_acl)
140
+ @obj.group_acl[Atmos::Test::Util.group] = :read
141
+ assert_equal({Atmos::Test::Util.group => :read}, @obj.group_acl)
142
+ assert(@obj.group_acl.has_key?(Atmos::Test::Util.group))
143
+ assert_equal(:read, @obj.group_acl[Atmos::Test::Util.group])
144
+ end
145
+
146
+ def test_change_secondary_user_permissions
147
+ @obj.user_acl[Atmos::Test::Util.other_user] = :read
148
+ assert_equal({Atmos::Test::Util.user => :full, Atmos::Test::Util.other_user => :read}, @obj.user_acl)
149
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.user))
150
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.other_user))
151
+ assert_equal(:full, @obj.user_acl[Atmos::Test::Util.user])
152
+ assert_equal(:read, @obj.user_acl[Atmos::Test::Util.other_user])
153
+
154
+ @obj.user_acl[Atmos::Test::Util.other_user] = :none
155
+ assert_equal({Atmos::Test::Util.user => :full}, @obj.user_acl)
156
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.user))
157
+ assert(!@obj.user_acl.has_key?(Atmos::Test::Util.other_user))
158
+ assert_equal(:full, @obj.user_acl[Atmos::Test::Util.user])
159
+
160
+ @obj.user_acl[Atmos::Test::Util.other_user] = :full
161
+ assert_equal({Atmos::Test::Util.user => :full, Atmos::Test::Util.other_user => :full}, @obj.user_acl)
162
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.user))
163
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.other_user))
164
+ assert_equal(:full, @obj.user_acl[Atmos::Test::Util.user])
165
+ assert_equal(:full, @obj.user_acl[Atmos::Test::Util.other_user])
166
+ end
167
+
168
+ def test_change_secondary_group_permissions
169
+ end
170
+
171
+ def test_delete_user_via_no_permissions
172
+ @obj.user_acl[Atmos::Test::Util.other_user] = :read
173
+ assert_equal({Atmos::Test::Util.user => :full, Atmos::Test::Util.other_user => :read}, @obj.user_acl)
174
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.user))
175
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.other_user))
176
+ assert_equal(:full, @obj.user_acl[Atmos::Test::Util.user])
177
+ assert_equal(:read, @obj.user_acl[Atmos::Test::Util.other_user])
178
+
179
+ @obj.user_acl[Atmos::Test::Util.other_user] = :none
180
+ assert_equal({Atmos::Test::Util.user => :full}, @obj.user_acl)
181
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.user))
182
+ assert(!@obj.user_acl.has_key?(Atmos::Test::Util.other_user))
183
+ assert_equal(:full, @obj.user_acl[Atmos::Test::Util.user])
184
+ end
185
+
186
+ def test_delete_group_via_no_permissions
187
+ end
188
+
189
+ def test_delete_user_via_delete
190
+ @obj.user_acl[Atmos::Test::Util.other_user] = :read
191
+ assert_equal({Atmos::Test::Util.user => :full, Atmos::Test::Util.other_user => :read}, @obj.user_acl)
192
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.user))
193
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.other_user))
194
+ assert_equal(:full, @obj.user_acl[Atmos::Test::Util.user])
195
+ assert_equal(:read, @obj.user_acl[Atmos::Test::Util.other_user])
196
+
197
+ @obj.user_acl.delete(Atmos::Test::Util.other_user)
198
+ assert_equal({Atmos::Test::Util.user => :full}, @obj.user_acl)
199
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.user))
200
+ assert(!@obj.user_acl.has_key?(Atmos::Test::Util.other_user))
201
+ assert_equal(:full, @obj.user_acl[Atmos::Test::Util.user])
202
+ end
203
+
204
+ def test_delete_group_via_delete
205
+ end
206
+
207
+ def test_clear_users
208
+ @obj.user_acl[Atmos::Test::Util.other_user] = :read
209
+ assert_equal({Atmos::Test::Util.user => :full, Atmos::Test::Util.other_user => :read}, @obj.user_acl)
210
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.user))
211
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.other_user))
212
+ assert_equal(:full, @obj.user_acl[Atmos::Test::Util.user])
213
+ assert_equal(:read, @obj.user_acl[Atmos::Test::Util.other_user])
214
+
215
+ @obj.user_acl.clear
216
+ assert_equal({Atmos::Test::Util.user => :full}, @obj.user_acl)
217
+ assert(@obj.user_acl.has_key?(Atmos::Test::Util.user))
218
+ assert(!@obj.user_acl.has_key?(Atmos::Test::Util.other_user))
219
+ assert_equal(:full, @obj.user_acl[Atmos::Test::Util.user])
220
+ end
221
+
222
+ def test_clear_groups
223
+ end
224
+
225
+ def test_bad_merge_users
226
+ assert_raise Atmos::Exceptions::ArgumentException do
227
+ @obj.user_acl.merge({Atmos::Test::Util.other_user => 'foo'})
228
+ end
229
+ end
230
+
231
+ def test_merge_users
232
+ assert_equal({Atmos::Test::Util.user => :full}, @obj.user_acl)
233
+
234
+ rv = @obj.user_acl.merge({Atmos::Test::Util.other_user => :read})
235
+ assert_equal({Atmos::Test::Util.user => :full, Atmos::Test::Util.other_user => :read}, rv)
236
+ assert_equal({Atmos::Test::Util.user => :full}, @obj.user_acl)
237
+ end
238
+
239
+ def test_merge_groups
240
+ end
241
+
242
+ def test_bad_merge_bang_users
243
+ assert_raise Atmos::Exceptions::ArgumentException do
244
+ @obj.user_acl.merge!({Atmos::Test::Util.other_user => 'foo'})
245
+ end
246
+ end
247
+
248
+ def test_merge_bang_users
249
+ @obj.user_acl.merge!({Atmos::Test::Util.other_user => :read})
250
+ assert_equal({Atmos::Test::Util.user => :full, Atmos::Test::Util.other_user => :read}, @obj.user_acl)
251
+ end
252
+
253
+ def test_bad_merge_bang_groups
254
+ end
255
+
256
+ def test_merge_bang_groups
257
+ end
258
+
259
+ def test_bad_replace_users
260
+ assert_raise Atmos::Exceptions::ArgumentException do
261
+ @obj.user_acl.replace({Atmos::Test::Util.other_user => 'foo'})
262
+ end
263
+ end
264
+
265
+ def test_replace_users
266
+ assert_equal({Atmos::Test::Util.user => :full}, @obj.user_acl)
267
+
268
+ @obj.user_acl.replace({Atmos::Test::Util.other_user => :read})
269
+ assert_equal({Atmos::Test::Util.other_user => :read}, @obj.user_acl)
270
+ end
271
+
272
+ def test_replace_groups
273
+ end
274
+
275
+
276
+
277
+ # def test_give_away_access
278
+ # @obj.user_acl[Atmos::Test::Util.user] = :read
279
+ # assert_equal({Atmos::Test::Util.user => :read}, @obj.user_acl)
280
+ # end
281
+
282
+
283
+ end
@@ -0,0 +1,162 @@
1
+ require 'credentials'
2
+ require 'test/unit'
3
+ require 'atmos'
4
+
5
+
6
+ class AtmosMetadataTest < Test::Unit::TestCase
7
+
8
+ def initialize(id)
9
+ super(id)
10
+ @cleanup = []
11
+ end
12
+
13
+ def setup
14
+ @s = Atmos::Test::Util.static_store
15
+ @obj = @s.create()
16
+ @cleanup.push(@obj)
17
+ end
18
+
19
+
20
+ def teardown
21
+ @cleanup.each do |obj|
22
+ obj.delete
23
+ end
24
+ $stdout.flush
25
+ end
26
+
27
+
28
+ def test_default_metadata
29
+ assert_equal({}, @obj.metadata)
30
+ assert_equal({}, @obj.listable_metadata)
31
+ assert_not_equal({}, @obj.system_metadata)
32
+ end
33
+
34
+ def test_add_metadata
35
+ assert_equal({}, @obj.metadata)
36
+ @obj.metadata['newmd'] = 'value'
37
+ assert_equal({'newmd' => 'value'}, @obj.metadata)
38
+ assert(@obj.metadata.has_key?('newmd'))
39
+ assert_equal('value', @obj.metadata['newmd'])
40
+ end
41
+
42
+ def test_add_metadata_value_nil
43
+ assert_equal({}, @obj.metadata)
44
+ @obj.metadata['newmd'] = nil
45
+ assert_equal({'newmd' => ""}, @obj.metadata)
46
+ assert(@obj.metadata.has_key?('newmd'))
47
+ assert_equal("", @obj.metadata['newmd'])
48
+ end
49
+
50
+ def test_add_metadata_value_boolean
51
+ assert_raise Atmos::Exceptions::ArgumentException do
52
+ @obj.metadata['newmd'] = true
53
+ end
54
+ end
55
+
56
+ def test_add_metadata_value_symbol
57
+ assert_raise Atmos::Exceptions::ArgumentException do
58
+ @obj.metadata['newmd'] = :value
59
+ end
60
+ end
61
+
62
+ def test_add_listable_metadata
63
+ assert_equal({}, @obj.listable_metadata)
64
+ @obj.listable_metadata['newmd'] = 'value'
65
+ assert_equal({'newmd' => 'value'}, @obj.listable_metadata)
66
+ assert(@obj.listable_metadata.has_key?('newmd'))
67
+ assert_equal('value', @obj.listable_metadata['newmd'])
68
+ end
69
+
70
+ def test_modify_metadata
71
+ assert_equal({}, @obj.metadata)
72
+ @obj.metadata['newmd'] = 'value'
73
+ assert_equal({'newmd' => 'value'}, @obj.metadata)
74
+
75
+ @obj.metadata['newmd'] = 'newvalue'
76
+ assert_equal({'newmd' => 'newvalue'}, @obj.metadata)
77
+ end
78
+
79
+ def test_modify_listable_metadata
80
+ assert_equal({}, @obj.listable_metadata)
81
+ @obj.listable_metadata['newmd'] = 'value'
82
+ assert_equal({'newmd' => 'value'}, @obj.listable_metadata)
83
+
84
+ @obj.listable_metadata['newmd'] = 'newvalue'
85
+ assert_equal({'newmd' => 'newvalue'}, @obj.listable_metadata)
86
+ end
87
+
88
+ def test_delete_metadata
89
+ assert_equal({}, @obj.metadata)
90
+ @obj.metadata['fleur'] = 'dragan'
91
+ @obj.metadata['john'] = 'kilroy'
92
+ assert_equal({'fleur' => 'dragan', 'john' => 'kilroy'}, @obj.metadata)
93
+
94
+ @obj.metadata.delete('john')
95
+ assert_equal({'fleur' => 'dragan'}, @obj.metadata)
96
+
97
+ @obj.metadata.delete('fleur')
98
+ assert_equal({}, @obj.metadata)
99
+ end
100
+
101
+ def test_clear_metadata
102
+ assert_equal({}, @obj.metadata)
103
+ @obj.metadata['fleur'] = 'dragan'
104
+ @obj.metadata['john'] = 'kilroy'
105
+ assert_equal({'fleur' => 'dragan', 'john' => 'kilroy'}, @obj.metadata)
106
+
107
+ @obj.metadata.clear
108
+ assert_equal({}, @obj.metadata)
109
+ end
110
+
111
+ def test_delete_listable_metadata
112
+ assert_equal({}, @obj.listable_metadata)
113
+ @obj.listable_metadata['fleur'] = 'dragan'
114
+ @obj.listable_metadata['john'] = 'kilroy'
115
+ assert_equal({'fleur' => 'dragan', 'john' => 'kilroy'}, @obj.listable_metadata)
116
+
117
+ @obj.listable_metadata.delete('john')
118
+ assert_equal({'fleur' => 'dragan'}, @obj.listable_metadata)
119
+
120
+ @obj.listable_metadata.delete('fleur')
121
+ assert_equal({}, @obj.listable_metadata)
122
+ end
123
+
124
+ def test_clear_listable_metadata
125
+ assert_equal({}, @obj.listable_metadata)
126
+ @obj.listable_metadata['fleur'] = 'dragan'
127
+ @obj.listable_metadata['john'] = 'kilroy'
128
+ assert_equal({'fleur' => 'dragan', 'john' => 'kilroy'}, @obj.listable_metadata)
129
+
130
+ @obj.listable_metadata.clear
131
+ assert_equal({}, @obj.listable_metadata)
132
+ end
133
+
134
+ def test_get_system_metadata
135
+ sys = @obj.system_metadata
136
+ assert_not_nil(sys)
137
+ assert(!sys.empty?)
138
+ end
139
+
140
+ def test_add_system_metadata
141
+ assert_raise Atmos::Exceptions::NotImplementedException do
142
+ @obj.system_metadata['api'] = 'ruby'
143
+ end
144
+ end
145
+
146
+ def test_modify_system_metadata
147
+ assert_raise Atmos::Exceptions::NotImplementedException do
148
+ @obj.system_metadata['uid'] = 'foo'
149
+ end
150
+ end
151
+
152
+ def test_delete_system_metadata
153
+ assert_raise Atmos::Exceptions::NotImplementedException do
154
+ @obj.system_metadata.delete('uid')
155
+ end
156
+ end
157
+
158
+ end
159
+
160
+
161
+
162
+