fog-radosgw 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ module Fog
2
+ module Radosgw
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ ENV['FOG_RC'] = ENV['FOG_RC'] || File.expand_path('../.fog', __FILE__)
2
+ ENV['FOG_CREDENTIAL'] = ENV['FOG_CREDENTIAL'] || 'default'
3
+
4
+ require 'fog'
5
+ require 'fog/test_helpers/formats_helper'
6
+
7
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'mock_helper'))
8
+
9
+ Excon.defaults.merge!(:debug_request => true, :debug_response => true)
@@ -0,0 +1,15 @@
1
+ # Use so you can run in mock mode from the command line
2
+ #
3
+ # FOG_MOCK=true fog
4
+
5
+ if ENV["FOG_MOCK"] == "true"
6
+ Fog.mock!
7
+ end
8
+
9
+ # if in mocked mode, fill in some fake credentials for us
10
+ if Fog.mock?
11
+ Fog.credentials = {
12
+ :radosgw_access_key_id => 'radosgw_access_key_id',
13
+ :radosgw_secret_access_key => 'radosgw_secret_access_key',
14
+ }.merge(Fog.credentials)
15
+ end
@@ -0,0 +1 @@
1
+ require 'fog/radosgw'
@@ -0,0 +1,170 @@
1
+ Shindo.tests('Radosgw::Provisioning | provisioning requests', ['radosgw']) do
2
+
3
+ current_timestamp = Time.now.to_i
4
+
5
+ user_format = {
6
+ 'email' => String,
7
+ 'display_name' => String,
8
+ 'user_id' => String,
9
+ 'suspended' => Integer,
10
+ 'keys' =>
11
+ [
12
+ {
13
+ 'access_key' => String,
14
+ 'secret_key' => String,
15
+ 'user' => String,
16
+ }
17
+ ],
18
+ }
19
+
20
+ tests('User creation') do
21
+
22
+ tests('is successful').returns(String) do
23
+
24
+ # Create a user.
25
+ #
26
+ email, name = "successful_user_creation_test_#{current_timestamp}@example.com", "Fog User 0"
27
+ user_id = Fog::Radosgw[:provisioning].create_user(name, name, email).body['user_id']
28
+ user_id.class
29
+
30
+ end
31
+
32
+ tests('fails if duplicate').raises(Fog::Radosgw::Provisioning::UserAlreadyExists) do
33
+ 2.times do
34
+ email, name = "failed_duplicate_user_creation_test_#{current_timestamp}@example.com", "Fog User 1"
35
+ user_id = Fog::Radosgw[:provisioning].create_user(name, name, email).body['user_id']
36
+ end
37
+ end
38
+
39
+ end
40
+
41
+ tests('User delete') do
42
+
43
+ tests('is successful').returns(200) do
44
+
45
+ # Create a user.
46
+ #
47
+ email, name = "successful_user_delete_test_#{current_timestamp}@example.com", "Fog User 2"
48
+ user_id = Fog::Radosgw[:provisioning].create_user(name, name, email).body['user_id']
49
+
50
+ Fog::Radosgw[:provisioning].delete_user(user_id).status
51
+
52
+ end
53
+
54
+ tests('is successful').returns(404) do
55
+
56
+ # Create a user.
57
+ #
58
+ email, name = "successful_user_delete_test_2_#{current_timestamp}@example.com", "Fog User 3"
59
+ user_id = Fog::Radosgw[:provisioning].create_user(name, name, email).body['user_id']
60
+
61
+ Fog::Radosgw[:provisioning].delete_user(user_id).status
62
+ Fog::Radosgw[:provisioning].get_user(user_id).status
63
+
64
+ end
65
+
66
+ end
67
+
68
+ tests('User disable') do
69
+
70
+ tests('is successful').returns(200) do
71
+
72
+ # Create a user.
73
+ #
74
+ email, name = "successful_user_disable_test_#{current_timestamp}@example.com", "Fog User 4"
75
+ user_id = Fog::Radosgw[:provisioning].create_user(name, name, email).body['user_id']
76
+
77
+ Fog::Radosgw[:provisioning].disable_user(user_id).status
78
+
79
+ end
80
+
81
+ end
82
+
83
+ tests('User enable') do
84
+
85
+ tests('is successful').returns(200) do
86
+
87
+ # Create a user.
88
+ #
89
+ email, name = "successful_user_disable_enable_test_#{current_timestamp}@example.com", "Fog User 5"
90
+ user_id = Fog::Radosgw[:provisioning].create_user(name, name, email).body['user_id']
91
+
92
+ Fog::Radosgw[:provisioning].disable_user(user_id).status
93
+ Fog::Radosgw[:provisioning].enable_user(user_id).status
94
+
95
+ end
96
+
97
+ end
98
+
99
+ tests('User retrieval') do
100
+
101
+ tests('is successful').formats(user_format) do
102
+
103
+ # Create a user.
104
+ #
105
+ email, name = "user_retrieval_test_#{current_timestamp}@example.com", "Fog User 6"
106
+ user_id = Fog::Radosgw[:provisioning].create_user(name, name, email).body['user_id']
107
+
108
+ # Get user details.
109
+ #
110
+ Fog::Radosgw[:provisioning].get_user(user_id).body
111
+
112
+ end
113
+
114
+ end
115
+
116
+ tests('User listing') do
117
+
118
+ tests('sucessfully lists users').formats(user_format) do
119
+
120
+ # Create a user.
121
+ #
122
+ email, name = "user_listing_test_#{current_timestamp}@example.com", "Fog User 7"
123
+ user_id = Fog::Radosgw[:provisioning].create_user(name, name, email).body['user_id']
124
+
125
+ # Ensure the list users response contains the user that we just
126
+ # created.
127
+ #
128
+ Fog::Radosgw[:provisioning].list_users.body.select { |x| x['email'] == email }.first
129
+
130
+ end
131
+
132
+ tests('successfully lists users containing no disabled users').returns(nil) do
133
+
134
+ # Create a user.
135
+ #
136
+ email, name = "user_listing_without_disabled_users_test_#{current_timestamp}@example.com", "Fog User 8"
137
+ user_id = Fog::Radosgw[:provisioning].create_user(name, name, email).body['user_id']
138
+
139
+ # Disable that user.
140
+ #
141
+ Fog::Radosgw[:provisioning].disable_user(user_id)
142
+
143
+ # Ensure the list users response does not contain the user that we
144
+ # just created and disabled.
145
+ #
146
+ Fog::Radosgw[:provisioning].list_users(:suspended => 0).body.select { |x| x['email'] == email }.first
147
+
148
+ end
149
+
150
+ tests('successfully lists users containing disabled users').formats(user_format) do
151
+
152
+ # Create a user.
153
+ #
154
+ email, name = "user_listing_with_disabled_users_test_#{current_timestamp}@example.com", "Fog User 9"
155
+ user_id = Fog::Radosgw[:provisioning].create_user(name, name, email).body['user_id']
156
+
157
+ # Disable that user.
158
+ #
159
+ Fog::Radosgw[:provisioning].disable_user(user_id)
160
+
161
+ # Ensure the list users response contains the user that we just
162
+ # created and disabled.
163
+ #
164
+ Fog::Radosgw[:provisioning].list_users.body.select { |x| x['email'] == email }.first
165
+
166
+ end
167
+
168
+ end
169
+
170
+ end
@@ -0,0 +1,23 @@
1
+ Shindo.tests('Radosgw::Usage | usage requests', ['radosgw']) do
2
+
3
+ @blank_usage_format = {
4
+ 'entries' => [],
5
+ 'summary' => []
6
+ }
7
+
8
+ tests('Statistics retrieval with no data returned') do
9
+
10
+ start_time = Time.now.utc + 86400
11
+ end_time = start_time + 86400
12
+
13
+ tests('via JSON').returns(@blank_usage_format) do
14
+
15
+ Fog::Radosgw[:usage].get_usage(Fog.credentials[:radosgw_access_key_id],
16
+ :types => [:access, :storage],
17
+ :start_time => start_time,
18
+ :end_time => end_time).body
19
+
20
+ end
21
+ end
22
+
23
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fog-radosgw
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jon Kåre Hellan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-09-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: fog-json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: fog
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 1.21.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.21.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: yard
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: shindo
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Fog backend for provisioning users on Ceph Radosgw - the Swift and S3
95
+ compatible REST API for Ceph.
96
+ email: hellan@acm.org
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files:
100
+ - README.md
101
+ - LICENSE.md
102
+ files:
103
+ - .gitignore
104
+ - CONTRIBUTORS.md
105
+ - Gemfile
106
+ - LICENSE.md
107
+ - README.md
108
+ - Rakefile
109
+ - fog-radosgw.gemspec
110
+ - lib/fog/radosgw.rb
111
+ - lib/fog/radosgw/core.rb
112
+ - lib/fog/radosgw/provisioning.rb
113
+ - lib/fog/radosgw/requests/provisioning/create_user.rb
114
+ - lib/fog/radosgw/requests/provisioning/delete_user.rb
115
+ - lib/fog/radosgw/requests/provisioning/disable_user.rb
116
+ - lib/fog/radosgw/requests/provisioning/enable_user.rb
117
+ - lib/fog/radosgw/requests/provisioning/get_user.rb
118
+ - lib/fog/radosgw/requests/provisioning/list_users.rb
119
+ - lib/fog/radosgw/requests/provisioning/update_user.rb
120
+ - lib/fog/radosgw/requests/provisioning/user.json
121
+ - lib/fog/radosgw/requests/usage/get_usage.rb
122
+ - lib/fog/radosgw/usage.rb
123
+ - lib/fog/radosgw/version.rb
124
+ - tests/helper.rb
125
+ - tests/helpers/mock_helper.rb
126
+ - tests/radosgw/helper.rb
127
+ - tests/radosgw/requests/provisioning/provisioning_tests.rb
128
+ - tests/radosgw/requests/usage/usage_tests.rb
129
+ homepage: https://github.com/fog/fog-radosgw
130
+ licenses:
131
+ - MIT
132
+ post_install_message:
133
+ rdoc_options:
134
+ - --charset=UTF-8
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 1.8.23
152
+ signing_key:
153
+ specification_version: 3
154
+ summary: Fog backend for provisioning Ceph Radosgw.
155
+ test_files: []
156
+ has_rdoc: