diff --git a/Gemfile.lock b/Gemfile.lock index e52d4cb..cff72c0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - entitlements-app (1.2.0) + entitlements-app (1.2.1) concurrent-ruby (~> 1.3, >= 1.3.1) faraday (~> 2.0) logger (~> 1.6) diff --git a/lib/entitlements/data/groups/cached.rb b/lib/entitlements/data/groups/cached.rb index 66663f8..555a510 100644 --- a/lib/entitlements/data/groups/cached.rb +++ b/lib/entitlements/data/groups/cached.rb @@ -51,6 +51,8 @@ def self.load_caches(dir) Entitlements.cache[:predictive_state][:by_ou][ou] ||= {} Entitlements.cache[:predictive_state][:by_ou][ou][identifier] = member_set Entitlements.cache[:predictive_state][:by_dn][dn] = { members: member_set, metadata: metadata } + rescue => e + raise "Failed to load predictive state cache file #{filename}: #{e.message}" end Entitlements.logger.debug "Loaded #{Entitlements.cache[:predictive_state][:by_ou].keys.size} OU(s) from cache" diff --git a/lib/version.rb b/lib/version.rb index 34d3bc2..412c637 100644 --- a/lib/version.rb +++ b/lib/version.rb @@ -2,6 +2,6 @@ module Entitlements module Version - VERSION = "1.2.0" + VERSION = "1.2.1" end end diff --git a/spec/unit/entitlements/data/groups/cached_spec.rb b/spec/unit/entitlements/data/groups/cached_spec.rb index a7a41d7..25ce6ea 100644 --- a/spec/unit/entitlements/data/groups/cached_spec.rb +++ b/spec/unit/entitlements/data/groups/cached_spec.rb @@ -17,6 +17,18 @@ end end + context "with a file that fails to parse" do + let(:dir) { fixture("predictive-state/failing-cache") } + + it "raises with a custom message" do + expect(logger).to receive(:debug).with("Loading predictive update caches from #{dir}") + + expect do + described_class.load_caches(dir) + end.to raise_error(RuntimeError, /Failed to load predictive state cache file/) + end + end + context "with valid predictive state directory" do let(:dir) { fixture("predictive-state/cache1") } diff --git a/spec/unit/fixtures/predictive-state/failing-cache/cn=admin,ou=org,ou=fakegithub,dc=github,dc=fake b/spec/unit/fixtures/predictive-state/failing-cache/cn=admin,ou=org,ou=fakegithub,dc=github,dc=fake new file mode 100644 index 0000000..6a0de29 --- /dev/null +++ b/spec/unit/fixtures/predictive-state/failing-cache/cn=admin,ou=org,ou=fakegithub,dc=github,dc=fake @@ -0,0 +1 @@ +metadata_is_missing_a_value