browse-everything 0.15.1 → 0.16.0

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.
Files changed (76) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +61 -9
  3. data/.rubocop_todo.yml +2 -15
  4. data/.travis.yml +19 -19
  5. data/CONTRIBUTING.md +6 -6
  6. data/Gemfile +12 -8
  7. data/README.md +30 -0
  8. data/Rakefile +2 -1
  9. data/app/assets/javascripts/browse_everything/behavior.js.coffee +5 -0
  10. data/app/controllers/browse_everything_controller.rb +75 -23
  11. data/app/helpers/browse_everything_helper.rb +2 -8
  12. data/app/helpers/font_awesome_version_helper.rb +9 -8
  13. data/app/services/browse_everything_session.rb +10 -0
  14. data/app/services/browse_everything_session/provider_session.rb +42 -0
  15. data/app/services/browser_factory.rb +25 -0
  16. data/app/views/browse_everything/_files.html.erb +56 -6
  17. data/browse-everything.gemspec +29 -25
  18. data/config/routes.rb +7 -2
  19. data/lib/browse-everything.rb +2 -0
  20. data/lib/browse_everything.rb +45 -12
  21. data/lib/browse_everything/auth/google/credentials.rb +28 -0
  22. data/lib/browse_everything/auth/google/request_parameters.rb +61 -0
  23. data/lib/browse_everything/browser.rb +11 -4
  24. data/lib/browse_everything/driver/authentication_factory.rb +22 -0
  25. data/lib/browse_everything/driver/base.rb +72 -19
  26. data/lib/browse_everything/driver/box.rb +46 -17
  27. data/lib/browse_everything/driver/dropbox.rb +36 -10
  28. data/lib/browse_everything/driver/file_system.rb +14 -26
  29. data/lib/browse_everything/driver/google_drive.rb +187 -54
  30. data/lib/browse_everything/driver/s3.rb +81 -75
  31. data/lib/browse_everything/engine.rb +3 -2
  32. data/lib/browse_everything/file_entry.rb +3 -1
  33. data/lib/browse_everything/retriever.rb +103 -31
  34. data/lib/browse_everything/version.rb +3 -1
  35. data/lib/generators/browse_everything/assets_generator.rb +3 -2
  36. data/lib/generators/browse_everything/config_generator.rb +11 -9
  37. data/lib/generators/browse_everything/install_generator.rb +3 -2
  38. data/lib/generators/browse_everything/templates/browse_everything_providers.yml.example +12 -11
  39. data/spec/controllers/browse_everything_controller_spec.rb +80 -0
  40. data/spec/features/select_files_spec.rb +13 -13
  41. data/spec/features/test_compiling_stylesheets_spec.rb +2 -0
  42. data/spec/fixtures/vcr_cassettes/google_drive.yml +331 -0
  43. data/spec/fixtures/vcr_cassettes/retriever.yml +93 -0
  44. data/spec/helper/browse_everything_controller_helper_spec.rb +21 -7
  45. data/spec/javascripts/jasmine_spec.rb +2 -0
  46. data/spec/javascripts/support/jasmine_helper.rb +1 -0
  47. data/spec/lib/browse_everything/auth/google/credentials_spec.rb +41 -0
  48. data/spec/{unit → lib/browse_everything}/browse_everything_helper_spec.rb +2 -0
  49. data/spec/lib/browse_everything/browser_spec.rb +109 -0
  50. data/spec/{unit → lib/browse_everything/driver}/base_spec.rb +5 -4
  51. data/spec/{unit → lib/browse_everything/driver}/box_spec.rb +20 -5
  52. data/spec/{unit → lib/browse_everything/driver}/dropbox_spec.rb +15 -18
  53. data/spec/{unit → lib/browse_everything/driver}/file_system_spec.rb +32 -26
  54. data/spec/lib/browse_everything/driver/google_drive_spec.rb +171 -0
  55. data/spec/{unit → lib/browse_everything/driver}/s3_spec.rb +38 -21
  56. data/spec/lib/browse_everything/driver_spec.rb +38 -0
  57. data/spec/{unit → lib/browse_everything}/file_entry_spec.rb +4 -1
  58. data/spec/lib/browse_everything/retriever_spec.rb +200 -0
  59. data/spec/lib/browse_everything_spec.rb +67 -0
  60. data/spec/services/browse_everything_session/provider_session_spec.rb +50 -0
  61. data/spec/services/browser_factory_spec.rb +40 -0
  62. data/spec/spec_helper.rb +39 -18
  63. data/spec/support/app/controllers/file_handler_controller.rb +4 -4
  64. data/spec/support/app/views/file_handler/main.html.erb +1 -1
  65. data/spec/support/capybara.rb +17 -0
  66. data/spec/support/rake.rb +3 -1
  67. data/spec/support/wait_for_ajax.rb +14 -0
  68. data/spec/test_app_templates/Gemfile.extra +1 -0
  69. data/spec/test_app_templates/lib/generators/test_app_generator.rb +10 -4
  70. data/spec/views/browse_everything/{_file.html.erb_spec.rb → _files.html.erb_spec.rb} +24 -18
  71. data/tasks/ci.rake +2 -0
  72. metadata +159 -107
  73. data/app/views/browse_everything/_file.html.erb +0 -52
  74. data/app/views/browse_everything/resolve.html.erb +0 -1
  75. data/spec/unit/browser_spec.rb +0 -76
  76. data/spec/unit/retriever_spec.rb +0 -109
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  describe 'Compiling the stylesheets', type: :feature do
2
4
  it 'does not raise errors' do
3
5
  visit '/'
@@ -0,0 +1,331 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.googleapis.com/oauth2/v4/token
6
+ body:
7
+ encoding: ASCII-8BIT
8
+ string: grant_type=authorization_code&code=code&redirect_uri=uri&client_id=id.apps.googleusercontent.com&client_secret=SECRET
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.13.1
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Cache-Control:
24
+ - no-cache, no-store, max-age=0, must-revalidate
25
+ Pragma:
26
+ - no-cache
27
+ Expires:
28
+ - Mon, 01 Jan 1990 00:00:00 GMT
29
+ Date:
30
+ - Mon, 30 Oct 2017 13:55:49 GMT
31
+ Vary:
32
+ - Origin
33
+ - X-Origin
34
+ Content-Type:
35
+ - application/json; charset=UTF-8
36
+ X-Content-Type-Options:
37
+ - nosniff
38
+ X-Frame-Options:
39
+ - SAMEORIGIN
40
+ X-Xss-Protection:
41
+ - 1; mode=block
42
+ Server:
43
+ - GSE
44
+ Alt-Svc:
45
+ - quic=":443"; ma=2592000; v="41,39,38,37,35"
46
+ Transfer-Encoding:
47
+ - chunked
48
+ body:
49
+ encoding: ASCII-8BIT
50
+ string: |
51
+ {
52
+ "access_token": "access-token",
53
+ "token_type": "Bearer",
54
+ "expires_in": 3600,
55
+ "refresh_token": "refresh-token"
56
+ }
57
+ http_version:
58
+ recorded_at: Mon, 30 Oct 2017 13:55:49 GMT
59
+ - request:
60
+ method: get
61
+ uri: https://www.googleapis.com/drive/v3/files?fields=nextPageToken,files(name,id,mimeType,size,modifiedTime,parents,webContentLink)&orderBy=folder,modifiedTime%20desc,name&pageSize=1000
62
+ body:
63
+ encoding: UTF-8
64
+ string: ''
65
+ headers:
66
+ User-Agent:
67
+ - |-
68
+ Samvera Application/0.0.0 google-api-ruby-client/0.15.0 Mac OS X/10.12.6
69
+ (gzip)
70
+ Accept:
71
+ - "*/*"
72
+ Accept-Encoding:
73
+ - gzip,deflate
74
+ Date:
75
+ - Mon, 30 Oct 2017 13:55:49 GMT
76
+ Authorization:
77
+ - Bearer access-token
78
+ Content-Type:
79
+ - application/x-www-form-urlencoded
80
+ response:
81
+ status:
82
+ code: 200
83
+ message: OK
84
+ headers:
85
+ Expires:
86
+ - Mon, 30 Oct 2017 13:55:50 GMT
87
+ Date:
88
+ - Mon, 30 Oct 2017 13:55:50 GMT
89
+ Cache-Control:
90
+ - private, max-age=0, must-revalidate, no-transform
91
+ Vary:
92
+ - Origin
93
+ - X-Origin
94
+ Content-Type:
95
+ - application/json; charset=UTF-8
96
+ Content-Encoding:
97
+ - gzip
98
+ X-Content-Type-Options:
99
+ - nosniff
100
+ X-Frame-Options:
101
+ - SAMEORIGIN
102
+ X-Xss-Protection:
103
+ - 1; mode=block
104
+ Server:
105
+ - GSE
106
+ Alt-Svc:
107
+ - quic=":443"; ma=2592000; v="41,39,38,37,35"
108
+ Transfer-Encoding:
109
+ - chunked
110
+ body:
111
+ encoding: UTF-8
112
+ string: |
113
+ {
114
+ "nextPageToken": "next-page-token",
115
+ "files": [
116
+ {
117
+ "id": "asset-id1",
118
+ "name": "asset-name1",
119
+ "mimeType": "application/vnd.google-apps.folder",
120
+ "parents": [
121
+ "asset-id4"
122
+ ],
123
+ "modifiedTime": "2017-02-08T16:39:53.000Z"
124
+ },
125
+ {
126
+ "id": "asset-id2",
127
+ "name": "asset-name2.pdf",
128
+ "mimeType": "application/pdf",
129
+ "webContentLink": "https://drive.google.com/uc?id=id&export=download",
130
+ "modifiedTime": "2017-10-20T16:48:50.001Z",
131
+ "size": "891764"
132
+ },
133
+ {
134
+ "id": "asset-id3",
135
+ "name": "asset-name3.pdf",
136
+ "mimeType": "application/pdf",
137
+ "parents": [
138
+ "asset-id6"
139
+ ],
140
+ "webContentLink": "https://drive.google.com/uc?id=id&export=download",
141
+ "modifiedTime": "2017-10-20T16:48:50.001Z",
142
+ "size": "891764"
143
+ }
144
+ ]
145
+ }
146
+ http_version:
147
+ recorded_at: Mon, 30 Oct 2017 13:55:50 GMT
148
+ - request:
149
+ method: get
150
+ uri: https://www.googleapis.com/drive/v3/files?fields=nextPageToken,files(name,id,mimeType,size,modifiedTime,parents,webContentLink)&orderBy=folder,modifiedTime%20desc,name&pageSize=1000&pageToken=next-page-token
151
+ body:
152
+ encoding: UTF-8
153
+ string: ''
154
+ headers:
155
+ User-Agent:
156
+ - |-
157
+ Samvera Application/0.0.0 google-api-ruby-client/0.15.0 Mac OS X/10.12.6
158
+ (gzip)
159
+ Accept:
160
+ - "*/*"
161
+ Accept-Encoding:
162
+ - gzip,deflate
163
+ Date:
164
+ - Mon, 30 Oct 2017 13:55:49 GMT
165
+ Authorization:
166
+ - Bearer access-token
167
+ Content-Type:
168
+ - application/x-www-form-urlencoded
169
+ response:
170
+ status:
171
+ code: 200
172
+ message: OK
173
+ headers:
174
+ Expires:
175
+ - Mon, 30 Oct 2017 13:55:50 GMT
176
+ Date:
177
+ - Mon, 30 Oct 2017 13:55:50 GMT
178
+ Cache-Control:
179
+ - private, max-age=0, must-revalidate, no-transform
180
+ Vary:
181
+ - Origin
182
+ - X-Origin
183
+ Content-Type:
184
+ - application/json; charset=UTF-8
185
+ Content-Encoding:
186
+ - gzip
187
+ X-Content-Type-Options:
188
+ - nosniff
189
+ X-Frame-Options:
190
+ - SAMEORIGIN
191
+ X-Xss-Protection:
192
+ - 1; mode=block
193
+ Server:
194
+ - GSE
195
+ Alt-Svc:
196
+ - quic=":443"; ma=2592000; v="41,39,38,37,35"
197
+ Transfer-Encoding:
198
+ - chunked
199
+ body:
200
+ encoding: UTF-8
201
+ string: |
202
+ {
203
+ "files": []
204
+ }
205
+ http_version:
206
+ recorded_at: Mon, 30 Oct 2017 13:55:50 GMT
207
+ - request:
208
+ method: post
209
+ uri: https://www.googleapis.com/batch/drive/v3
210
+ body:
211
+ encoding: UTF-8
212
+ string: "--a2f3ce3d4c24a197cbba0300e98666b974a6eefc\r\nContent-Type: application/http\r\nContent-Id:
213
+ <b9edfb4e-045e-491e-8706-39513675fcc4+0>\r\nContent-Length: 239\r\nContent-Transfer-Encoding:
214
+ binary\r\n\r\nGET /drive/v3/files?fields=nextPageToken%2Cfiles%28name%2Cid%2CmimeType%2Csize%2CmodifiedTime%2Cparents%2CwebContentLink%29&orderBy=modifiedByMeTime%2CmodifiedTime%2Cfolder%20desc%2Cname&pageSize=1000
215
+ HTTP/1.1\r\nHost: www.googleapis.com\r\n\r\n\r\n--a2f3ce3d4c24a197cbba0300e98666b974a6eefc--\r\n\r\n"
216
+ headers:
217
+ User-Agent:
218
+ - |-
219
+ Samvera Application/0.0.0 google-api-ruby-client/0.18.0 Mac OS X/10.12.6
220
+ (gzip)
221
+ Accept:
222
+ - "*/*"
223
+ Accept-Encoding:
224
+ - gzip,deflate
225
+ Date:
226
+ - Mon, 18 Dec 2017 01:12:40 GMT
227
+ Content-Type:
228
+ - multipart/mixed; boundary=a2f3ce3d4c24a197cbba0300e98666b974a6eefc
229
+ Authorization:
230
+ - Bearer access-token
231
+ response:
232
+ status:
233
+ code: 200
234
+ message: OK
235
+ headers:
236
+ Vary:
237
+ - Origin
238
+ - X-Origin
239
+ Cache-Control:
240
+ - no-cache, no-store, max-age=0, must-revalidate
241
+ Pragma:
242
+ - no-cache
243
+ Expires:
244
+ - Mon, 01 Jan 1990 00:00:00 GMT
245
+ Date:
246
+ - Mon, 18 Dec 2017 01:12:43 GMT
247
+ Content-Type:
248
+ - multipart/mixed; boundary=batch_kIUSyvoB-sA_AAkZDwojjgg
249
+ Content-Encoding:
250
+ - gzip
251
+ X-Content-Type-Options:
252
+ - nosniff
253
+ X-Frame-Options:
254
+ - SAMEORIGIN
255
+ X-Xss-Protection:
256
+ - 1; mode=block
257
+ Server:
258
+ - GSE
259
+ Alt-Svc:
260
+ - hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337;
261
+ quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35"
262
+ Transfer-Encoding:
263
+ - chunked
264
+ body:
265
+ encoding: ASCII-8BIT
266
+ string: !binary |-
267
+ testdata
268
+ http_version:
269
+ recorded_at: Mon, 18 Dec 2017 01:12:42 GMT
270
+ - request:
271
+ method: get
272
+ uri: https://www.googleapis.com/drive/v3/files/asset-id2?fields=id,%20name,%20size
273
+ body:
274
+ encoding: UTF-8
275
+ string: ''
276
+ headers:
277
+ User-Agent:
278
+ - |-
279
+ Samvera Application/0.0.0 google-api-ruby-client/0.15.0 Mac OS X/10.12.6
280
+ (gzip)
281
+ Accept:
282
+ - "*/*"
283
+ Accept-Encoding:
284
+ - gzip,deflate
285
+ Date:
286
+ - Mon, 30 Oct 2017 13:55:49 GMT
287
+ Authorization:
288
+ - Bearer access-token
289
+ Content-Type:
290
+ - application/x-www-form-urlencoded
291
+ response:
292
+ status:
293
+ code: 200
294
+ message: OK
295
+ headers:
296
+ Expires:
297
+ - Mon, 30 Oct 2017 18:33:52 GMT
298
+ Date:
299
+ - Mon, 30 Oct 2017 18:33:52 GMT
300
+ Cache-Control:
301
+ - private, max-age=0, must-revalidate, no-transform
302
+ Vary:
303
+ - Origin
304
+ - X-Origin
305
+ Content-Type:
306
+ - application/json; charset=UTF-8
307
+ Content-Encoding:
308
+ - gzip
309
+ X-Content-Type-Options:
310
+ - nosniff
311
+ X-Frame-Options:
312
+ - SAMEORIGIN
313
+ X-Xss-Protection:
314
+ - 1; mode=block
315
+ Server:
316
+ - GSE
317
+ Alt-Svc:
318
+ - quic=":443"; ma=2592000; v="41,39,38,37,35"
319
+ Transfer-Encoding:
320
+ - chunked
321
+ body:
322
+ encoding: UTF-8
323
+ string: |
324
+ {
325
+ "id": "asset-id2",
326
+ "name": "asset-name2.pdf",
327
+ "webContentLink": "https://drive.google.com/uc?id=id&export=download"
328
+ }
329
+ http_version:
330
+ recorded_at: Mon, 30 Oct 2017 18:33:52 GMT
331
+ recorded_with: VCR 3.0.3
@@ -1,5 +1,98 @@
1
1
  ---
