waz-storage 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,9 +15,11 @@ module WAZ
15
15
  #
16
16
  # All other parameters are optional.
17
17
  def establish_connection!(options = {})
18
- raise InvalidOption, :account_name unless options.keys.include? :account_name
19
- raise InvalidOption, :access_key unless options.keys.include? :access_key
20
- options[:use_ssl] = false unless options.keys.include? :use_ssl
18
+ raise InvalidOption, :account_name unless options.keys.include? :account_name
19
+ raise InvalidOption, :access_key if !options.keys.include? :use_sas_auth_only unless options.keys.include? :access_key
20
+ raise InvalidOption, :use_sas_auth_only if !options.keys.include? :access_key unless options.keys.include? :use_sas_auth_only
21
+ raise InvalidOption, :sharedaccesssignature if !options.keys.include? :access_key unless options.keys.include? :sharedaccesssignature and options.keys.include? :use_sas_auth_only
22
+ options[:use_ssl] = false unless options.keys.include? :use_ssl
21
23
  (@connections ||= []) << options
22
24
  end
23
25
 
@@ -65,4 +67,4 @@ module WAZ
65
67
  end
66
68
  end
67
69
  end
68
- end
70
+ end
@@ -3,10 +3,14 @@ module WAZ
3
3
  # This module is imported by the specific services that use Shared Key authentication profile. On the current implementation
4
4
  # this module is imported from WAZ::Queues::Service and WAZ::Blobs::Service.
5
5
  module SharedKeyCoreService
6
- attr_accessor :account_name, :access_key, :use_ssl, :base_url, :type_of_service, :use_devenv
6
+ attr_accessor :account_name, :access_key, :use_ssl, :base_url, :type_of_service, :use_devenv, :use_sas_auth_only, :sharedaccesssignature
7
7
 
8
8
  # Creates an instance of the implementor service (internally used by the API).
9
9
  def initialize(options = {})
10
+ # Flag to define the use of shared access signature only
11
+ self.use_sas_auth_only = options[:use_sas_auth_only] or false
12
+ self.sharedaccesssignature = options[:sharedaccesssignature]
13
+
10
14
  self.account_name = options[:account_name]
11
15
  self.access_key = options[:access_key]
12
16
  self.type_of_service = options[:type_of_service]
@@ -25,7 +29,7 @@ module WAZ
25
29
  http_headers.merge!("x-ms-Date" => Time.new.httpdate)
26
30
  http_headers.merge!("Content-Length" => (payload or "").size)
27
31
  request = {:headers => http_headers, :method => verb.to_s.downcase.to_sym, :url => url, :payload => payload}
28
- request[:headers].merge!("Authorization" => "SharedKey #{account_name}:#{generate_signature(request)}")
32
+ request[:headers].merge!("Authorization" => "SharedKey #{account_name}:#{generate_signature(request)}") unless self.use_sas_auth_only
29
33
  return RestClient::Request.new(request)
30
34
  end
31
35
 
@@ -36,7 +40,11 @@ module WAZ
36
40
  query_params = options.keys.sort{ |a, b| a.to_s <=> b.to_s}.map{ |k| "#{k.to_s.gsub(/_/, '')}=#{CGI.escape(options[k].to_s)}"}.join("&") unless options.nil? or options.empty?
37
41
  uri = "#{protocol}://#{base_url}/#{path.start_with?(account_name) ? "" : account_name }#{((path or "").start_with?("/") or path.start_with?(account_name)) ? "" : "/"}#{(path or "")}" if !self.use_devenv.nil? and self.use_devenv
38
42
  uri ||= "#{protocol}://#{account_name}.#{base_url}#{(path or "").start_with?("/") ? "" : "/"}#{(path or "")}"
39
- uri << "?#{query_params}" if query_params
43
+ if self.use_sas_auth_only
44
+ uri << "?#{self.sharedaccesssignature.gsub(/\?/,'')}"
45
+ else
46
+ uri << "?#{query_params}" if query_params
47
+ end
40
48
  return uri
41
49
  end
42
50
 
@@ -111,4 +119,4 @@ module WAZ
111
119
  end
112
120
  end
113
121
  end
114
- end
122
+ end
@@ -3,7 +3,7 @@ module WAZ
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = '1'
5
5
  MINOR = '0'
6
- TINY = '5'
6
+ TINY = '6'
7
7
  end
8
8
 
9
9
  Version = [VERSION::MAJOR, VERSION::MINOR, VERSION::TINY].compact * '.'
data/rakefile CHANGED
@@ -1,17 +1,18 @@
1
1
  require 'rake'
2
2
  require 'rubygems'
3
- require 'spec/rake/spectask'
3
+ require 'rspec/core/rake_task'
4
4
  require 'rake/gempackagetask'
5
5
  require 'rake/rdoctask'
6
6
  require 'lib/waz-storage'
7
7
 
8
8
  task :default => [:specs]
9
9
 
10
- Spec::Rake::SpecTask.new('specs') do |t|
11
- t.spec_files = FileList['tests/waz/blobs/*.rb', 'tests/waz/queues/*.rb', 'tests/waz/tables/*.rb', 'tests/waz/storage/*.rb']
10
+ RSpec::Core::RakeTask.new do |t|
11
+ t.name = :specs
12
+ t.pattern = "tests/**/*.rb"
12
13
  t.rcov = true
13
14
  t.rcov_opts = ['--text-report', '--exclude', "exclude.*/.gem,test,Library,#{ENV['GEM_HOME']}", '--sort', 'coverage' ]
14
- t.spec_opts = ['-cfn']
15
+ t.rspec_opts = ['-cfn']
15
16
  end
16
17
 
17
18
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waz-storage
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 5
10
- version: 1.0.5
9
+ - 6
10
+ version: 1.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Johnny G. Halife
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-19 00:00:00 -03:00
18
+ date: 2011-05-18 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency