ruby-atmos-pure 1.0.3
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/COPYING +8 -0
- data/README +129 -0
- data/Rakefile +103 -0
- data/lib/atmos.rb +35 -0
- data/lib/atmos/attributes.rb +545 -0
- data/lib/atmos/exceptions.rb +28 -0
- data/lib/atmos/object.rb +321 -0
- data/lib/atmos/parser.rb +110 -0
- data/lib/atmos/parser/rexml.rb +1 -0
- data/lib/atmos/request.rb +221 -0
- data/lib/atmos/response.rb +116 -0
- data/lib/atmos/rest.rb +145 -0
- data/lib/atmos/store.rb +220 -0
- data/lib/atmos/util.rb +40 -0
- data/lib/atmos/version.rb +12 -0
- data/test/credentials.rb +141 -0
- data/test/esutest.rb +499 -0
- data/test/files/SmallImageForTest.iso +0 -0
- data/test/files/dragaf-tiny-from-vsphere.ova +0 -0
- data/test/files/something.txt +1 -0
- data/test/require_test.rb +2 -0
- data/test/suite.rb +11 -0
- data/test/suite_noproxy.rb +12 -0
- data/test/suite_proxy.rb +14 -0
- data/test/test_acl.rb +283 -0
- data/test/test_metadata.rb +162 -0
- data/test/test_object_create.rb +167 -0
- data/test/test_object_get.rb +55 -0
- data/test/test_object_misc.rb +80 -0
- data/test/test_object_read.rb +98 -0
- data/test/test_object_update.rb +59 -0
- data/test/test_request.rb +49 -0
- data/test/test_store.rb +125 -0
- data/test/test_util.rb +58 -0
- metadata +155 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require File.dirname(__FILE__) + '/../lib/atmos'
|
4
|
+
|
5
|
+
|
6
|
+
class AtmosRequestTest < 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
|
+
|
48
|
+
end
|
49
|
+
end
|
data/test/test_store.rb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'credentials'
|
3
|
+
require 'atmos'
|
4
|
+
|
5
|
+
|
6
|
+
class AtmosStoreConstructorTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def initialize( id )
|
9
|
+
super(id)
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def test_connect_without_parser
|
21
|
+
assert_raise Atmos::Exceptions::ArgumentException do
|
22
|
+
Atmos::Store.new(:uri => Atmos::Test::Util.url,
|
23
|
+
:uid => Atmos::Test::Util.user,
|
24
|
+
:secret => Atmos::Test::Util.secret)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_connect_with_parser
|
29
|
+
Atmos::Parser::parser = Atmos::Parser::NOKOGIRI
|
30
|
+
s = Atmos::Store.new(:url => Atmos::Test::Util.url,
|
31
|
+
:uid => Atmos::Test::Util.uid,
|
32
|
+
:secret => Atmos::Test::Util.secret)
|
33
|
+
assert_not_nil(s)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_redirect
|
37
|
+
Atmos::Parser::parser = Atmos::Parser::NOKOGIRI
|
38
|
+
if (!Atmos::Test::Util.redirect_url.nil?)
|
39
|
+
assert_raise Atmos::Exceptions::NotImplementedException do
|
40
|
+
Atmos::Store.new(:url => Atmos::Test::Util.redirect_url,
|
41
|
+
:uid => Atmos::Test::Util.uid,
|
42
|
+
:secret => Atmos::Test::Util.secret)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_bad_option
|
48
|
+
Atmos::Parser::parser = Atmos::Parser::NOKOGIRI
|
49
|
+
assert_raise Atmos::Exceptions::ArgumentException do
|
50
|
+
Atmos::Store.new(:uri => Atmos::Test::Util.url,
|
51
|
+
:uid => Atmos::Test::Util.user,
|
52
|
+
:secret => Atmos::Test::Util.secret,
|
53
|
+
:foo => true)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_connect_to_bad_server_version
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
class AtmosStoreTest < Test::Unit::TestCase
|
64
|
+
|
65
|
+
def initialize( id )
|
66
|
+
super(id)
|
67
|
+
@cleanup = []
|
68
|
+
end
|
69
|
+
|
70
|
+
def setup
|
71
|
+
@s = Atmos::Test::Util.static_store;
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def teardown
|
76
|
+
@cleanup.each do |obj|
|
77
|
+
obj.delete
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
def test_get_atmos_version
|
83
|
+
rv = @s.server_version
|
84
|
+
assert_not_nil(rv)
|
85
|
+
assert_equal(String, rv.class)
|
86
|
+
assert_equal(Atmos::Test::Util.version, rv) if (!Atmos::Test::Util.version.nil?)
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
def dont_test_iterate_through_listable_tags
|
91
|
+
i = 0;
|
92
|
+
ctag = "ruby-atmos-curseword#{$$}"
|
93
|
+
obj = @s.create(:listable_metadata => {ctag => true})
|
94
|
+
@cleanup.push(obj)
|
95
|
+
|
96
|
+
@s.each_listable_tag do |tag|
|
97
|
+
i += 1
|
98
|
+
end
|
99
|
+
|
100
|
+
assert(i > 0)
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
def test_iterate_through_listable_tags_with_token
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
def test_iterate_through_objects_with_tag
|
110
|
+
srand()
|
111
|
+
tag = "ruby-atmos-curseword-#{rand()}"
|
112
|
+
|
113
|
+
for i in (1...10)
|
114
|
+
obj = @s.create(:listable_metadata => {tag => true})
|
115
|
+
@cleanup.push(obj)
|
116
|
+
end
|
117
|
+
|
118
|
+
i = 0
|
119
|
+
@s.each_object_with_listable_tag(tag) do |obj|
|
120
|
+
i += 1
|
121
|
+
end
|
122
|
+
assert_equal(9, i)
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
data/test/test_util.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'atmos'
|
3
|
+
|
4
|
+
|
5
|
+
class AtmosUtilTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
$stdout.flush
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_hash2header_nil
|
15
|
+
rv = Atmos::Util.hash2header(nil)
|
16
|
+
assert_nil(rv)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_hash2header_empty
|
20
|
+
rv = Atmos::Util.hash2header({})
|
21
|
+
assert_equal("", rv)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_hash2header_bad_input_type
|
25
|
+
assert_raise Atmos::Exceptions::ArgumentException do
|
26
|
+
Atmos::Util.hash2header([])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_hash2header
|
31
|
+
# input = {:a=>:b, :x=>:y, 1=>1}
|
32
|
+
# rv = Atmos::Util.hash2header(input)
|
33
|
+
# assert_equal("a=b, x=y, 1=1", rv)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_header2hash_nil
|
37
|
+
rv = Atmos::Util.header2hash(nil)
|
38
|
+
assert_nil(rv)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_header2hash_empty
|
42
|
+
rv = Atmos::Util.header2hash("")
|
43
|
+
assert_equal({}, rv)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_header2hash_bad_input_type
|
47
|
+
assert_raise Atmos::Exceptions::ArgumentException do
|
48
|
+
Atmos::Util.header2hash([])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_header2hash
|
53
|
+
input = "a=b, x=y, 1=1"
|
54
|
+
rv = Atmos::Util.header2hash(input)
|
55
|
+
assert_equal({'a'=>'b', 'x'=>'y', '1'=>'1'}, rv)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-atmos-pure
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Fleur Dragan
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-01-05 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: log4r
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 1
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 1
|
33
|
+
- 9
|
34
|
+
version: 1.1.9
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: ruby-hmac
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 15
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 4
|
49
|
+
- 0
|
50
|
+
version: 0.4.0
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
description: Ruby OO library to access an EMC Atmos server with rexml as XML parser.
|
54
|
+
email: fleur.dragan@emc.com
|
55
|
+
executables: []
|
56
|
+
|
57
|
+
extensions: []
|
58
|
+
|
59
|
+
extra_rdoc_files:
|
60
|
+
- README
|
61
|
+
- COPYING
|
62
|
+
files:
|
63
|
+
- Rakefile
|
64
|
+
- lib/atmos.rb
|
65
|
+
- lib/atmos/attributes.rb
|
66
|
+
- lib/atmos/exceptions.rb
|
67
|
+
- lib/atmos/object.rb
|
68
|
+
- lib/atmos/parser.rb
|
69
|
+
- lib/atmos/request.rb
|
70
|
+
- lib/atmos/response.rb
|
71
|
+
- lib/atmos/rest.rb
|
72
|
+
- lib/atmos/store.rb
|
73
|
+
- lib/atmos/util.rb
|
74
|
+
- lib/atmos/version.rb
|
75
|
+
- test/credentials.rb
|
76
|
+
- test/esutest.rb
|
77
|
+
- test/files/dragaf-tiny-from-vsphere.ova
|
78
|
+
- test/files/SmallImageForTest.iso
|
79
|
+
- test/files/something.txt
|
80
|
+
- test/require_test.rb
|
81
|
+
- test/suite.rb
|
82
|
+
- test/suite_noproxy.rb
|
83
|
+
- test/suite_proxy.rb
|
84
|
+
- test/test_acl.rb
|
85
|
+
- test/test_metadata.rb
|
86
|
+
- test/test_object_create.rb
|
87
|
+
- test/test_object_get.rb
|
88
|
+
- test/test_object_misc.rb
|
89
|
+
- test/test_object_read.rb
|
90
|
+
- test/test_object_update.rb
|
91
|
+
- test/test_request.rb
|
92
|
+
- test/test_store.rb
|
93
|
+
- test/test_util.rb
|
94
|
+
- README
|
95
|
+
- COPYING
|
96
|
+
- lib/atmos/parser/rexml.rb
|
97
|
+
has_rdoc: true
|
98
|
+
homepage: http://www.emc.com/atmos
|
99
|
+
licenses: []
|
100
|
+
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options:
|
103
|
+
- --title
|
104
|
+
- EMC Atmos' REST API gem - ruby-atmos
|
105
|
+
- --main
|
106
|
+
- README
|
107
|
+
- --line-numbers
|
108
|
+
- --inline-source
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
hash: 3
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
version: "0"
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
hash: 3
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
version: "0"
|
129
|
+
requirements: []
|
130
|
+
|
131
|
+
rubyforge_project: ruby-atmos-pure
|
132
|
+
rubygems_version: 1.3.7
|
133
|
+
signing_key:
|
134
|
+
specification_version: 3
|
135
|
+
summary: Client library for EMC's Atmos REST API
|
136
|
+
test_files:
|
137
|
+
- test/credentials.rb
|
138
|
+
- test/esutest.rb
|
139
|
+
- test/files/dragaf-tiny-from-vsphere.ova
|
140
|
+
- test/files/SmallImageForTest.iso
|
141
|
+
- test/files/something.txt
|
142
|
+
- test/require_test.rb
|
143
|
+
- test/suite.rb
|
144
|
+
- test/suite_noproxy.rb
|
145
|
+
- test/suite_proxy.rb
|
146
|
+
- test/test_acl.rb
|
147
|
+
- test/test_metadata.rb
|
148
|
+
- test/test_object_create.rb
|
149
|
+
- test/test_object_get.rb
|
150
|
+
- test/test_object_misc.rb
|
151
|
+
- test/test_object_read.rb
|
152
|
+
- test/test_object_update.rb
|
153
|
+
- test/test_request.rb
|
154
|
+
- test/test_store.rb
|
155
|
+
- test/test_util.rb
|