google-api-client 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,58 @@
1
+ # Copyright 2012 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'spec_helper'
16
+
17
+ require 'google/api_client'
18
+
19
+ describe Google::APIClient::JWTAsserter do
20
+
21
+ before do
22
+ @key = OpenSSL::PKey::RSA.new 2048
23
+ end
24
+
25
+ it 'should generate valid JWTs' do
26
+ asserter = Google::APIClient::JWTAsserter.new('client1', 'scope1 scope2', @key)
27
+ jwt = asserter.to_jwt
28
+ jwt.should_not == nil
29
+
30
+ claim = JWT.decode(jwt, @key.public_key, true)
31
+ claim["iss"].should == 'client1'
32
+ claim["scope"].should == 'scope1 scope2'
33
+ end
34
+
35
+ it 'should send valid access token request' do
36
+ stubs = Faraday::Adapter::Test::Stubs.new do |stub|
37
+ stub.post('/o/oauth2/token') do |env|
38
+ params = Addressable::URI.form_unencode(env[:body])
39
+ JWT.decode(params.assoc("assertion").last, @key.public_key)
40
+ params.assoc("grant_type").should == ['grant_type','urn:ietf:params:oauth:grant-type:jwt-bearer']
41
+ [200, {}, '{
42
+ "access_token" : "1/abcdef1234567890",
43
+ "token_type" : "Bearer",
44
+ "expires_in" : 3600
45
+ }']
46
+ end
47
+ end
48
+ connection = Faraday.new(:url => 'https://accounts.google.com') do |builder|
49
+ builder.adapter(:test, stubs)
50
+ end
51
+
52
+ asserter = Google::APIClient::JWTAsserter.new('client1', 'scope1 scope2', @key)
53
+ auth = asserter.authorize(nil, { :connection => connection})
54
+ auth.should_not == nil?
55
+ auth.access_token.should == "1/abcdef1234567890"
56
+ end
57
+ end
58
+
@@ -108,4 +108,34 @@ describe Google::APIClient do
108
108
  # TODO
109
109
  it_should_behave_like 'configurable user agent'
110
110
  end
111
+
112
+ describe 'when executing requests' do
113
+ before do
114
+ @client.authorization = :oauth_2
115
+ @connection = Faraday.new(:url => 'https://www.googleapis.com') do |builder|
116
+ stubs = Faraday::Adapter::Test::Stubs.new do |stub|
117
+ stub.get('/test') do |env|
118
+ env[:request_headers]['Authorization'].should == 'Bearer 12345'
119
+ end
120
+ end
121
+ builder.adapter(:test, stubs)
122
+ end
123
+ end
124
+
125
+ it 'should use default authorization' do
126
+ @client.authorization.access_token = "12345"
127
+ @client.execute(:http_method => :get,
128
+ :uri => 'https://www.googleapis.com/test',
129
+ :connection => @connection)
130
+ end
131
+
132
+ it 'should use request scoped authorization when provided' do
133
+ @client.authorization.access_token = "abcdef"
134
+ new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
135
+ @client.execute(:http_method => :get,
136
+ :uri => 'https://www.googleapis.com/test',
137
+ :connection => @connection,
138
+ :authorization => new_auth)
139
+ end
140
+ end
111
141
  end
data/tasks/gem.rake CHANGED
@@ -24,12 +24,13 @@ namespace :gem do
24
24
  s.rdoc_options.concat ['--main', 'README.md']
25
25
 
26
26
  # Dependencies used in the main library
27
- s.add_runtime_dependency('signet', '>= 0.3.1')
27
+ s.add_runtime_dependency('signet', '>= 0.3.4')
28
28
  s.add_runtime_dependency('addressable', '>= 2.2.3')
29
29
  s.add_runtime_dependency('autoparse', '>= 0.3.1')
30
30
  s.add_runtime_dependency('faraday', '~> 0.7.0')
31
- s.add_runtime_dependency('multi_json', '>= 1.0.0')
31
+ s.add_runtime_dependency('multi_json', '>= 1.3.0')
32
32
  s.add_runtime_dependency('extlib', '>= 0.9.15')
33
+ s.add_runtime_dependency('uuidtools', '>= 2.1.0')
33
34
 
34
35
  # Dependencies used in the CLI
35
36
  s.add_runtime_dependency('launchy', '>= 2.0.0')
@@ -40,7 +41,6 @@ namespace :gem do
40
41
  s.add_development_dependency('rake', '>= 0.9.0')
41
42
  s.add_development_dependency('rspec', '~> 1.2.9')
42
43
  s.add_development_dependency('rcov', '>= 0.9.9')
43
- s.add_development_dependency('diff-lcs', '>= 1.1.2')
44
44
 