2
2
  http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://retrieve.cloud.example.com/some/dir/can_retrieve.pdf
6
+ headers:
7
+ Range: bytes=0-0
8
+ response:
9
+ status:
10
+ code: '206'
11
+ message: 'Partial Content'
12
+ headers:
13
+ Content-Length:
14
+ - 1
15
+ Content-Type:
16
+ - application/pdf
17
+ Content-Range:
18
+ - 'bytes 0-0/64134'
19
+ body:
20
+ encoding: ASCII-8BIT
21
+ string: '%'
22
+ http_version: '1.1'
23
+ recorded_at: Tue, 24 Jul 2018 10:38:42 GMT
24
+ - request:
25
+ method: get
26
+ uri: https://retrieve.cloud.example.com/some/dir/cannot_retrieve.pdf
27
+ headers:
28
+ Range: bytes=0-0
29
+ response:
30
+ status:
31
+ code: '403'
32
+ message: 'Unauthorized'
33
+ http_version: '1.1'
34
+ recorded_at: Tue, 24 Jul 2018 10:38:42 GMT
35
+ - request:
36
+ method: get
37
+ uri: https://drive.google.com/uc?export=download&id=id
38
+ headers:
39
+ Authorization:
40
+ - Bearer access-token
41
+ response:
42
+ status:
43
+ code: '200'
44
+ message: OK
45
+ headers:
46
+ Content-Length: '1234'
47
+ body:
48
+ encoding: ASCII-8BIT
49
+ string: content
50
+ http_version: '1.1'
51
+ recorded_at: Mon, 23 Jul 2018 16:00:03 GMT
52
+ - request:
53
+ method: head
54
+ uri: https://drive.google.com/uc?export=download&id=id
55
+ headers:
56
+ Authorization:
57
+ - Bearer access-token
58
+ response:
59
+ status:
60
+ code: '200'
61
+ message: OK
62
+ headers:
63
+ Content-Length: '1234'
64
+ body:
65
+ encoding: ASCII-8BIT
66
+ string: content
67
+ http_version: '1.1'
68
+ recorded_at: Mon, 23 Jul 2018 16:00:03 GMT
69
+ - request:
70
+ method: get
71
+ uri: https://retrieve.cloud.example.com/some/dir/file_error.pdf
72
+ headers:
73
+ Accept: ! '*/*'
74
+ Authorization: Bearer ya29.kQCEAHj1bwFXr2AuGQJmSGRWQXpacmmYZs4kzCiXns3d6H1ZpIDWmdM8
75
+ response:
76
+ status:
77
+ code: '403'
78
+ message: Unauthorized
79
+ headers:
80
+ Server: nginx
81
+ Date: Wed, 01 Oct 2014 14:01:16 GMT
82
+ Content-Type: application/json
83
+ Transfer-Encoding: chunked
84
+ Connection: close
85
+ pragma: no-cache
86
+ cache-control: no-cache
87
+ body:
88
+ encoding: ASCII-8BIT
89
+ string: |-
90
+ {"error":{"errors":[{"domain":"usageLimits","reason":"dailyLimitExceededUnreg",
91
+ "message":"Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
92
+ "extendedHelp":"https://code.google.com/apis/console"}],"code":403,
93
+ "message":"Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."}}
94
+ http_version: '1.1'
95
+ recorded_at: Mon, 23 Jul 2018 15:27:31 GMT
3
96
  - request:
