From 780e8a5cb8feeab9910c1ef59fa60317caa45ac6 Mon Sep 17 00:00:00 2001 From: trespilhas Date: Fri, 13 Mar 2026 14:17:03 -0400 Subject: [PATCH 1/2] Fixed https://github.com/github/entitlements-app/issues/68 --- lib/entitlements/data/groups/calculated/text.rb | 2 +- .../entitlements/data/groups/calculated/text_spec.rb | 9 +++++---- spec/unit/fixtures/ldap-config/metadata/semicolon.txt | 5 +++++ 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 spec/unit/fixtures/ldap-config/metadata/semicolon.txt diff --git a/lib/entitlements/data/groups/calculated/text.rb b/lib/entitlements/data/groups/calculated/text.rb index b78828a..bfccc8c 100644 --- a/lib/entitlements/data/groups/calculated/text.rb +++ b/lib/entitlements/data/groups/calculated/text.rb @@ -294,7 +294,7 @@ def parsed_data result[key]["&="] ||= [] # Semicolon predicates - if key == "description" + if key == "description" || key.start_with?("metadata_") result[key][operator] << { key: val } else result[key][operator] << parsed_predicate(val) diff --git a/spec/unit/entitlements/data/groups/calculated/text_spec.rb b/spec/unit/entitlements/data/groups/calculated/text_spec.rb index 538fd09..94f1398 100644 --- a/spec/unit/entitlements/data/groups/calculated/text_spec.rb +++ b/spec/unit/entitlements/data/groups/calculated/text_spec.rb @@ -183,10 +183,11 @@ expect(subject.metadata).to eq("kittens" => "awesome", "puppies" => "young dogs") end - it "raises an error if expiration is given to metadata" do - filename = fixture("ldap-config/metadata/expiration.txt") - message = "In #{filename}, the key metadata_kittens cannot have additional setting(s) \"expiration\"!" - expect { described_class.new(filename: filename) }.to raise_error(message) + it "does not raise an error when metadata values contain semicolons" do + filename = fixture("ldap-config/metadata/semicolon.txt") + expect { described_class.new(filename: filename) }.not_to raise_error + subject = described_class.new(filename: filename) + expect(subject.metadata).to eq("kittens" => "awesome", "justification" => "Need access; for project work") end end diff --git a/spec/unit/fixtures/ldap-config/metadata/semicolon.txt b/spec/unit/fixtures/ldap-config/metadata/semicolon.txt new file mode 100644 index 0000000..cc6cdef --- /dev/null +++ b/spec/unit/fixtures/ldap-config/metadata/semicolon.txt @@ -0,0 +1,5 @@ +description = Lots of metadata here +username = BlackManx +username = RAGAMUFFIn +metadata_kittens = awesome +metadata_justification = Need access; for project work From 6904cd9dfdf89c021b4dde314fab206b8882b751 Mon Sep 17 00:00:00 2001 From: trespilhas Date: Mon, 16 Mar 2026 10:47:39 -0400 Subject: [PATCH 2/2] Restored 100% test coverage --- spec/unit/entitlements/data/groups/calculated/text_spec.rb | 6 ++++++ .../fixtures/ldap-config/expiration/additional-settings.txt | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 spec/unit/fixtures/ldap-config/expiration/additional-settings.txt diff --git a/spec/unit/entitlements/data/groups/calculated/text_spec.rb b/spec/unit/entitlements/data/groups/calculated/text_spec.rb index 94f1398..0e56d53 100644 --- a/spec/unit/entitlements/data/groups/calculated/text_spec.rb +++ b/spec/unit/entitlements/data/groups/calculated/text_spec.rb @@ -203,6 +203,12 @@ subject = described_class.new(filename: filename) expect(subject.modifiers).to eq("expiration"=>"2043-01-01") end + + it "raises an error if a modifier has additional settings" do + filename = fixture("ldap-config/expiration/additional-settings.txt") + message = "In #{filename}, the key modifier_expiration cannot have additional setting(s) \"expiration\"!" + expect { described_class.new(filename: filename).modifiers }.to raise_error(message) + end end describe "#rules" do diff --git a/spec/unit/fixtures/ldap-config/expiration/additional-settings.txt b/spec/unit/fixtures/ldap-config/expiration/additional-settings.txt new file mode 100644 index 0000000..08e5e89 --- /dev/null +++ b/spec/unit/fixtures/ldap-config/expiration/additional-settings.txt @@ -0,0 +1,3 @@ +description = This has a modifier with extra settings +username = blackmanx +expiration = 2043-01-01; expiration = 2044-01-01