signet 0.3.2 → 0.3.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/CHANGELOG.md +7 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +39 -0
- data/README.md +3 -0
- data/Rakefile +1 -11
- data/lib/signet/oauth_1/client.rb +63 -66
- data/lib/signet/oauth_2/client.rb +37 -59
- data/lib/signet/version.rb +1 -1
- data/spec/signet/oauth_1/client_spec.rb +88 -0
- data/spec/signet/oauth_2/client_spec.rb +10 -28
- data/tasks/gem.rake +2 -4
- data/tasks/wiki.rake +0 -1
- metadata +71 -141
- data/tasks/rdoc.rake +0 -26
- data/tasks/rubyforge.rake +0 -100
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 0.3.3
|
2
|
+
|
3
|
+
* Request objects no longer recreated during processing
|
4
|
+
* Faraday middleware now supported
|
5
|
+
* Streamed requests now supported
|
6
|
+
* Fixed assertion profiles; client ID/secret omission no longer an error
|
7
|
+
|
1
8
|
# 0.3.2
|
2
9
|
|
3
10
|
* Added audience security check for ID tokens
|
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'addressable', '>= 2.2.3'
|
4
|
+
gem 'faraday', '~> 0.7.0'
|
5
|
+
gem 'multi_json', '>= 1.3.0'
|
6
|
+
gem 'jwt', '>= 0.1.4'
|
7
|
+
gem 'extlib', '>= 0.9.15'
|
8
|
+
gem 'jruby-openssl', :platforms => :jruby
|
9
|
+
|
10
|
+
group :development do
|
11
|
+
gem 'launchy'
|
12
|
+
gem 'yard'
|
13
|
+
gem 'redcarpet'
|
14
|
+
end
|
15
|
+
|
16
|
+
group :test, :development do
|
17
|
+
gem 'rake', '>= 0.9.0'
|
18
|
+
gem 'rspec', '~> 1.2.9'
|
19
|
+
gem 'rcov', '>= 0.9.9', :platform => :mri_18
|
20
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.2.8)
|
5
|
+
extlib (0.9.15)
|
6
|
+
faraday (0.7.6)
|
7
|
+
addressable (~> 2.2)
|
8
|
+
multipart-post (~> 1.1)
|
9
|
+
rack (~> 1.1)
|
10
|
+
json (1.7.3)
|
11
|
+
jwt (0.1.4)
|
12
|
+
json (>= 1.2.4)
|
13
|
+
launchy (2.1.0)
|
14
|
+
addressable (~> 2.2.6)
|
15
|
+
multi_json (1.3.5)
|
16
|
+
multipart-post (1.1.5)
|
17
|
+
rack (1.4.1)
|
18
|
+
rake (0.9.2.2)
|
19
|
+
rcov (1.0.0)
|
20
|
+
redcarpet (2.1.1)
|
21
|
+
rspec (1.2.9)
|
22
|
+
yard (0.8.1)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
addressable (>= 2.2.3)
|
29
|
+
extlib (>= 0.9.15)
|
30
|
+
faraday (~> 0.7.0)
|
31
|
+
jruby-openssl
|
32
|
+
jwt (>= 0.1.4)
|
33
|
+
launchy
|
34
|
+
multi_json (>= 1.3.0)
|
35
|
+
rake (>= 0.9.0)
|
36
|
+
rcov (>= 0.9.9)
|
37
|
+
redcarpet
|
38
|
+
rspec (~> 1.2.9)
|
39
|
+
yard
|
data/README.md
CHANGED
@@ -7,6 +7,9 @@
|
|
7
7
|
<dt>License</dt><dd>Apache 2.0</dd>
|
8
8
|
</dl>
|
9
9
|
|
10
|
+
[](http://travis-ci.org/google/signet)
|
11
|
+
[](https://gemnasium.com/google/signet)
|
12
|
+
|
10
13
|
## Description
|
11
14
|
|
12
15
|
Signet is an OAuth 1.0 / OAuth 2.0 implementation.
|
data/Rakefile
CHANGED
@@ -4,11 +4,6 @@ $:.uniq!
|
|
4
4
|
|
5
5
|
require 'rubygems'
|
6
6
|
require 'rake'
|
7
|
-
require 'rake/testtask'
|
8
|
-
require 'rake/rdoctask'
|
9
|
-
require 'rake/packagetask'
|
10
|
-
require 'rake/gempackagetask'
|
11
|
-
require 'rake/contrib/rubyforgepublisher'
|
12
7
|
|
13
8
|
begin
|
14
9
|
require 'spec/rake/spectask'
|
@@ -27,14 +22,9 @@ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
|
27
22
|
|
28
23
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
29
24
|
|
30
|
-
RUBY_FORGE_PROJECT = PKG_NAME
|
31
|
-
RUBY_FORGE_USER = "sporkmonger"
|
32
|
-
RUBY_FORGE_PATH = "/var/www/gforge-projects/#{RUBY_FORGE_PROJECT}"
|
33
|
-
RUBY_FORGE_URL = "http://#{RUBY_FORGE_PROJECT}.rubyforge.org/"
|
34
|
-
|
35
25
|
PKG_AUTHOR = "Bob Aman"
|
36
26
|
PKG_AUTHOR_EMAIL = "bobaman@google.com"
|
37
|
-
PKG_HOMEPAGE =
|
27
|
+
PKG_HOMEPAGE = "http://code.google.com/p/oauth-signet/"
|
38
28
|
PKG_SUMMARY = "Package Summary"
|
39
29
|
PKG_DESCRIPTION = <<-TEXT
|
40
30
|
Signet is an OAuth 1.0 / OAuth 2.0 implementation.
|
@@ -849,93 +849,90 @@ module Signet
|
|
849
849
|
end
|
850
850
|
options = {
|
851
851
|
:signature_method => 'HMAC-SHA1',
|
852
|
-
:realm => nil
|
852
|
+
:realm => nil,
|
853
|
+
:connection => Faraday.default_connection
|
853
854
|
}.merge(options)
|
854
|
-
|
855
|
+
|
856
|
+
if options[:request].kind_of?(Faraday::Request)
|
857
|
+
request = options[:request]
|
858
|
+
else
|
855
859
|
if options[:request].kind_of?(Array)
|
856
860
|
method, uri, headers, body = options[:request]
|
857
|
-
|
858
|
-
options[:
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
)
|
863
|
-
headers = options[:request].headers || {}
|
864
|
-
body = options[:request].body || ''
|
861
|
+
else
|
862
|
+
method = options[:method] || :get
|
863
|
+
uri = options[:uri]
|
864
|
+
headers = options[:headers] || []
|
865
|
+
body = options[:body] || ''
|
865
866
|
end
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
}
|
879
|
-
# Verify that we have all pieces required to return an HTTP request
|
880
|
-
request_components.each do |(key, value)|
|
881
|
-
unless value
|
882
|
-
raise ArgumentError, "Missing :#{key} parameter."
|
867
|
+
headers = headers.to_a if headers.kind_of?(Hash)
|
868
|
+
request_components = {
|
869
|
+
:method => method,
|
870
|
+
:uri => uri,
|
871
|
+
:headers => headers,
|
872
|
+
:body => body
|
873
|
+
}
|
874
|
+
# Verify that we have all pieces required to return an HTTP request
|
875
|
+
request_components.each do |(key, value)|
|
876
|
+
unless value
|
877
|
+
raise ArgumentError, "Missing :#{key} parameter."
|
878
|
+
end
|
883
879
|
end
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
880
|
+
if !body.kind_of?(String) && body.respond_to?(:each)
|
881
|
+
# Just in case we get a chunked body
|
882
|
+
merged_body = StringIO.new
|
883
|
+
body.each do |chunk|
|
884
|
+
merged_body.write(chunk)
|
885
|
+
end
|
886
|
+
body = merged_body.string
|
887
|
+
end
|
888
|
+
if !body.kind_of?(String)
|
889
|
+
raise TypeError, "Expected String, got #{body.class}."
|
890
|
+
end
|
891
|
+
method = method.to_s.downcase.to_sym
|
892
|
+
|
893
|
+
request = Faraday::Request.create(method) do |req|
|
894
|
+
req.url(Addressable::URI.parse(uri))
|
895
|
+
req.headers = Faraday::Utils::Headers.new(headers)
|
896
|
+
req.body = body
|
890
897
|
end
|
891
|
-
body = merged_body.string
|
892
|
-
end
|
893
|
-
if !body.kind_of?(String)
|
894
|
-
raise TypeError, "Expected String, got #{body.class}."
|
895
898
|
end
|
896
|
-
|
899
|
+
|
897
900
|
parameters = ::Signet::OAuth1.unsigned_resource_parameters(
|
898
901
|
:client_credential_key => self.client_credential_key,
|
899
902
|
:token_credential_key => self.token_credential_key,
|
900
903
|
:signature_method => options[:signature_method],
|
901
904
|
:two_legged => self.two_legged
|
902
905
|
)
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
906
|
+
|
907
|
+
env = request.to_env(options[:connection])
|
908
|
+
|
909
|
+
content_type = request['Content-Type'].to_s
|
910
|
+
content_type = content_type.split(';', 2).first if content_type.index(';')
|
911
|
+
if request.method == :post && content_type == 'application/x-www-form-urlencoded'
|
912
|
+
# Serializes the body in case a hash/array was passed. Noop if already string like
|
913
|
+
encoder = Faraday::Request::UrlEncoded.new(lambda { |env| })
|
914
|
+
encoder.call(env)
|
915
|
+
request.body = env[:body]
|
916
|
+
|
917
|
+
post_parameters = Addressable::URI.form_unencode(env[:body])
|
918
|
+
parameters = parameters.concat(post_parameters)
|
919
|
+
end
|
920
|
+
|
916
921
|
# No need to attach URI query parameters, the .sign_parameters
|
917
922
|
# method takes care of that automatically.
|
918
923
|
signature = ::Signet::OAuth1.sign_parameters(
|
919
|
-
method,
|
920
|
-
|
924
|
+
env[:method],
|
925
|
+
env[:url],
|
921
926
|
parameters,
|
922
927
|
self.client_credential_secret,
|
923
928
|
self.token_credential_secret
|
924
929
|
)
|
930
|
+
|
925
931
|
parameters << ['oauth_signature', signature]
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
)
|
931
|
-
]
|
932
|
-
headers << authorization_header
|
933
|
-
headers << ['Cache-Control', 'no-store']
|
934
|
-
return Faraday::Request.create(method.to_s.downcase.to_sym) do |req|
|
935
|
-
req.url(Addressable::URI.parse(uri))
|
936
|
-
req.headers = Faraday::Utils::Headers.new(headers)
|
937
|
-
req.body = body
|
938
|
-
end
|
932
|
+
request['Authorization'] = ::Signet::OAuth1.generate_authorization_header(
|
933
|
+
parameters, options[:realm])
|
934
|
+
request['Cache-Control'] = 'no-store'
|
935
|
+
return request
|
939
936
|
end
|
940
937
|
|
941
938
|
##
|
@@ -656,12 +656,7 @@ module Signet
|
|
656
656
|
if self.token_credential_uri == nil
|
657
657
|
raise ArgumentError, 'Missing token endpoint URI.'
|
658
658
|
end
|
659
|
-
|
660
|
-
raise ArgumentError, 'Missing client identifier.'
|
661
|
-
end
|
662
|
-
if self.client_secret == nil
|
663
|
-
raise ArgumentError, 'Missing client secret.'
|
664
|
-
end
|
659
|
+
|
665
660
|
method = 'POST'
|
666
661
|
parameters = {"grant_type" => self.grant_type}
|
667
662
|
case self.grant_type
|
@@ -679,9 +674,10 @@ module Signet
|
|
679
674
|
# the presence of the redirect URI.
|
680
675
|
raise ArgumentError, 'Missing authorization code.'
|
681
676
|
end
|
677
|
+
parameters.merge!(self.extension_parameters)
|
682
678
|
end
|
683
|
-
parameters['client_id'] = self.client_id
|
684
|
-
parameters['client_secret'] = self.client_secret
|
679
|
+
parameters['client_id'] = self.client_id unless self.client_id.nil?
|
680
|
+
parameters['client_secret'] = self.client_secret unless self.client_secret.nil?
|
685
681
|
headers = [
|
686
682
|
['Cache-Control', 'no-store'],
|
687
683
|
['Content-Type', 'application/x-www-form-urlencoded']
|
@@ -752,7 +748,7 @@ module Signet
|
|
752
748
|
# - <code>:realm</code> —
|
753
749
|
# The Authorization realm. See RFC 2617.
|
754
750
|
#
|
755
|
-
# @return [
|
751
|
+
# @return [Faraday::Request] The request object.
|
756
752
|
def generate_authenticated_request(options={})
|
757
753
|
if self.access_token == nil
|
758
754
|
raise ArgumentError, 'Missing access token.'
|
@@ -760,62 +756,44 @@ module Signet
|
|
760
756
|
options = {
|
761
757
|
:realm => nil
|
762
758
|
}.merge(options)
|
763
|
-
if options[:request]
|
759
|
+
if options[:request].kind_of?(Faraday::Request)
|
760
|
+
request = options[:request]
|
761
|
+
else
|
764
762
|
if options[:request].kind_of?(Array)
|
765
763
|
method, uri, headers, body = options[:request]
|
766
|
-
|
767
|
-
options[:
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
)
|
772
|
-
headers = options[:request].headers || {}
|
773
|
-
body = options[:request].body || ''
|
764
|
+
else
|
765
|
+
method = options[:method] || :get
|
766
|
+
uri = options[:uri]
|
767
|
+
headers = options[:headers] || []
|
768
|
+
body = options[:body] || ''
|
774
769
|
end
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
}
|
788
|
-
# Verify that we have all pieces required to return an HTTP request
|
789
|
-
request_components.each do |(key, value)|
|
790
|
-
unless value
|
791
|
-
raise ArgumentError, "Missing :#{key} parameter."
|
770
|
+
headers = headers.to_a if headers.kind_of?(Hash)
|
771
|
+
request_components = {
|
772
|
+
:method => method,
|
773
|
+
:uri => uri,
|
774
|
+
:headers => headers,
|
775
|
+
:body => body
|
776
|
+
}
|
777
|
+
# Verify that we have all pieces required to return an HTTP request
|
778
|
+
request_components.each do |(key, value)|
|
779
|
+
unless value
|
780
|
+
raise ArgumentError, "Missing :#{key} parameter."
|
781
|
+
end
|
792
782
|
end
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
merged_body.write(chunk)
|
783
|
+
method = method.to_s.downcase.to_sym
|
784
|
+
request = Faraday::Request.create(method.to_s.downcase.to_sym) do |req|
|
785
|
+
req.url(Addressable::URI.parse(uri))
|
786
|
+
req.headers = Faraday::Utils::Headers.new(headers)
|
787
|
+
req.body = body
|
799
788
|
end
|
800
|
-
body = merged_body.string
|
801
|
-
end
|
802
|
-
if !body.kind_of?(String)
|
803
|
-
raise TypeError, "Expected String, got #{body.class}."
|
804
|
-
end
|
805
|
-
method = method.to_s.downcase.to_sym
|
806
|
-
headers << [
|
807
|
-
'Authorization',
|
808
|
-
::Signet::OAuth2.generate_bearer_authorization_header(
|
809
|
-
self.access_token,
|
810
|
-
options[:realm] ? [['realm', options[:realm]]] : nil
|
811
|
-
)
|
812
|
-
]
|
813
|
-
headers << ['Cache-Control', 'no-store']
|
814
|
-
return Faraday::Request.create(method.to_s.downcase.to_sym) do |req|
|
815
|
-
req.url(Addressable::URI.parse(uri))
|
816
|
-
req.headers = Faraday::Utils::Headers.new(headers)
|
817
|
-
req.body = body
|
818
789
|
end
|
790
|
+
|
791
|
+
request['Authorization'] = ::Signet::OAuth2.generate_bearer_authorization_header(
|
792
|
+
self.access_token,
|
793
|
+
options[:realm] ? [['realm', options[:realm]]] : nil
|
794
|
+
)
|
795
|
+
request['Cache-Control'] = 'no-store'
|
796
|
+
return request
|
819
797
|
end
|
820
798
|
|
821
799
|
##
|
data/lib/signet/version.rb
CHANGED
@@ -690,4 +690,92 @@ describe Signet::OAuth1::Client, 'configured' do
|
|
690
690
|
parameters['oauth_version'].should == '1.0'
|
691
691
|
end
|
692
692
|
end
|
693
|
+
|
694
|
+
describe 'with Faraday requests' do
|
695
|
+
|
696
|
+
it 'should correctly get the protected resource' do
|
697
|
+
# Repeat this because signatures change from test to test
|
698
|
+
10.times do
|
699
|
+
original_request = Faraday::Request.create(:get) do |req|
|
700
|
+
req.url(Addressable::URI.parse('https://photos.example.net/photos?file=vacation.jpg&size=original'))
|
701
|
+
req.headers = Faraday::Utils::Headers.new([['Host', 'photos.example.net']])
|
702
|
+
req.body = ''
|
703
|
+
end
|
704
|
+
|
705
|
+
signed_request = @client.generate_authenticated_request(
|
706
|
+
:request => original_request
|
707
|
+
)
|
708
|
+
|
709
|
+
# Should be same request object
|
710
|
+
original_request['Authorization'].should == signed_request['Authorization']
|
711
|
+
|
712
|
+
signed_request.method.should == :get
|
713
|
+
signed_request.path.should ===
|
714
|
+
'https://photos.example.net/photos?file=vacation.jpg&size=original'
|
715
|
+
authorization_header = signed_request.headers['Authorization']
|
716
|
+
signed_request.body.should == ''
|
717
|
+
parameters = ::Signet::OAuth1.parse_authorization_header(
|
718
|
+
authorization_header
|
719
|
+
).inject({}) { |h,(k,v)| h[k]=v; h }
|
720
|
+
parameters.should_not have_key('oauth_client_credential_key')
|
721
|
+
parameters.should_not have_key('oauth_temporary_credential_key')
|
722
|
+
parameters.should_not have_key('oauth_token_credential_key')
|
723
|
+
parameters.should_not have_key('oauth_callback')
|
724
|
+
parameters['oauth_nonce'].should =~ /^\w+$/
|
725
|
+
parameters['oauth_timestamp'].should =~ /^\d+$/
|
726
|
+
parameters['oauth_signature_method'].should == 'HMAC-SHA1'
|
727
|
+
parameters['oauth_consumer_key'].should == @client.client_credential_key
|
728
|
+
parameters['oauth_token'].should == @client.token_credential_key
|
729
|
+
parameters['oauth_signature'].should =~ /^[a-zA-Z0-9\=\/\+]+$/
|
730
|
+
parameters['oauth_version'].should == '1.0'
|
731
|
+
end
|
732
|
+
end
|
733
|
+
|
734
|
+
it 'should correctly post the protected resource' do
|
735
|
+
# Repeat this because signatures change from test to test
|
736
|
+
10.times do
|
737
|
+
original_request = Faraday::Request.create(:post) do |req|
|
738
|
+
req.url(Addressable::URI.parse('https://photos.example.net/photos'))
|
739
|
+
req.headers = Faraday::Utils::Headers.new([
|
740
|
+
['Host', 'photos.example.net'],
|
741
|
+
['Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'],
|
742
|
+
['Content-Length', '31'],
|
743
|
+
])
|
744
|
+
req.body = {
|
745
|
+
'size' => 'original',
|
746
|
+
'file' => 'vacation.jpg'
|
747
|
+
}
|
748
|
+
end
|
749
|
+
|
750
|
+
signed_request = @client.generate_authenticated_request(
|
751
|
+
:request => original_request
|
752
|
+
)
|
753
|
+
|
754
|
+
# Should be same request object
|
755
|
+
original_request['Authorization'].should == signed_request['Authorization']
|
756
|
+
|
757
|
+
signed_request.method.should == :post
|
758
|
+
signed_request.path.should ===
|
759
|
+
'https://photos.example.net/photos'
|
760
|
+
authorization_header = signed_request.headers['Authorization']
|
761
|
+
# Can't rely on the order post parameters are encoded in.
|
762
|
+
signed_request.body.should include('file=vacation.jpg')
|
763
|
+
signed_request.body.should include('size=original')
|
764
|
+
parameters = ::Signet::OAuth1.parse_authorization_header(
|
765
|
+
authorization_header
|
766
|
+
).inject({}) { |h,(k,v)| h[k]=v; h }
|
767
|
+
parameters.should_not have_key('oauth_client_credential_key')
|
768
|
+
parameters.should_not have_key('oauth_temporary_credential_key')
|
769
|
+
parameters.should_not have_key('oauth_token_credential_key')
|
770
|
+
parameters.should_not have_key('oauth_callback')
|
771
|
+
parameters['oauth_nonce'].should =~ /^\w+$/
|
772
|
+
parameters['oauth_timestamp'].should =~ /^\d+$/
|
773
|
+
parameters['oauth_signature_method'].should == 'HMAC-SHA1'
|
774
|
+
parameters['oauth_consumer_key'].should == @client.client_credential_key
|
775
|
+
parameters['oauth_token'].should == @client.token_credential_key
|
776
|
+
parameters['oauth_signature'].should =~ /^[a-zA-Z0-9\=\/\+]+$/
|
777
|
+
parameters['oauth_version'].should == '1.0'
|
778
|
+
end
|
779
|
+
end
|
780
|
+
end
|
693
781
|
end
|
@@ -191,6 +191,16 @@ describe Signet::OAuth2::Client, 'configured for Google userinfo API' do
|
|
191
191
|
end).should raise_error(TypeError)
|
192
192
|
end
|
193
193
|
|
194
|
+
it 'should include extension parameters in token request' do
|
195
|
+
@client.grant_type = 'urn:ietf:params:oauth:grant-type:saml2-bearer'
|
196
|
+
@client.extension_parameters['assertion'] =
|
197
|
+
'PEFzc2VydGlvbiBJc3N1ZUluc3RhbnQ9IjIwMTEtMDU'
|
198
|
+
|
199
|
+
request = @client.generate_access_token_request
|
200
|
+
params = Addressable::URI.form_unencode(request.body)
|
201
|
+
params.should include(['assertion', 'PEFzc2VydGlvbiBJc3N1ZUluc3RhbnQ9IjIwMTEtMDU'])
|
202
|
+
end
|
203
|
+
|
194
204
|
it 'should allow the token to be updated' do
|
195
205
|
issued_at = Time.now
|
196
206
|
@client.update_token!(
|
@@ -248,20 +258,6 @@ describe Signet::OAuth2::Client, 'configured for Google userinfo API' do
|
|
248
258
|
end).should raise_error(ArgumentError)
|
249
259
|
end
|
250
260
|
|
251
|
-
it 'should raise an error if client ID is missing' do
|
252
|
-
@client.client_secret = 'secret-12345'
|
253
|
-
(lambda do
|
254
|
-
@client.fetch_access_token!
|
255
|
-
end).should raise_error(ArgumentError)
|
256
|
-
end
|
257
|
-
|
258
|
-
it 'should raise an error if client secret is missing' do
|
259
|
-
@client.client_id = 'client-12345'
|
260
|
-
(lambda do
|
261
|
-
@client.fetch_access_token!
|
262
|
-
end).should raise_error(ArgumentError)
|
263
|
-
end
|
264
|
-
|
265
261
|
it 'should raise an error if unauthorized' do
|
266
262
|
@client.client_id = 'client-12345'
|
267
263
|
@client.client_secret = 'secret-12345'
|
@@ -488,20 +484,6 @@ JSON
|
|
488
484
|
end).should raise_error(ArgumentError)
|
489
485
|
end
|
490
486
|
|
491
|
-
it 'should raise an error if a bogus request body is supplied' do
|
492
|
-
@client.client_id = 'client-12345'
|
493
|
-
@client.client_secret = 'secret-12345'
|
494
|
-
@client.access_token = '12345'
|
495
|
-
(lambda do
|
496
|
-
@client.generate_authenticated_request(
|
497
|
-
:realm => 'Example',
|
498
|
-
:method => 'POST',
|
499
|
-
:uri => 'http://www.example.com/',
|
500
|
-
:body => :bogus
|
501
|
-
)
|
502
|
-
end).should raise_error(TypeError)
|
503
|
-
end
|
504
|
-
|
505
487
|
it 'should raise an error if the client does not have an access token' do
|
506
488
|
@client.client_id = 'client-12345'
|
507
489
|
@client.client_secret = 'secret-12345'
|
data/tasks/gem.rake
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require "rubygems/package_task"
|
2
2
|
|
3
3
|
namespace :gem do
|
4
4
|
GEM_SPEC = Gem::Specification.new do |s|
|
@@ -14,7 +14,6 @@ namespace :gem do
|
|
14
14
|
s.homepage = PKG_HOMEPAGE
|
15
15
|
s.summary = PKG_SUMMARY
|
16
16
|
s.description = PKG_DESCRIPTION
|
17
|
-
s.rubyforge_project = RUBY_FORGE_PROJECT
|
18
17
|
|
19
18
|
s.files = PKG_FILES.to_a
|
20
19
|
|
@@ -30,12 +29,11 @@ namespace :gem do
|
|
30
29
|
s.add_development_dependency("rake", "~> 0.8.3")
|
31
30
|
s.add_development_dependency("rspec", "~> 1.1.11")
|
32
31
|
s.add_development_dependency("launchy", "~> 2.0.0")
|
33
|
-
s.add_development_dependency("diff-lcs", "~> 1.1.2")
|
34
32
|
|
35
33
|
s.require_path = "lib"
|
36
34
|
end
|
37
35
|
|
38
|
-
|
36
|
+
Gem::PackageTask.new(GEM_SPEC) do |p|
|
39
37
|
p.gem_spec = GEM_SPEC
|
40
38
|
p.need_tar = true
|
41
39
|
p.need_zip = true
|
data/tasks/wiki.rake
CHANGED
metadata
CHANGED
@@ -1,162 +1,102 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: signet
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 2
|
10
|
-
version: 0.3.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.3
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Bob Aman
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-05-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: addressable
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2160769840 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
18
|
+
requirements:
|
27
19
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 1
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 2
|
33
|
-
- 3
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 2.2.3
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: faraday
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *2160769840
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: faraday
|
27
|
+
requirement: &2160769240 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
29
|
+
requirements:
|
43
30
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 3
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 7
|
49
|
-
- 0
|
31
|
+
- !ruby/object:Gem::Version
|
50
32
|
version: 0.7.0
|
51
33
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: multi_json
|
55
34
|
prerelease: false
|
56
|
-
|
35
|
+
version_requirements: *2160769240
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: multi_json
|
38
|
+
requirement: &2160768620 !ruby/object:Gem::Requirement
|
57
39
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
hash: 23
|
62
|
-
segments:
|
63
|
-
- 1
|
64
|
-
- 0
|
65
|
-
- 0
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
66
43
|
version: 1.0.0
|
67
44
|
type: :runtime
|
68
|
-
version_requirements: *id003
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: jwt
|
71
45
|
prerelease: false
|
72
|
-
|
46
|
+
version_requirements: *2160768620
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: jwt
|
49
|
+
requirement: &2160768040 !ruby/object:Gem::Requirement
|
73
50
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
hash: 19
|
78
|
-
segments:
|
79
|
-
- 0
|
80
|
-
- 1
|
81
|
-
- 4
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
82
54
|
version: 0.1.4
|
83
55
|
type: :runtime
|
84
|
-
version_requirements: *id004
|
85
|
-
- !ruby/object:Gem::Dependency
|
86
|
-
name: rake
|
87
56
|
prerelease: false
|
88
|
-
|
57
|
+
version_requirements: *2160768040
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rake
|
60
|
+
requirement: &2160767280 !ruby/object:Gem::Requirement
|
89
61
|
none: false
|
90
|
-
requirements:
|
62
|
+
requirements:
|
91
63
|
- - ~>
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
hash: 57
|
94
|
-
segments:
|
95
|
-
- 0
|
96
|
-
- 8
|
97
|
-
- 3
|
64
|
+
- !ruby/object:Gem::Version
|
98
65
|
version: 0.8.3
|
99
66
|
type: :development
|
100
|
-
version_requirements: *id005
|
101
|
-
- !ruby/object:Gem::Dependency
|
102
|
-
name: rspec
|
103
67
|
prerelease: false
|
104
|
-
|
68
|
+
version_requirements: *2160767280
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: &2160766640 !ruby/object:Gem::Requirement
|
105
72
|
none: false
|
106
|
-
requirements:
|
73
|
+
requirements:
|
107
74
|
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
hash: 5
|
110
|
-
segments:
|
111
|
-
- 1
|
112
|
-
- 1
|
113
|
-
- 11
|
75
|
+
- !ruby/object:Gem::Version
|
114
76
|
version: 1.1.11
|
115
77
|
type: :development
|
116
|
-
version_requirements: *id006
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: launchy
|
119
78
|
prerelease: false
|
120
|
-
|
79
|
+
version_requirements: *2160766640
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: launchy
|
82
|
+
requirement: &2160766000 !ruby/object:Gem::Requirement
|
121
83
|
none: false
|
122
|
-
requirements:
|
84
|
+
requirements:
|
123
85
|
- - ~>
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
hash: 15
|
126
|
-
segments:
|
127
|
-
- 2
|
128
|
-
- 0
|
129
|
-
- 0
|
86
|
+
- !ruby/object:Gem::Version
|
130
87
|
version: 2.0.0
|
131
88
|
type: :development
|
132
|
-
version_requirements: *id007
|
133
|
-
- !ruby/object:Gem::Dependency
|
134
|
-
name: diff-lcs
|
135
89
|
prerelease: false
|
136
|
-
|
137
|
-
|
138
|
-
requirements:
|
139
|
-
- - ~>
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
hash: 23
|
142
|
-
segments:
|
143
|
-
- 1
|
144
|
-
- 1
|
145
|
-
- 2
|
146
|
-
version: 1.1.2
|
147
|
-
type: :development
|
148
|
-
version_requirements: *id008
|
149
|
-
description: |
|
150
|
-
Signet is an OAuth 1.0 / OAuth 2.0 implementation.
|
90
|
+
version_requirements: *2160766000
|
91
|
+
description: ! 'Signet is an OAuth 1.0 / OAuth 2.0 implementation.
|
151
92
|
|
93
|
+
'
|
152
94
|
email: bobaman@google.com
|
153
95
|
executables: []
|
154
|
-
|
155
96
|
extensions: []
|
156
|
-
|
157
|
-
extra_rdoc_files:
|
97
|
+
extra_rdoc_files:
|
158
98
|
- README.md
|
159
|
-
files:
|
99
|
+
files:
|
160
100
|
- lib/compat/digest/hmac.rb
|
161
101
|
- lib/compat/securerandom.rb
|
162
102
|
- lib/signet/errors.rb
|
@@ -184,50 +124,40 @@ files:
|
|
184
124
|
- tasks/gem.rake
|
185
125
|
- tasks/git.rake
|
186
126
|
- tasks/metrics.rake
|
187
|
-
- tasks/rdoc.rake
|
188
|
-
- tasks/rubyforge.rake
|
189
127
|
- tasks/spec.rake
|
190
128
|
- tasks/wiki.rake
|
191
129
|
- tasks/yard.rake
|
192
130
|
- website/index.html
|
193
131
|
- CHANGELOG.md
|
132
|
+
- Gemfile
|
133
|
+
- Gemfile.lock
|
194
134
|
- LICENSE
|
195
135
|
- Rakefile
|
196
136
|
- README.md
|
197
|
-
|
198
|
-
homepage: http://signet.rubyforge.org/
|
137
|
+
homepage: http://code.google.com/p/oauth-signet/
|
199
138
|
licenses: []
|
200
|
-
|
201
139
|
post_install_message:
|
202
|
-
rdoc_options:
|
140
|
+
rdoc_options:
|
203
141
|
- --main
|
204
142
|
- README.md
|
205
|
-
require_paths:
|
143
|
+
require_paths:
|
206
144
|
- lib
|
207
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
208
146
|
none: false
|
209
|
-
requirements:
|
210
|
-
- -
|
211
|
-
- !ruby/object:Gem::Version
|
212
|
-
|
213
|
-
|
214
|
-
- 0
|
215
|
-
version: "0"
|
216
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ! '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
152
|
none: false
|
218
|
-
requirements:
|
219
|
-
- -
|
220
|
-
- !ruby/object:Gem::Version
|
221
|
-
|
222
|
-
segments:
|
223
|
-
- 0
|
224
|
-
version: "0"
|
153
|
+
requirements:
|
154
|
+
- - ! '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
225
157
|
requirements: []
|
226
|
-
|
227
|
-
|
228
|
-
rubygems_version: 1.3.7
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 1.8.15
|
229
160
|
signing_key:
|
230
161
|
specification_version: 3
|
231
162
|
summary: Package Summary
|
232
163
|
test_files: []
|
233
|
-
|
data/tasks/rdoc.rake
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require "rake/rdoctask"
|
2
|
-
|
3
|
-
namespace :doc do
|
4
|
-
desc "Generate RDoc documentation"
|
5
|
-
Rake::RDocTask.new do |rdoc|
|
6
|
-
rdoc.rdoc_dir = "doc"
|
7
|
-
rdoc.title = "#{PKG_NAME}-#{PKG_VERSION} Documentation"
|
8
|
-
rdoc.options << "--line-numbers" << "--inline-source" <<
|
9
|
-
"--accessor" << "cattr_accessor=object" << "--charset" << "utf-8"
|
10
|
-
rdoc.template = "#{ENV["template"]}.rb" if ENV["template"]
|
11
|
-
rdoc.rdoc_files.include("README.md", "CHANGELOG.md", "LICENSE")
|
12
|
-
rdoc.rdoc_files.include("lib/**/*.rb")
|
13
|
-
end
|
14
|
-
|
15
|
-
desc "Generate ri locally for testing"
|
16
|
-
task :ri do
|
17
|
-
sh "rdoc --ri -o ri ."
|
18
|
-
end
|
19
|
-
|
20
|
-
desc "Remove ri products"
|
21
|
-
task :clobber_ri do
|
22
|
-
rm_r "ri" rescue nil
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
task "clobber" => ["doc:clobber_rdoc", "doc:clobber_ri"]
|
data/tasks/rubyforge.rake
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
namespace :gem do
|
2
|
-
desc 'Package and upload to RubyForge'
|
3
|
-
task :release => ["gem:package"] do |t|
|
4
|
-
require 'rubyforge'
|
5
|
-
|
6
|
-
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
|
7
|
-
abort "Versions don't match #{v} vs #{PROJ.version}" if v != PKG_VERSION
|
8
|
-
pkg = "pkg/#{GEM_SPEC.full_name}"
|
9
|
-
|
10
|
-
rf = RubyForge.new
|
11
|
-
rf.configure
|
12
|
-
puts 'Logging in...'
|
13
|
-
rf.login
|
14
|
-
|
15
|
-
c = rf.userconfig
|
16
|
-
changelog = File.open("CHANGELOG.md") { |file| file.read }
|
17
|
-
c['release_changes'] = changelog
|
18
|
-
c['preformatted'] = true
|
19
|
-
|
20
|
-
files = ["#{pkg}.tgz", "#{pkg}.zip", "#{pkg}.gem"]
|
21
|
-
|
22
|
-
puts "Releasing #{PKG_NAME} v. #{PKG_VERSION}"
|
23
|
-
rf.add_release RUBY_FORGE_PROJECT, PKG_NAME, PKG_VERSION, *files
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
namespace :doc do
|
28
|
-
desc "Publish RDoc to RubyForge"
|
29
|
-
task :release => ["doc:yard"] do
|
30
|
-
require "rake/contrib/sshpublisher"
|
31
|
-
require "yaml"
|
32
|
-
|
33
|
-
config = YAML.load(
|
34
|
-
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
35
|
-
)
|
36
|
-
host = "#{config['username']}@rubyforge.org"
|
37
|
-
remote_dir = RUBY_FORGE_PATH + "/api"
|
38
|
-
local_dir = "doc"
|
39
|
-
system("mkdir -p website/api")
|
40
|
-
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
namespace :spec do
|
45
|
-
desc "Publish specdoc to RubyForge"
|
46
|
-
task :release => ["spec:specdoc"] do
|
47
|
-
require "rake/contrib/sshpublisher"
|
48
|
-
require "yaml"
|
49
|
-
|
50
|
-
config = YAML.load(
|
51
|
-
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
52
|
-
)
|
53
|
-
host = "#{config['username']}@rubyforge.org"
|
54
|
-
remote_dir = RUBY_FORGE_PATH + "/specdoc"
|
55
|
-
local_dir = "specdoc"
|
56
|
-
system("mkdir -p website/specdoc")
|
57
|
-
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
58
|
-
end
|
59
|
-
|
60
|
-
namespace :rcov do
|
61
|
-
desc "Publish coverage report to RubyForge"
|
62
|
-
task :release => ["spec:rcov"] do
|
63
|
-
require "rake/contrib/sshpublisher"
|
64
|
-
require "yaml"
|
65
|
-
|
66
|
-
config = YAML.load(
|
67
|
-
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
68
|
-
)
|
69
|
-
host = "#{config['username']}@rubyforge.org"
|
70
|
-
remote_dir = RUBY_FORGE_PATH + "/coverage"
|
71
|
-
local_dir = "coverage"
|
72
|
-
system("mkdir -p website/coverage")
|
73
|
-
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
namespace :website do
|
79
|
-
desc "Publish website to RubyForge"
|
80
|
-
task :init do
|
81
|
-
require "rake/contrib/sshpublisher"
|
82
|
-
require "yaml"
|
83
|
-
|
84
|
-
config = YAML.load(
|
85
|
-
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
86
|
-
)
|
87
|
-
host = "#{config['username']}@rubyforge.org"
|
88
|
-
remote_dir = RUBY_FORGE_PATH
|
89
|
-
local_dir = "website"
|
90
|
-
system("mkdir -p website/api")
|
91
|
-
system("mkdir -p website/specdoc")
|
92
|
-
system("mkdir -p website/coverage")
|
93
|
-
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
94
|
-
end
|
95
|
-
|
96
|
-
desc "Publish website to RubyForge"
|
97
|
-
task :release => [
|
98
|
-
"website:init", "doc:release", "spec:release", "spec:rcov:release"
|
99
|
-
]
|
100
|
-
end
|