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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e58456aa931649225eed7877b806e8f46e38aff513b4bd1d47ed4ca6d1a7c4e2
4
- data.tar.gz: e29ceefbdda9bc4d9dd1eee4daf32a10093bc1f3e8a3e6c809b5e5aa4283c35e
3
+ metadata.gz: f05d57e597b220694bfa6681b6fd44ce847bbc3d9bed60c23547f4b6f879bcb5
4
+ data.tar.gz: d3bbd0453df99c237ead29a3d86b7b67a64dc6ceedf03420cc99ccd39eefd1ff
5
5
  SHA512:
6
- metadata.gz: 1865aee0aee41357c69048badaa0b7372a93b503d45fc7ee2c0c752960230403b332239aa9633b501ed73d5237b57d651deee4b59f52a678c9f41925c6f91670
7
- data.tar.gz: 24067eabbacc781a120caa9606335f6d9c18ca6564ddd7e71424ae6cca8d6afa32b02f0cf35805e3bc987ffb14fe26284bce5d53aef11829018898e903bb0db9
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
- begin
6
- response = ForestLiana::ForestApiRequester.get(route)
5
+ response = ForestLiana::ForestApiRequester.get(route)
7
6
 
8
- if response.is_a?(Net::HTTPOK)
9
- JSON.parse(response.body)
10
- else
11
- raise "Forest API returned an #{ForestLiana::Errors::HTTPErrorHelper.format(response)}"
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'] || 1).to_i.second
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?
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "8.0.14"
2
+ VERSION = "8.0.15"
3
3
  end
@@ -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.14
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-16 00:00:00.000000000 Z
11
+ date: 2023-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails