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..0e56d53 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 @@ -202,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 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