45
45
  s.require_path = 'lib'
46
46
 
data/tasks/spec.rake CHANGED
@@ -47,7 +47,7 @@ namespace :spec do
47
47
 
48
48
  if RCOV_ENABLED
49
49
  RCov::VerifyTask.new(:verify) do |t|
50
- t.threshold = 100.0
50
+ t.threshold = 65.0
51
51
  t.index_html = 'coverage/index.html'
52
52
  end
53
53
 
@@ -76,8 +76,8 @@ namespace :spec do
76
76
  end
77
77
 
78
78
  if RCOV_ENABLED
79
- desc 'Alias to spec:verify'
80
- task 'spec' => 'spec:verify'
79
+ desc 'Alias to spec:rcov'
80
+ task 'spec' => 'spec:rcov'
81
81
  else
82
82
  desc 'Alias to spec:all'
83
83
  task 'spec' => 'spec:all'
data/tasks/wiki.rake CHANGED
@@ -1,4 +1,3 @@
1
- require 'google/api_client'
2
1
  require 'rake'
3
2
  require 'rake/clean'
4
3
 
@@ -18,6 +17,7 @@ the following Google APIs.
18
17
 
19
18
  WIKI
20
19
  preferred_apis = {}
20
+ require 'google/api_client'
21
21
  client = Google::APIClient.new
22
22
  for api in client.discovered_apis
23
23
  if !preferred_apis.has_key?(api.name)
metadata CHANGED
@@ -1,161 +1,162 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: google-api-client
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.4
4
5
  prerelease:
5
- version: 0.4.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Bob Aman
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-03-27 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-06-11 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: signet
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70297458293420 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 0.3.1
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.3.4
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: addressable
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70297458293420
25
+ - !ruby/object:Gem::Dependency
26
+ name: addressable
27
+ requirement: &70297458292140 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
34
32
  version: 2.2.3
35
33
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: autoparse
39
34
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70297458292140
36
+ - !ruby/object:Gem::Dependency
37
+ name: autoparse
38
+ requirement: &70297458291200 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
45
43
  version: 0.3.1
46
44
  type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: faraday
50
45
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70297458291200
47
+ - !ruby/object:Gem::Dependency
48
+ name: faraday
49
+ requirement: &70297458289620 !ruby/object:Gem::Requirement
52
50
  none: false
53
- requirements:
51
+ requirements:
54
52
  - - ~>
55
- - !ruby/object:Gem::Version
53
+ - !ruby/object:Gem::Version
56
54
  version: 0.7.0
57
55
  type: :runtime
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: multi_json
61
56
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *70297458289620
58
+ - !ruby/object:Gem::Dependency
59
+ name: multi_json
60
+ requirement: &70297458288680 !ruby/object:Gem::Requirement
63
61
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: 1.0.0
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: 1.3.0
68
66
  type: :runtime
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
- name: extlib
72
67
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *70297458288680
69
+ - !ruby/object:Gem::Dependency
70
+ name: extlib
71
+ requirement: &70297458287340 !ruby/object:Gem::Requirement
74
72
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
78
76
  version: 0.9.15
79
77
  type: :runtime
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
82
- name: launchy
83
78
  prerelease: false
84
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *70297458287340
80
+ - !ruby/object:Gem::Dependency
81
+ name: uuidtools
82
+ requirement: &70297458278880 !ruby/object:Gem::Requirement
85
83
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: 2.1.0
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *70297458278880
91
+ - !ruby/object:Gem::Dependency
92
+ name: launchy
93
+ requirement: &70297458275860 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
89
98
  version: 2.0.0
90
99
  type: :runtime
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
93
- name: sinatra
94
100
  prerelease: false
95
- requirement: &id008 !ruby/object:Gem::Requirement
101
+ version_requirements: *70297458275860
102
+ - !ruby/object:Gem::Dependency
103
+ name: sinatra
104
+ requirement: &70297458274500 !ruby/object:Gem::Requirement
96
105
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
100
109
  version: 1.2.0
101
110
  type: :development
102
- version_requirements: *id008
103
- - !ruby/object:Gem::Dependency
104
- name: rake
105
111
  prerelease: false
106
- requirement: &id009 !ruby/object:Gem::Requirement
112
+ version_requirements: *70297458274500
113
+ - !ruby/object:Gem::Dependency
114
+ name: rake
115
+ requirement: &70297458273640 !ruby/object:Gem::Requirement
107
116
  none: false
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
111
120
  version: 0.9.0
112
121
  type: :development
113
- version_requirements: *id009
114
- - !ruby/object:Gem::Dependency
115
- name: rspec
116
122
  prerelease: false