4
97
  method: get
5
98
  uri: https://retrieve.cloud.example.com/some/dir/file.pdf
@@ -1,19 +1,25 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('../spec_helper', __dir__)
2
4
 
3
5
  include BrowserConfigHelper
4
6
 
5
7
  describe BrowseEverythingController, type: :controller do
6
- before(:all) { stub_configuration }
7
- after(:all) { unstub_configuration }
8
-
9
8
  subject { helper_context.auth_link.scan(/state/) }
10
9
 
11
10
  let(:helper_context) { controller.view_context }
12
11
  let(:browser) { BrowseEverything::Browser.new(url_options) }
13
12
 
14
- before { allow(controller).to receive(:provider).and_return(provider) }
13
+ before do
14
+ stub_configuration
15
+ allow(controller).to receive(:provider).and_return(provider)
16
+ end
17
+
18
+ after do
19
+ unstub_configuration
20
+ end
15
21
 
16
- context 'dropbox' do
22
+ context 'when using Dropbox as a provider' do
17
23
  let(:provider) { browser.providers['dropbox'] }
18
24
 
19
25
  describe 'auth_link' do
@@ -21,11 +27,19 @@ describe BrowseEverythingController, type: :controller do
21
27
  end
22
28
  end
23
29
 
24
- context 'box' do
30
+ context 'when using Box as a provider' do
25
31
  let(:provider) { browser.providers['box'] }
26
32
 
27
33
  describe 'auth_link' do
28
34
  its(:length) { is_expected.to eq(1) }
29
35
  end
30
36
  end
37
+
38
+ context 'when using Google Drive as a provider' do
39
+ let(:provider) { browser.providers['google_drive'] }
40
+
41
+ describe 'auth_link' do
42
+ its(:length) { is_expected.to eq(1) }
43
+ end
44
+ end
31
45
  end