tim 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,34 @@
1
1
  = Tim
2
2
 
3
+ == Summary
4
+
5
+ Tim is a Rails Engine responsible for Cloud image management. It
6
+ allows clients to create, delete and upload images to a multitude of
7
+ Cloud providers. Tim builds on top of Imagefactory’s cloud
8
+ abstraction layer.
9
+
10
+ Adding the ability for clients to store meta-data (used for searching
11
+ and sorting) as well as versioning and support for access control.
12
+ Tim wraps all this up in a clean, simply RESTful API.
13
+
14
+ You can read the full presentation
15
+ here[http://www.aeolusproject.org/docs/presentations/2012-nov-conference/tim.odp].
16
+
17
+ == Configuration
18
+
19
+ === Securing Image Factory requests
20
+
21
+ It is possible to secure Image Factory requests using 2 Legged OAuth. To use 2
22
+ Legged OAuth you must set the OAuth consumer key, consumer secret and url in the
23
+ Tim::ImageFactory::Base.config.
24
+
25
+ Example:
26
+
27
+ oauth_config = {:consumer_key => "mock-key",
28
+ :consumer_secret => "mock-secret",
29
+ :site => "http://localhost:8075/imagefactory/"}
30
+ Tim::ImageFactory::Base.config = oauth_config
31
+
3
32
  == Running Tests
4
33
 
5
34
  {<img src="https://secure.travis-ci.org/aeolus-incubator/tim.png"
@@ -1,4 +1,5 @@
1
1
  require "active_resource"
2
+ require File.join(File.dirname(__FILE__), 'oauth', 'active_resource_oauth_client')
2
3
  require File.join(File.dirname(__FILE__), 'model', 'base')
3
4
  require File.join(File.dirname(__FILE__), 'model', 'target_image')
4
- require File.join(File.dirname(__FILE__), 'model', 'provider_image')
5
+ require File.join(File.dirname(__FILE__), 'model', 'provider_image')
@@ -0,0 +1,52 @@
1
+ require 'oauth'
2
+
3
+ # Monkey-patch ActiveResource to allow us to merge our OAuth headers in.
4
+ # Portions of the below are taken from Active Resource which is MIT licensed;
5
+ # hence this whole file is being licensed under the MIT License to err on the side of safety.
6
+ module ActiveResourceOAuthClient
7
+ ActiveResource::Connection.class_eval do
8
+ def request_with_oauth(method, path, *arguments)
9
+ @oauth_config = Tim::ImageFactory::Base.config || {}
10
+ # Take care to fall back to the standard request method if we don't have full OAuth credentials
11
+ unless use_oauth_for_url?("#{site.scheme}://#{site.host}:#{site.port}#{path}")
12
+ return request_without_oauth(method, path, *arguments)
13
+ end
14
+ result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload|
15
+ payload[:method] = method
16
+ payload[:request_uri] = "#{site.scheme}://#{site.host}:#{site.port}#{path}"
17
+ puts "#{payload[:method]} #{payload[:request_uri]}"
18
+ oauth_consumer = OAuth::Consumer.new(
19
+ @oauth_config[:consumer_key],
20
+ @oauth_config[:consumer_secret],
21
+ :site => @oauth_config[:site] )
22
+ puts @oauth_config[:consumer_key] + " " + @oauth_config[:consumer_secret]
23
+ token = OAuth::AccessToken.new(oauth_consumer)
24
+ base_request = oauth_consumer.create_signed_request(method, path, token, {}, *arguments)
25
+ payload[:result] = http.request(base_request)
26
+ end
27
+ # Error-handling code from OAuth
28
+ # http://wiki.oauth.net/w/page/12238543/ProblemReporting
29
+ auth_header = result.to_hash['www-authenticate']
30
+ problem_header = auth_header ? auth_header.select{|h| h =~ /^OAuth /}.select{|h| h =~ /oauth_problem/}.first : nil
31
+ if auth_header && problem_header
32
+ params = OAuth::Helper.parse_header(problem_header)
33
+ raise OAuth::Problem.new(params.delete("oauth_problem"), result, params)
34
+ end
35
+ # Error-handling code from ActiveResource
36
+ handle_response(result)
37
+ rescue Timeout::Error => e
38
+ raise TimeoutError.new(e.message)
39
+ rescue OpenSSL::SSL::SSLError => e
40
+ raise SSLError.new(e.message)
41
+ end
42
+
43
+ # Currently, only Factory calls should use OAuth -- extend as needed
44
+ def use_oauth_for_url?(url)
45
+ Tim::ImageFactory::Base.use_oauth? and
46
+ url.include?(Tim::ImageFactory::Base.config[:site])
47
+ end
48
+
49
+ alias_method_chain :request, :oauth
50
+
51
+ end
52
+ end
@@ -1,3 +1,3 @@
1
1
  module Tim
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,8 +1,16 @@
1
1
  Tim.user_class = "User"
2
2
  Tim.provider_account_class = "ProviderAccount"
3
3
  Tim.provider_type_class = "ProviderType"
4
+
4
5
  # Image Factory URL
5
6
  Tim::ImageFactory::Base.site = "http://localhost:8075/imagefactory"
7
+
8
+ # Example OAuth Configuration
9
+ #oauth_config = {:consumer_key => "mock-key",
10
+ # :consumer_secret => "mock-secret",
11
+ # :site => "http://localhost:8075/imagefactory/"}#
12
+ #Tim::ImageFactory::Base.config = oauth_config
13
+
6
14
  # FIXME: We should be able to infer these from Routes
7
15
  Tim::ImageFactory::TargetImage.callback_url = "http://localhost:3000/tim/target_images/"
8
16
  Tim::ImageFactory::ProviderImage.callback_url = "http://localhost:3000/tim/provider_images/"
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency "rails", "~> 3.2"
22
22
  s.add_dependency "haml"
23
23
  s.add_dependency "nokogiri"
24
+ s.add_dependency "oauth"
24
25
 
25
26
  s.add_development_dependency "sqlite3"
26
27
  s.add_development_dependency "rspec-rails"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-16 00:00:00.000000000 Z
13
+ date: 2013-02-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &8009320 !ruby/object:Gem::Requirement
17
+ requirement: &12953140 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '3.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *8009320
25
+ version_requirements: *12953140
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: haml
28
- requirement: &8007020 !ruby/object:Gem::Requirement
28
+ requirement: &12950400 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *8007020
36
+ version_requirements: *12950400
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: nokogiri
39
- requirement: &8006340 !ruby/object:Gem::Requirement
39
+ requirement: &12965480 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,21 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *8006340
47
+ version_requirements: *12965480
48
+ - !ruby/object:Gem::Dependency
49
+ name: oauth
50
+ requirement: &12962440 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: *12962440
48
59
  - !ruby/object:Gem::Dependency
49
60
  name: sqlite3
50
- requirement: &8018880 !ruby/object:Gem::Requirement
61
+ requirement: &12958660 !ruby/object:Gem::Requirement
51
62
  none: false
52
63
  requirements:
53
64
  - - ! '>='
@@ -55,10 +66,10 @@ dependencies:
55
66
  version: '0'
56
67
  type: :development
57
68
  prerelease: false
58
- version_requirements: *8018880
69
+ version_requirements: *12958660
59
70
  - !ruby/object:Gem::Dependency
60
71
  name: rspec-rails
61
- requirement: &8016220 !ruby/object:Gem::Requirement
72
+ requirement: &12973520 !ruby/object:Gem::Requirement
62
73
  none: false
63
74
  requirements:
64
75
  - - ! '>='
@@ -66,10 +77,10 @@ dependencies:
66
77
  version: '0'
67
78
  type: :development
68
79
  prerelease: false
69
- version_requirements: *8016220
80
+ version_requirements: *12973520
70
81
  - !ruby/object:Gem::Dependency
71
82
  name: database_cleaner
72
- requirement: &8026240 !ruby/object:Gem::Requirement
83
+ requirement: &12971700 !ruby/object:Gem::Requirement
73
84
  none: false
74
85
  requirements:
75
86
  - - ! '>='
@@ -77,10 +88,10 @@ dependencies:
77
88
  version: '0'
78
89
  type: :development
79
90
  prerelease: false
80
- version_requirements: *8026240
91
+ version_requirements: *12971700
81
92
  - !ruby/object:Gem::Dependency
82
93
  name: factory_girl_rails
83
- requirement: &8035500 !ruby/object:Gem::Requirement
94
+ requirement: &12970380 !ruby/object:Gem::Requirement
84
95
  none: false
85
96
  requirements:
86
97
  - - ~>
@@ -88,10 +99,10 @@ dependencies:
88
99
  version: 4.1.0
89
100
  type: :development
90
101
  prerelease: false
91
- version_requirements: *8035500
102
+ version_requirements: *12970380
92
103
  - !ruby/object:Gem::Dependency
93
104
  name: minitest
94
- requirement: &8865100 !ruby/object:Gem::Requirement
105
+ requirement: &12969260 !ruby/object:Gem::Requirement
95
106
  none: false
96
107
  requirements:
97
108
  - - ! '>='
@@ -99,7 +110,7 @@ dependencies:
99
110
  version: '0'
100
111
  type: :development
101
112
  prerelease: false
102
- version_requirements: *8865100
113
+ version_requirements: *12969260
103
114
  description: Rails engine client for the Aeolus Image Factory cross-cloud virtual
104
115
  machine image builder.
105
116
  email:
@@ -198,7 +209,6 @@ files:
198
209
  - db/migrate/20121210131423_add_build_method_to_target_image.rb
199
210
  - db/migrate/20120910175233_create_tim_templates.rb
200
211
  - lib/tasks/tim_tasks.rake
201
- - lib/tasks/cucumber.rake
202
212
  - lib/tim/engine.rb
203
213
  - lib/tim/version.rb
204
214
  - lib/generators/tim/templates/README
@@ -210,6 +220,7 @@ files:
210
220
  - lib/image_factory/model/base.rb
211
221
  - lib/image_factory/model/target_image.rb
212
222
  - lib/image_factory/image_factory.rb
223
+ - lib/image_factory/oauth/active_resource_oauth_client.rb
213
224
  - MIT-LICENSE
214
225
  - Rakefile
215
226
  - README.rdoc
@@ -315,7 +326,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
315
326
  version: '0'
316
327
  segments:
317
328
  - 0
318
- hash: 2330827430856779926
329
+ hash: -2467413164711160043
319
330
  required_rubygems_version: !ruby/object:Gem::Requirement
320
331
  none: false
321
332
  requirements:
@@ -324,7 +335,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
324
335
  version: '0'
325
336
  segments:
326
337
  - 0
327
- hash: 2330827430856779926
338
+ hash: -2467413164711160043
328
339
  requirements: []
329
340
  rubyforge_project:
330
341
  rubygems_version: 1.8.15
@@ -1,59 +0,0 @@
1
- # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
- # It is recommended to regenerate this file in the future when you upgrade to a
3
- # newer version of cucumber-rails. Consider adding your own code to a new file
4
- # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
- # files.
6
-
7
-
8
- unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
9
-
10
- begin
11
- require 'cucumber/rake/task'
12
-
13
- namespace :cucumber do
14
- Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
15
- t.fork = true # You may get faster startup if you set this to false
16
- t.profile = 'default'
17
- end
18
-
19
- Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
20
- t.fork = true # You may get faster startup if you set this to false
21
- t.profile = 'wip'
22
- end
23
-
24
- Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
25
- t.fork = true # You may get faster startup if you set this to false
26
- t.profile = 'rerun'
27
- end
28
-
29
- desc 'Run all features'
30
- task :all => [:ok, :wip]
31
-
32
- task :statsetup do
33
- require 'rails/code_statistics'
34
- ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
35
- ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
36
- end
37
- end
38
- desc 'Alias for cucumber:ok'
39
- task :cucumber => 'cucumber:ok'
40
-
41
- task :default => :cucumber
42
-
43
- task :features => :cucumber do
44
- STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
45
- end
46
-
47
- # In case we don't have ActiveRecord, append a no-op task that we can depend upon.
48
- task 'db:test:prepare' do
49
- end
50
-
51
- task :stats => 'cucumber:statsetup'
52
- rescue LoadError
53
- desc 'cucumber rake task not available (cucumber not installed)'
54
- task :cucumber do
55
- abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
56
- end
57
- end
58
-
59
- end