117
- requirement: &id010 !ruby/object:Gem::Requirement
123
+ version_requirements: *70297458273640
124
+ - !ruby/object:Gem::Dependency
125
+ name: rspec
126
+ requirement: &70297458272260 !ruby/object:Gem::Requirement
118
127
  none: false
119
- requirements:
128
+ requirements:
120
129
  - - ~>
121
- - !ruby/object:Gem::Version
130
+ - !ruby/object:Gem::Version
122
131
  version: 1.2.9
123
132
  type: :development
124
- version_requirements: *id010
125
- - !ruby/object:Gem::Dependency
126
- name: rcov
127
133
  prerelease: false
128
- requirement: &id011 !ruby/object:Gem::Requirement
134
+ version_requirements: *70297458272260
135
+ - !ruby/object:Gem::Dependency
136
+ name: rcov
137
+ requirement: &70297458264380 !ruby/object:Gem::Requirement
129
138
  none: false
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
133
142
  version: 0.9.9
134
143
  type: :development
135
- version_requirements: *id011
136
- - !ruby/object:Gem::Dependency
137
- name: diff-lcs
138
144
  prerelease: false
139
- requirement: &id012 !ruby/object:Gem::Requirement
140
- none: false
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: 1.1.2
145
- type: :development
146
- version_requirements: *id012
147
- description: |
148
- The Google API Ruby Client makes it trivial to discover and access supported
145
+ version_requirements: *70297458264380
146
+ description: ! 'The Google API Ruby Client makes it trivial to discover and access
147
+ supported
148
+
149
149
  APIs.
150
150
 
151
+ '
151
152
  email: bobaman@google.com
152
- executables:
153
+ executables:
153
154
  - google-api
154
155
  extensions: []
155
-
156
- extra_rdoc_files:
156
+ extra_rdoc_files:
157
157
  - README.md
158
- files:
158
+ files:
159
+ - lib/google/api_client/batch.rb
159
160
  - lib/google/api_client/client_secrets.rb
160
161
  - lib/google/api_client/discovery/api.rb
161
162
  - lib/google/api_client/discovery/media.rb
@@ -168,52 +169,56 @@ files:
168
169
  - lib/google/api_client/media.rb
169
170
  - lib/google/api_client/reference.rb
170
171
  - lib/google/api_client/result.rb
172
+ - lib/google/api_client/service_account.rb
171
173
  - lib/google/api_client/version.rb
172
174
  - lib/google/api_client.rb
173
175
  - lib/google/inflection.rb
176
+ - spec/fixtures/files/sample.txt
177
+ - spec/google/api_client/batch_spec.rb
174
178
  - spec/google/api_client/discovery_spec.rb
179
+ - spec/google/api_client/media_spec.rb
180
+ - spec/google/api_client/result_spec.rb
181
+ - spec/google/api_client/service_account_spec.rb
175
182
  - spec/google/api_client_spec.rb
176
183
  - spec/spec.opts
177
184
  - spec/spec_helper.rb
178
185
  - tasks/gem.rake
179
186
  - tasks/git.rake
180
187
  - tasks/metrics.rake
181
- - tasks/rdoc.rake
182
188
  - tasks/spec.rake
183
189
  - tasks/wiki.rake
184
190
  - tasks/yard.rake
185
191
  - CHANGELOG.md
192
+ - Gemfile
193
+ - Gemfile.lock
186
194
  - LICENSE
187
195
  - Rakefile
188
196
  - README.md
189
197
  - bin/google-api
190
198
  homepage: http://code.google.com/p/google-api-ruby-client/
191
199
  licenses: []
192
-
193
200
  post_install_message:
194
- rdoc_options:
201
+ rdoc_options:
195
202
  - --main
196
203
  - README.md
197
- require_paths:
204
+ require_paths:
198
205
  - lib
199
- required_ruby_version: !ruby/object:Gem::Requirement
206
+ required_ruby_version: !ruby/object:Gem::Requirement
200
207
  none: false
201
- requirements:
202
- - - ">="
203
- - !ruby/object:Gem::Version
204
- version: "0"
205
- required_rubygems_version: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - ! '>='
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
213
  none: false
207
- requirements:
208
- - - ">="
209
- - !ruby/object:Gem::Version
210
- version: "0"
214
+ requirements:
215
+ - - ! '>='
216
+ - !ruby/object:Gem::Version
217
+ version: '0'
211
218
  requirements: []
212
-
213
219
  rubyforge_project:
214
- rubygems_version: 1.8.15
220
+ rubygems_version: 1.8.10
215
221
  signing_key:
216
222
  specification_version: 3
217
223
  summary: Package Summary
218
224
  test_files: []
219
-