Commit 42265d2
Changed files (2)
lib
scim
kit
v2
spec
scim
kit
lib/scim/kit/v2/filter.rb
@@ -9,9 +9,9 @@ module Scim
class Filter < Parslet::Parser
root :filter
- # FILTER = attrExp / logExp / valuePath / *1"not" "(" FILTER ")"
+ # FILTER = attrExp / logExp / valuePath / assignVariable / *1"not" "(" FILTER ")"
rule(:filter) do
- attribute_expression | logical_expression | value_path | not_op >> lparen >> filter >> rparen
+ attribute_expression | logical_expression | value_path | assign_variable | not_op >> lparen >> filter >> rparen
end
# valuePath = attrPath "[" valFilter "]" ; FILTER uses sub-attributes of a parent attrPath
@@ -77,6 +77,12 @@ module Scim
)
)
end
+
+ # assignVariable = ATTRNAME '=' *(NAMECHAR) | STRING
+ rule(:assign_variable) do
+ attribute_name >> space >> assign >> space >> (name_character.repeat(1, nil) | string)
+ end
+
rule(:presence) { str('pr').as(:presence) }
rule(:and_op) { str('and').as(:and) }
rule(:or_op) { str('or').as(:or) }
@@ -119,6 +125,7 @@ module Scim
rule(:hyphen) { str('-') }
rule(:underscore) { str('_') }
rule(:version) { digit >> dot >> digit }
+ rule(:assign) { str('=') }
end
end
end
spec/scim/kit/v2/filter_spec.rb
@@ -126,13 +126,13 @@ RSpec.describe Scim::Kit::V2::Filter do
[
# '',
'(userType eq "Employee") and ((emails co "example.com") or (emails.value co "example.org"))',
- # 'userType ne "Employee" and not (emails co "example.com" or emails.value co "example.org")',
+ '(userType ne "Employee") and (not((emails co "example.com") or (emails.value co "example.org")))',
'(userType eq "Employee") and (emails.type eq "work")',
'(userType eq "Employee") and (emails[(type eq "work") and (value co "@example.com")])',
'(emails[(type eq "work") and (value co "@example.com")]) or (ims[(type eq "xmpp") and (value co "@foo.com")])',
'(title pr) and (userType eq "Employee")',
'(title pr) or (userType eq "Intern")',
- # 'email eq "hello@example.org" or name.givenName eq "Tsuyoshi" or id = "4CE7E760-F222-4096-90B1-4AC491D12F2E"',
+ '((email eq "hello@example.org") or (name.givenName eq "Tsuyoshi")) or (id = "4CE7E760-F222-4096-90B1-4AC491D12F2E")',
'title pr'
].each do |x|
specify { expect(subject).to parse(x) }