forest_liana 8.0.14 → 8.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/forest_liana/application_controller.rb +1 -0
- data/app/services/forest_liana/ability/fetch.rb +5 -13
- data/app/services/forest_liana/ability/permission.rb +1 -1
- data/lib/forest_liana/version.rb +1 -1
- data/spec/services/forest_liana/ability/permission_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f05d57e597b220694bfa6681b6fd44ce847bbc3d9bed60c23547f4b6f879bcb5
|
4
|
+
data.tar.gz: d3bbd0453df99c237ead29a3d86b7b67a64dc6ceedf03420cc99ccd39eefd1ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03506c47bf6f748129c80823b372246845f215d253b7b3ee3d2d14a27b4588c4014fa6a27d05a8199bee5134549663637c19f35327a87ff3ee0a0f4bfba82632
|
7
|
+
data.tar.gz: 2b55b11b94dc2fa393bcdbb66bf2a16305b193f004399ac4b79c2a33ac0c0d81f1fed98c8c798725c1504e38a718990ff402e6e1fdb2f1e91726306ff6c3cb29
|
@@ -4,6 +4,7 @@ require 'csv'
|
|
4
4
|
module ForestLiana
|
5
5
|
class ApplicationController < ForestLiana::BaseController
|
6
6
|
rescue_from ForestLiana::Ability::Exceptions::AccessDenied, with: :render_error
|
7
|
+
rescue_from ForestLiana::Errors::HTTP403Error, with: :render_error
|
7
8
|
rescue_from ForestLiana::Errors::HTTP422Error, with: :render_error
|
8
9
|
|
9
10
|
def self.papertrail?
|
@@ -2,20 +2,12 @@ module ForestLiana
|
|
2
2
|
module Ability
|
3
3
|
module Fetch
|
4
4
|
def get_permissions(route)
|
5
|
-
|
6
|
-
response = ForestLiana::ForestApiRequester.get(route)
|
5
|
+
response = ForestLiana::ForestApiRequester.get(route)
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
rescue => exception
|
14
|
-
FOREST_REPORTER.report exception
|
15
|
-
FOREST_LOGGER.error 'Cannot retrieve the permissions from the Forest server.'
|
16
|
-
FOREST_LOGGER.error 'Which was caused by:'
|
17
|
-
ForestLiana::Errors::ExceptionHelper.recursively_print(exception, margin: ' ', is_error: true)
|
18
|
-
nil
|
7
|
+
if response.is_a?(Net::HTTPOK)
|
8
|
+
JSON.parse(response.body)
|
9
|
+
else
|
10
|
+
raise ForestLiana::Errors::HTTP403Error.new("Permission could not be retrieved")
|
19
11
|
end
|
20
12
|
end
|
21
13
|
end
|
@@ -6,7 +6,7 @@ module ForestLiana
|
|
6
6
|
module Permission
|
7
7
|
include Fetch
|
8
8
|
|
9
|
-
TTL = (ENV['FOREST_PERMISSIONS_EXPIRATION_IN_SECONDS'] ||
|
9
|
+
TTL = (ENV['FOREST_PERMISSIONS_EXPIRATION_IN_SECONDS'] || 900).to_i.second
|
10
10
|
|
11
11
|
def is_crud_authorized?(action, user, collection)
|
12
12
|
return true unless has_permission_system?
|
data/lib/forest_liana/version.rb
CHANGED
@@ -327,6 +327,17 @@ module ForestLiana
|
|
327
327
|
expect {dummy_class.is_smart_action_authorized?(user, String, parameters, '/forest/actions/my_action', 'POST')}.to raise_error(ForestLiana::Errors::ExpectedError, 'The collection String doesn\'t exist')
|
328
328
|
end
|
329
329
|
end
|
330
|
+
|
331
|
+
describe 'when the server doesn\'t return an success response' do
|
332
|
+
before do
|
333
|
+
Rails.cache.clear
|
334
|
+
end
|
335
|
+
|
336
|
+
it 'should return an exception' do
|
337
|
+
allow(ForestLiana::ForestApiRequester).to receive(:get).and_return(instance_double(HTTParty::Response, code: 500, body: nil))
|
338
|
+
expect { dummy_class.is_crud_authorized?('browse', user, Island.first) }.to raise_error(ForestLiana::Errors::HTTP403Error, 'Permission could not be retrieved')
|
339
|
+
end
|
340
|
+
end
|
330
341
|
end
|
331
342
|
end
|
332
343
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forest_liana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.0.
|
4
|
+
version: 8.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Munda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|