Skip to content

Commit

Permalink
Ticket #823 : Can pass null value
Browse files Browse the repository at this point in the history
  • Loading branch information
thabart committed Dec 4, 2024
1 parent 8a3345f commit 6aa7c93
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/Scim/SimpleIdServer.Scim/Extensions/JTokenExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) SimpleIdServer. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using Newtonsoft.Json.Linq;

namespace SimpleIdServer.Scim.Extensions;

public static class JTokenExtensions
{
public static bool IsEmpty(this JToken token)
=> token == null || string.IsNullOrWhiteSpace(token.ToString());
}
9 changes: 5 additions & 4 deletions src/Scim/SimpleIdServer.Scim/Helpers/RepresentationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -627,13 +627,12 @@ public static ICollection<SCIMRepresentationAttribute> BuildRepresentationAttrib
if (record.SchemaAttribute.MultiValued)
{
var jArr = record.Content as JArray;
if (jArr == null)
if (jArr == null && !record.Content.IsEmpty())
{
throw new SCIMSchemaViolatedException(string.Format(Global.AttributeIsNotArray, record.SchemaAttribute.Name));
}


attributes.AddRange(BuildAttributes(jArr, record.SchemaAttribute, record.Schema, ignoreUnsupportedCanonicalValues));
if(jArr != null) attributes.AddRange(BuildAttributes(jArr, record.SchemaAttribute, record.Schema, ignoreUnsupportedCanonicalValues));
}
else
{
Expand Down Expand Up @@ -908,12 +907,14 @@ private static ResolutionRowResult Resolve(KeyValuePair<string, JToken> kvp, ICo
private static ICollection<ResolutionRowResult> ResolveFullQualifiedName(KeyValuePair<string, JToken> kvp, ICollection<SCIMSchema> extensionSchemas)
{
var jObj = kvp.Value as JObject;
if (jObj == null)
var jArr = kvp.Value as JArray;
if (jArr != null)
{
throw new SCIMSchemaViolatedException(string.Format(Global.PropertyCannotContainsArray, kvp.Key));
}

var result = new List<ResolutionRowResult>();
if (jObj == null) return result;
var schema = extensionSchemas.First(e => kvp.Key == e.Id);
foreach (var skvp in jObj)
{
Expand Down

0 comments on commit 6aa7c93

Please sign in to comment.