Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/entitlements/data/groups/calculated/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines +297 to 300
Expand Down
15 changes: 11 additions & 4 deletions spec/unit/entitlements/data/groups/calculated/text_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines +188 to +189
expect(subject.metadata).to eq("kittens" => "awesome", "justification" => "Need access; for project work")
end
end

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description = This has a modifier with extra settings
username = blackmanx
expiration = 2043-01-01; expiration = 2044-01-01
5 changes: 5 additions & 0 deletions spec/unit/fixtures/ldap-config/metadata/semicolon.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description = Lots of metadata here
username = BlackManx
username = RAGAMUFFIn
metadata_kittens = awesome
metadata_justification = Need access; for project work
Loading