google-api-client 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/google-api-client.gemspec +4 -3
  4. data/lib/google/api_client/client_secrets.rb +1 -1
  5. data/lib/google/apis/core/download.rb +10 -1
  6. data/lib/google/apis/core/json_representation.rb +2 -2
  7. data/lib/google/apis/version.rb +1 -1
  8. data/samples/cli/.env +4 -0
  9. data/samples/web/.env +2 -0
  10. data/samples/web/views/home.erb +0 -1
  11. metadata +5 -71
  12. data/api_names_out.yaml +0 -28434
  13. data/generated/google/apis/sheets_v1.rb +0 -43
  14. data/generated/google/apis/sheets_v1/classes.rb +0 -4542
  15. data/generated/google/apis/sheets_v1/representations.rb +0 -1703
  16. data/generated/google/apis/sheets_v1/service.rb +0 -363
  17. data/script/generate +0 -105
  18. data/script/package +0 -8
  19. data/script/release +0 -15
  20. data/spec/fixtures/files/api_names.yaml +0 -3
  21. data/spec/fixtures/files/auth_stored_credentials.json +0 -8
  22. data/spec/fixtures/files/child/.gitignore +0 -0
  23. data/spec/fixtures/files/client_secrets.json +0 -1
  24. data/spec/fixtures/files/invalid.json +0 -1
  25. data/spec/fixtures/files/test.blah +0 -1
  26. data/spec/fixtures/files/test.txt +0 -1
  27. data/spec/fixtures/files/test_api.json +0 -440
  28. data/spec/google/api_client/auth/storage_spec.rb +0 -120
  29. data/spec/google/api_client/auth/storages/file_store_spec.rb +0 -39
  30. data/spec/google/api_client/auth/storages/redis_store_spec.rb +0 -68
  31. data/spec/google/api_client/client_secrets_spec.rb +0 -389
  32. data/spec/google/apis/core/api_command_spec.rb +0 -209
  33. data/spec/google/apis/core/batch_spec.rb +0 -142
  34. data/spec/google/apis/core/download_spec.rb +0 -103
  35. data/spec/google/apis/core/hashable_spec.rb +0 -60
  36. data/spec/google/apis/core/http_command_spec.rb +0 -303
  37. data/spec/google/apis/core/json_representation_spec.rb +0 -199
  38. data/spec/google/apis/core/service_spec.rb +0 -313
  39. data/spec/google/apis/core/upload_spec.rb +0 -300
  40. data/spec/google/apis/generated_spec.rb +0 -27
  41. data/spec/google/apis/generator/generator_spec.rb +0 -324
  42. data/spec/google/apis/logging_spec.rb +0 -100
  43. data/spec/google/apis/options_spec.rb +0 -40
  44. data/spec/integration_tests/adsense_spec.rb +0 -29
  45. data/spec/integration_tests/drive_spec.rb +0 -35
  46. data/spec/integration_tests/pubsub_spec.rb +0 -48
  47. data/spec/integration_tests/url_shortener_spec.rb +0 -45
  48. data/spec/spec_helper.rb +0 -153
  49. data/spec/spec_helper/load_path_spec.rb +0 -33
