Skip to content

Commit 3f7e4d7

Browse files
Ticket #912 : Fix parsing
1 parent 359dad1 commit 3f7e4d7

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

src/Scim/SimpleIdServer.Scim.Parser/SCIMFilterParser.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ public static IEnumerable<string> SplitStringIntoFilters(string filterString)
351351
level++;
352352
}
353353

354+
if('(' == character && groupingIsOpened)
355+
{
356+
level++;
357+
}
358+
354359
if ('(' == character && (string.IsNullOrWhiteSpace(filterBuilder.ToString()) || filterBuilder.ToString() == "not"))
355360
{
356361
if ('(' == character && level == 0 && filterBuilder.Length == 0) nbGroupingRoot++;

tests/SimpleIdServer.Scim.Tests/FilterFixture.cs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public void When_Parse_And_Execute_Filter()
3737
{
3838
Id = Guid.NewGuid().ToString()
3939
};
40+
var fourthRepresentation = new SCIMRepresentation
41+
{
42+
Id = Guid.NewGuid().ToString(),
43+
LastModified = DateTime.Parse("2010-05-13T04:42:34Z")
44+
};
4045
representation.AddAttribute(new SCIMRepresentationAttribute(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), schema.GetAttribute("title"), schema.Id)
4146
{
4247
Id = Guid.NewGuid().ToString(),
@@ -112,11 +117,22 @@ public void When_Parse_And_Execute_Filter()
112117
{
113118
ValueString = "foo.com"
114119
});
120+
fourthRepresentation.AddAttribute(new SCIMRepresentationAttribute(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), schema.GetAttribute("userName"), schema.Id)
121+
{
122+
Id = Guid.NewGuid().ToString(),
123+
ValueString = "suraj"
124+
});
125+
fourthRepresentation.AddAttribute(new SCIMRepresentationAttribute(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), schema.GetAttribute("userType"), schema.Id)
126+
{
127+
Id = Guid.NewGuid().ToString(),
128+
ValueString = "OtherValue"
129+
});
115130
var representations = new List<SCIMRepresentation>
116131
{
117132
representation,
118133
secondRepresentation,
119-
thirdRepresentation
134+
thirdRepresentation,
135+
fourthRepresentation
120136
};
121137

122138
var firstResult = ParseAndExecuteFilter(representations.AsQueryable(), "userName eq \"bjensen\"", customSchema);
@@ -144,19 +160,20 @@ public void When_Parse_And_Execute_Filter()
144160
var twentyTwoResult = ParseAndExecuteFilter(representations.AsQueryable(), "(userName eq \"bjensen\")", customSchema);
145161
var twentyThreeResult = ParseAndExecuteFilter(representations.AsQueryable(), "(userName eq \"bjensen\" or userName eq \"Jule\")", customSchema);
146162
var twentyFourResult = ParseAndExecuteFilter(representations.AsQueryable(), "(userName eq \"bjensen\") and emails[type eq \"work\" and value co \"example.org\"] and phoneNumbers[primary eq \"true\"]", customSchema);
147-
163+
var twentyFiveResult = ParseAndExecuteFilter(representations.AsQueryable(), "(username eq suraj) and ((userType eq OtherValue) or (userType eq Public))", customSchema);
164+
148165
Assert.Equal(1, firstResult.Count());
149166
Assert.Equal(1, secondResult.Count());
150167
Assert.Equal(2, thirdResult.Count());
151168
Assert.Equal(1, fourthResult.Count());
152169
Assert.Equal(1, fifthResult.Count());
153170
Assert.Equal(1, sixResult.Count());
154-
Assert.Equal(2, sevenResult.Count());
155-
Assert.Equal(2, eightResult.Count());
171+
Assert.Equal(3, sevenResult.Count());
172+
Assert.Equal(3, eightResult.Count());
156173
Assert.Equal(1, nineResult.Count());
157174
Assert.Equal(2, tenResult.Count());
158175
Assert.Equal(1, elevenResult.Count());
159-
Assert.Equal(1, twelveResult.Count());
176+
Assert.Equal(2, twelveResult.Count());
160177
Assert.Equal(1, thirteenResult.Count());
161178
Assert.Equal(1, fourteenResult.Count());
162179
Assert.Equal(2, fifteenResult.Count());
@@ -170,6 +187,8 @@ public void When_Parse_And_Execute_Filter()
170187
Assert.Equal(1, twentyTwoResult.Count());
171188
Assert.Equal(2, twentyThreeResult.Count());
172189
Assert.Equal(1, twentyFourResult.Count());
190+
Assert.Equal(1, twentyFiveResult.Count());
191+
string ss = "";
173192
}
174193

175194
private IQueryable<SCIMRepresentation> ParseAndExecuteFilter(IQueryable<SCIMRepresentation> representations, string filter, SCIMSchema customSchema)

0 commit comments

Comments
 (0)