@@ -1,120 +0,0 @@
1
- require 'spec_helper'
2
-
3
- require 'google/api_client/auth/storage'
4
-
5
- describe Google::APIClient::Storage do
6
- let(:root_path) { File.expand_path(File.join(__FILE__, '..', '..', '..')) }
7
- let(:json_file) { File.expand_path(File.join(root_path, 'fixtures', 'files', 'auth_stored_credentials.json')) }
8
-
9
- let(:store) { double }
10
- let(:client_stub) { double }
11
- subject { Google::APIClient::Storage.new(store) }
12
-
13
- describe 'authorize' do
14
- it 'should authorize' do
15
- expect(subject).to respond_to(:authorization)
16
- expect(subject.store).to be == store
17
- end
18
- end
19
-
20
- describe 'authorize' do
21
- describe 'with credentials' do
22
-
23
- it 'should initialize a new OAuth Client' do
24
- expect(subject).to receive(:load_credentials).and_return({:first => 'a dummy'})
25
- expect(client_stub).to receive(:issued_at=)
26
- expect(client_stub).to receive(:expired?).and_return(false)
27
- expect(Signet::OAuth2::Client).to receive(:new).and_return(client_stub)
28
- expect(subject).not_to receive(:refresh_authorization)
29
- subject.authorize
30
- end
31
-
32
- it 'should refresh authorization' do
33
- expect(subject).to receive(:load_credentials).and_return({:first => 'a dummy'})
34
- expect(client_stub).to receive(:issued_at=)
35
- expect(client_stub).to receive(:expired?).and_return(true)
36
- expect(Signet::OAuth2::Client).to receive(:new).and_return(client_stub)
37
- expect(subject).to receive(:refresh_authorization)
38
- auth = subject.authorize
39
- expect(auth).to be == subject.authorization
40
- expect(auth).not_to be_nil
41
- end
42
- end
43
-
44
- describe 'without credentials' do
45
-
46
- it 'should return nil' do
47
- expect(subject.authorization).to be_nil
48
- expect(subject).to receive(:load_credentials).and_return({})
49
- expect(subject.authorize).to be_nil
50
- expect(subject.authorization).to be_nil
51
- end
52
- end
53
- end
54
-
55
- describe 'write_credentials' do
56
- it 'should call store to write credentials' do
57
- authorization_stub = double
58
- expect(authorization_stub).to receive(:refresh_token).and_return(true)
59
- expect(subject).to receive(:credentials_hash)
60
- expect(subject.store).to receive(:write_credentials)
61
- subject.write_credentials(authorization_stub)
62
- expect(subject.authorization).to be == authorization_stub
63
- end
64
-
65
- it 'should not call store to write credentials' do
66
- expect(subject).not_to receive(:credentials_hash)
67
- expect(subject.store).not_to receive(:write_credentials)
68
- expect {
69
- subject.write_credentials()
70
- }.not_to raise_error
71
- end
72
- it 'should not call store to write credentials' do
73
- expect(subject).not_to receive(:credentials_hash)
74
- expect(subject.store).not_to receive(:write_credentials)
75
- expect {
76
- subject.write_credentials('something')
77
- }.not_to raise_error
78
- end
79
-
80
- end
81
-
82
- describe 'refresh_authorization' do
83
- it 'should call refresh and write credentials' do
84
- expect(subject).to receive(:write_credentials)
85
- authorization_stub = double
86
- expect(subject).to receive(:authorization).and_return(authorization_stub)
87
- expect(authorization_stub).to receive(:refresh!).and_return(true)
88
- subject.refresh_authorization
89
- end
90
- end
91
-
92
- describe 'load_credentials' do
93
- it 'should call store to load credentials' do
94
- expect(subject.store).to receive(:load_credentials)
95
- subject.send(:load_credentials)
96
- end
97
- end
98
-
99
- describe 'credentials_hash' do
100
- it 'should return an hash' do
101
- authorization_stub = double
102
- expect(authorization_stub).to receive(:access_token)
103
- expect(authorization_stub).to receive(:client_id)
104
- expect(authorization_stub).to receive(:client_secret)
105
- expect(authorization_stub).to receive(:expires_in)
106
- expect(authorization_stub).to receive(:refresh_token)
107
- expect(authorization_stub).to receive(:issued_at).and_return('100')
108
- allow(subject).to receive(:authorization).and_return(authorization_stub)
109
- credentials = subject.send(:credentials_hash)
110
- expect(credentials).to include(:access_token)
111
- expect(credentials).to include(:authorization_uri)
112
- expect(credentials).to include(:client_id)
113
- expect(credentials).to include(:client_secret)
114
- expect(credentials).to include(:expires_in)
115
- expect(credentials).to include(:refresh_token)
116
- expect(credentials).to include(:token_credential_uri)
117
- expect(credentials).to include(:issued_at)
118
- end
119
- end
120
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- require 'google/api_client/auth/storages/file_store'
4
-
5
- describe Google::APIClient::FileStore do
6
- let(:root_path) { File.expand_path(File.join(__FILE__, '..','..','..', '..','..')) }
7
- let(:json_file) { File.expand_path(File.join(root_path, 'fixtures', 'files', 'auth_stored_credentials.json')) }
8
-
9
- let(:credentials_hash) {{
10
- "access_token"=>"my_access_token",
11
- "authorization_uri"=>"https://accounts.google.com/o/oauth2/auth",
12
- "client_id"=>"123456_test_client_id@.apps.googleusercontent.com",
13
- "client_secret"=>"123456_client_secret",
14
- "expires_in"=>3600,
15
- "refresh_token"=>"my_refresh_token",
16
- "token_credential_uri"=>"https://accounts.google.com/o/oauth2/token",
17
- "issued_at"=>1384440275
18
- }}
19
-
20
- subject{Google::APIClient::FileStore.new('a file path')}
21
-
22
- it 'should have a path' do
23
- expect(subject.path).to be == 'a file path'
24
- subject.path = 'an other file path'
25
- expect(subject.path).to be == 'an other file path'
26
- end
27
-
28
- it 'should load credentials' do
29
- subject.path = json_file
30
- credentials = subject.load_credentials
31
- expect(credentials).to include('access_token', 'authorization_uri', 'refresh_token')
32
- end
33
-
34
- it 'should write credentials' do
35
- io_stub = StringIO.new
36
- expect(subject).to receive(:open).and_return(io_stub)
37
- subject.write_credentials(credentials_hash)
38
- end
39
- end
@@ -1,68 +0,0 @@
1
- require 'spec_helper'
2
-
3
- require 'google/api_client/auth/storages/redis_store'
4
-
5
- describe Google::APIClient::RedisStore do
6
- let(:root_path) { File.expand_path(File.join(__FILE__, '..', '..', '..', '..', '..')) }
7
- let(:json_file) { File.expand_path(File.join(root_path, 'fixtures', 'files', 'auth_stored_credentials.json')) }
8
- let(:redis) {double}
9
-
10
- let(:credentials_hash) { {
11
- "access_token" => "my_access_token",
12
- "authorization_uri" => "https://accounts.google.com/o/oauth2/auth",
13
- "client_id" => "123456_test_client_id@.apps.googleusercontent.com",
14
- "client_secret" => "123456_client_secret",
15
- "expires_in" => 3600,
16
- "refresh_token" => "my_refresh_token",
17
- "token_credential_uri" => "https://accounts.google.com/o/oauth2/token",
18
- "issued_at" => 1384440275
19
- } }
20
-
21
- subject { Google::APIClient::RedisStore.new('a redis instance') }
22
-
23
- it 'should have a redis instance' do
24
- expect(subject.redis).to be == 'a redis instance'
25
- subject.redis = 'an other redis instance'
26
- expect(subject.redis).to be == 'an other redis instance'
27
- end
28
-
29
- describe 'load_credentials' do
30
-
31
- it 'should load credentials' do
32
- subject.redis= redis
33
- expect(redis).to receive(:get).and_return(credentials_hash.to_json)
34
- expect(subject.load_credentials).to be == credentials_hash
35
- end
36
-
37
- it 'should return nil' do
38
- subject.redis= redis
39
- expect(redis).to receive(:get).and_return(nil)
40
- expect(subject.load_credentials).to be_nil
41
- end
42
- end
43
-
44
- describe 'redis_credentials_key' do
45
- context 'without given key' do
46
- it 'should return default key' do
47
- expect(subject.redis_credentials_key).to be == "google_api_credentials"
48
- end
49
- end
50
- context 'with given key' do
51
- let(:redis_store) { Google::APIClient::RedisStore.new('a redis instance', 'another_google_api_credentials') }
52
- it 'should use given key' do
53
- expect(redis_store.redis_credentials_key).to be == "another_google_api_credentials"
54
- end
55
- end
56
-
57
- end
58
-
59
- describe 'write credentials' do
60
-
61
- it 'should write credentials' do
62
- subject.redis= redis
63
- expect(redis).to receive(:set).and_return('ok')
64
- expect(subject.write_credentials(credentials_hash)).to be_truthy
65
- end
66
- end
67
-
68
- end
@@ -1,389 +0,0 @@
1
- # encoding:utf-8
2
-
3
- # Copyright 2013 Google Inc.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
- require 'spec_helper'
18
-
19
- require 'google/api_client/client_secrets'
20
-
21
- FIXTURES_PATH = File.expand_path('../../../fixtures', __FILE__)
22
-
23
- RSpec.describe Google::APIClient::ClientSecrets do
24
- describe '::new' do
25
- let(:filename) { File.join(FIXTURES_PATH, 'files', 'client_secrets.json') }
26
- let(:data) { File.open(filename, 'r') { |file| JSON.load(file.read) } }
27
-
28
- context 'without options' do
29
- subject { Google::APIClient::ClientSecrets.new(data) }
30
-
31
- describe 'existence of instance variables' do
32
- it '@access_token' do
33
- expect(subject).to respond_to(:access_token)
34
- end
35
- it '@authorization_uri' do
36
- expect(subject).to respond_to(:authorization_uri)
37
- end
38
- it '@client_id' do
39
- expect(subject).to respond_to(:client_id)
40
- end
41
- it '@client_secret' do
42
- expect(subject).to respond_to(:client_secret)
43
- end
44
- it '@expires_at' do
45
- expect(subject).to respond_to(:expires_at)
46
- end
47
- it '@expires_in' do
48
- expect(subject).to respond_to(:expires_in)
49
- end
50
- it '@id_token' do
51
- expect(subject).to respond_to(:id_token)
52
- end
53
- it '@issued_at' do
54
- expect(subject).to respond_to(:issued_at)
55
- end
56
- it '@javascript_origins' do
57
- expect(subject).to respond_to(:javascript_origins)
58
- end
59
- it '@redirect_uris' do
60
- expect(subject).to respond_to(:redirect_uris)
61
- end
62
- it '@refresh_token' do
63
- expect(subject).to respond_to(:refresh_token)
64
- end
65
- it '@token_credential_uri' do
66
- expect(subject).to respond_to(:token_credential_uri)
67
- end
68
- end
69
-
70
- describe 'value of instance variables' do
71
- it 'should set @access_token' do
72
- expect(subject.access_token).to be_nil
73
- end
74
- it 'should set @authorization_uri' do
75
- expect(subject.authorization_uri).to eq 'https://accounts.google.com/o/oauth2/auth'
76
- end
77
- it 'should set @client_id' do
78
- expect(subject.client_id).to eq '898243283568.apps.googleusercontent.com'
79
- end
80
- it 'should set @client_secret' do
81
- expect(subject.client_secret).to eq 'i8YaXdGgiQ4_KrTVNGsB7QP1'
82
- end
83
- it 'should set @expires_at' do
84
- expect(subject.expires_at).to be_nil
85
- end
86
- it 'should set @expires_in' do
87
- expect(subject.expires_in).to be_nil
88
- end
89
- it 'should set @flow' do
90
- expect(subject.flow).to eq 'installed'
91
- end
92
- it 'should set @id_token' do
93
- expect(subject.id_token).to be_nil
94
- end
95
- it 'should set @issued_at' do
96
- expect(subject.issued_at).to be_nil
97
- end
98
- it 'should set @javascript_origins' do
99
- expect(subject.javascript_origins).to eq []
100
- end
101
- it 'should set @redirect_uris' do
102
- expect(subject.redirect_uris).to eq []
103
- end
104
- it 'should set @refresh_token' do
105
- expect(subject.refresh_token).to be_nil
106
- end
107
- it 'should set @token_credential_uri' do
108
- expect(subject.token_credential_uri).to eq 'https://accounts.google.com/o/oauth2/token'
109
- end
110
- end
111
- end
112
-
113
- context 'with options' do
114
- context 'option keys are string' do
115
- let(:string_options) do
116
- { 'samples' =>
117
- {
118
- 'access_token' => 'sample_access_token',
119
- 'auth_uri' => 'sample_auth_uri',
120
- 'authorization_uri' => 'sample_authorization_uri',
121
- 'client_id' => 'sample_client_id',
122
- 'client_secret' => 'sample_client_secret',
123
- 'expires_at' => 'sample_expires_at',
124
- 'expires_in' => 'sample_expires_in',
125
- 'id_token' => 'sample_id_token',
126
- 'issued_at' => 'sample_issued_at',
127
- 'javascript_origin' => 'sample_javascript_origin',
128
- 'javascript_origins' => 'sample_javascript_origins',
129
- 'redirect_uris' => 'sample_redirect_uris',
130
- 'refresh_token' => 'sample_refresh_token',
131
- 'token_credential_uri' => 'sample_token_credential_uri',
132
- 'token_uri' => 'sample_token_uri' } }
133
- end
134
- subject { Google::APIClient::ClientSecrets.new(string_options) }
135
-
136
- describe 'existence of instance variables' do
137
- it '@access_token' do
138
- expect(subject).to respond_to(:access_token)
139
- end
140
- it '@authorization_uri' do
141
- expect(subject).to respond_to(:authorization_uri)
142
- end
143
- it '@client_id' do
144
- expect(subject).to respond_to(:client_id)
145
- end
146
- it '@client_secret' do
147
- expect(subject).to respond_to(:client_secret)
148
- end
149
- it '@expires_at' do
150
- expect(subject).to respond_to(:expires_at)
151
- end
152
- it '@expires_in' do
153
- expect(subject).to respond_to(:expires_in)
154
- end
155
- it '@id_token' do
156
- expect(subject).to respond_to(:id_token)
157
- end
158
- it '@issued_at' do
159
- expect(subject).to respond_to(:issued_at)
160
- end
161
- it '@javascript_origins' do
162
- expect(subject).to respond_to(:javascript_origins)
163
- end
164
- it '@redirect_uris' do
165
- expect(subject).to respond_to(:redirect_uris)
166
- end
167
- it '@refresh_token' do
168
- expect(subject).to respond_to(:refresh_token)
169
- end
170
- it '@token_credential_uri' do
171
- expect(subject).to respond_to(:token_credential_uri)
172
- end
173
- end
174
-
175
- describe 'value of instance variables' do
176
- it 'should set @access_token' do
177
- expect(subject.access_token).to eq 'sample_access_token'
178
- end
179
- it 'should set @authorization_uri' do
180
- expect(subject.authorization_uri).to eq 'sample_auth_uri'
181
- end
182
- it 'should set @client_id' do
183
- expect(subject.client_id).to eq 'sample_client_id'
184
- end
185
- it 'should set @client_secret' do
186
- expect(subject.client_secret).to eq 'sample_client_secret'
187
- end
188
- it 'should set @expires_at' do
189
- expect(subject.expires_at).to eq 'sample_expires_at'
190
- end
191
- it 'should set @expires_in' do
192
- expect(subject.expires_in).to eq 'sample_expires_in'
193
- end
194
- it 'should set @flow' do
195
- expect(subject.flow).to eq 'samples'
196
- end
197
- it 'should set @id_token' do
198
- expect(subject.id_token).to eq 'sample_id_token'
199
- end
200
- it 'should set @issued_at' do
201
- expect(subject.issued_at).to eq 'sample_issued_at'
202
- end
203
- it 'should set @javascript_origins' do
204
- expect(subject.javascript_origins).to eq 'sample_javascript_origins'
205
- end
206
- it 'should set @redirect_uris' do
207
- expect(subject.redirect_uris).to eq 'sample_redirect_uris'
208
- end
209
- it 'should set @refresh_token' do
210
- expect(subject.refresh_token).to eq 'sample_refresh_token'
211
- end
212
- it 'should set @token_credential_uri' do
213
- expect(subject.token_credential_uri).to eq 'sample_token_uri'
214
- end
215
- end
216
- end
217
-
218
- context 'option keys are symbol' do
219
- let(:symbol_options) do
220
- { 'samples' =>
221
- {
222
- access_token: 'sample_access_token',
223
- auth_uri: 'sample_auth_uri',
224
- authorization_uri: 'sample_authorization_uri',
225
- client_id: 'sample_client_id',
226
- client_secret: 'sample_client_secret',
227
- expires_at: 'sample_expires_at',
228
- expires_in: 'sample_expires_in',
229
- id_token: 'sample_id_token',
230
- issued_at: 'sample_issued_at',
231
- javascript_origin: 'sample_javascript_origin',
232
- javascript_origins: 'sample_javascript_origins',
233
- redirect_uris: 'sample_redirect_uris',
234
- refresh_token: 'sample_refresh_token',
235
- token_credential_uri: 'sample_token_credential_uri',
236
- token_uri: 'sample_token_uri' } }
237
- end
238
- subject { Google::APIClient::ClientSecrets.new(symbol_options) }
239
-
240
- describe 'existence of instance variables' do
241
- it '@access_token' do
242
- expect(subject).to respond_to(:access_token)
243
- end
244
- it '@authorization_uri' do
245
- expect(subject).to respond_to(:authorization_uri)
246
- end
247
- it '@client_id' do
248
- expect(subject).to respond_to(:client_id)
249
- end
250
- it '@client_secret' do
251
- expect(subject).to respond_to(:client_secret)
252
- end
253
- it '@expires_at' do
254
- expect(subject).to respond_to(:expires_at)
255
- end
256
- it '@expires_in' do
257
- expect(subject).to respond_to(:expires_in)
258
- end
259
- it '@id_token' do
260
- expect(subject).to respond_to(:id_token)
261
- end
262
- it '@issued_at' do
263
- expect(subject).to respond_to(:issued_at)
264
- end
265
- it '@javascript_origins' do
266
- expect(subject).to respond_to(:javascript_origins)
267
- end
268
- it '@redirect_uris' do
269
- expect(subject).to respond_to(:redirect_uris)
270
- end
271
- it '@refresh_token' do
272
- expect(subject).to respond_to(:refresh_token)
273
- end
274
- it '@token_credential_uri' do
275
- expect(subject).to respond_to(:token_credential_uri)
276
- end
277
- end
278
-
279
- describe 'value of instance variables' do
280
- it 'should set @access_token' do
281
- expect(subject.access_token).to eq 'sample_access_token'
282
- end
283
- it 'should set @authorization_uri' do
284
- expect(subject.authorization_uri).to eq 'sample_auth_uri'
285
- end
286
- it 'should set @client_id' do
287
- expect(subject.client_id).to eq 'sample_client_id'
288
- end
289
- it 'should set @client_secret' do
290
- expect(subject.client_secret).to eq 'sample_client_secret'
291
- end
292
- it 'should set @expires_at' do
293
- expect(subject.expires_at).to eq 'sample_expires_at'
294
- end
295
- it 'should set @expires_in' do
296
- expect(subject.expires_in).to eq 'sample_expires_in'
297
- end
298
- it 'should set @flow' do
299
- expect(subject.flow).to eq 'samples'
300
- end
301
- it 'should set @id_token' do
302
- expect(subject.id_token).to eq 'sample_id_token'
303
- end
304
- it 'should set @issued_at' do
305
- expect(subject.issued_at).to eq 'sample_issued_at'
306
- end
307
- it 'should set @javascript_origins' do
308
- expect(subject.javascript_origins).to eq 'sample_javascript_origins'
309
- end
310
- it 'should set @redirect_uris' do
311
- expect(subject.redirect_uris).to eq 'sample_redirect_uris'
312
- end
313
- it 'should set @refresh_token' do
314
- expect(subject.refresh_token).to eq 'sample_refresh_token'
315
- end
316
- it 'should set @token_credential_uri' do
317
- expect(subject.token_credential_uri).to eq 'sample_token_uri'
318
- end
319
- end
320
- end
321
- end
322
- end
323
-
324
- context 'with JSON file' do
325
- let(:file) { File.join(FIXTURES_PATH, 'files', 'client_secrets.json') }
326
- subject(:secrets) { Google::APIClient::ClientSecrets.load(file)}
327
-
328
- it 'should load the correct client ID' do
329
- expect(secrets.client_id).to be == '898243283568.apps.googleusercontent.com'
330
- end
331
-
332
- it 'should load the correct client secret' do
333
- expect(secrets.client_secret).to be == 'i8YaXdGgiQ4_KrTVNGsB7QP1'
334
- end
335
-
336
- context 'serialzed to hash' do
337
- subject(:hash) { secrets.to_hash }
338
- it 'should contain the flow as the first key' do
339
- expect(hash).to have_key "installed"
340
- end
341
-
342
- it 'should contain the client ID' do
343
- expect(hash["installed"]["client_id"]).to be == '898243283568.apps.googleusercontent.com'
344
- end
345
-
346
- it 'should contain the client secret' do
347
- expect(hash["installed"]["client_secret"]).to be == 'i8YaXdGgiQ4_KrTVNGsB7QP1'
348
- end
349
-
350
- it 'should remove empty value' do
351
- expect(hash["installed"]["redirect_uris"]).to be nil
352
- end
353
-
354
- it 'should remove nil values' do
355
- expect(hash["installed"]["issued_at"]).to be nil
356
- end
357
- end
358
- end
359
-
360
- context 'with no existing JSON file' do
361
- it 'should raise exception' do
362
- file = File.join(FIXTURES_PATH, 'files', 'no_file.json')
363
- expect { Google::APIClient::ClientSecrets.load(file) }.to raise_exception(Errno::ENOENT)
364
- end
365
- end
366
-
367
- context 'with invalid JSON file' do
368
- it 'should raise exception' do
369
- file = File.join(FIXTURES_PATH, 'files', 'invalid.json')
370
- expect { Google::APIClient::ClientSecrets.load(file) }.to raise_exception(JSON::ParserError)
371
- end
372
- end
373
-
374
- context 'with folder name, which have json file in parents' do
375
- it 'should load the correct client id' do
376
- folder = File.join(FIXTURES_PATH, 'files', 'child')
377
- secrets = Google::APIClient::ClientSecrets.load(folder)
378
- expect(secrets.client_id).to be == '898243283568.apps.googleusercontent.com'
379
- end
380
- end
381
-
382
- context 'with folder wihout client_secrets.json' do
383
- it "should raise exception", fakefs: true do
384
- FileUtils.mkdir("/tmp")
385
- expect { Google::APIClient::ClientSecrets.load('/tmp') }.to raise_exception(ArgumentError)
386
- end
387
- end
388
-
389
- end