Skip to content

Commit

Permalink
Ticket #47 : Fix duplicate nested attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
thabart committed Sep 7, 2020
1 parent aaf80d8 commit f439b65
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>1.1.5</VersionPrefix>
<VersionPrefix>1.1.6</VersionPrefix>
<Authors>SimpleIdServer</Authors>
<Owners>SimpleIdServer</Owners>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static SCIMRepresentation ToDomain(this SCIMRepresentationModel represent
ResourceType = representation.ResourceType,
Id = representation.Id,
Schemas = representation.Schemas.Select(s => ToDomain(s.Schema)).ToList(),
Attributes = representation.Attributes.Select(s =>
Attributes = representation.Attributes.Where(_ => _.Parent == null).Select(s =>
{
return ToDomain(s);
}).ToList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public async Task<SCIMRepresentation> Handle(ReplaceRepresentationCommand replac
}
}

existingRepresentation.SetExternalId(updatedRepresentation.ExternalId);
existingRepresentation.SetUpdated(DateTime.UtcNow);
using (var transaction = await _scimRepresentationCommandRepository.StartTransaction())
{
Expand Down
5 changes: 5 additions & 0 deletions src/Scim/SimpleIdServer.Scim/Domain/SCIMRepresentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public void SetCreated(DateTime created)
Created = created;
}

public void SetExternalId(string externalId)
{
ExternalId = externalId;
}

public void SetUpdated(DateTime lastModified)
{
LastModified = lastModified;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,16 @@ Scenario: Check user can be updated (HTTP PUT)
| name | { "formatted" : "formatted", "familyName": "familyName", "givenName": "givenName" } |
| phones | [ { "phoneNumber": "01", "type": "mobile" }, { "phoneNumber": "02", "type": "home" } ] |
| employeeNumber | number |
| externalId | ext |

And extract JSON from body
And extract 'id' from JSON body
And execute HTTP PUT JSON request 'http://localhost/Users/$id$'
| Key | Value |
| schemas | [ "urn:ietf:params:scim:schemas:core:2.0:User" ] |
| name | { "formatted" : "newFormatted", "familyName": "newFamilyName", "givenName": "newGivenName" } |
| id | $id$ |
| Key | Value |
| schemas | [ "urn:ietf:params:scim:schemas:core:2.0:User" ] |
| name | { "formatted" : "newFormatted", "familyName": "newFamilyName", "givenName": "newGivenName" } |
| id | $id$ |
| externalId | newext |

And execute HTTP GET request 'http://localhost/Users/$id$'
And extract JSON from body
Expand All @@ -212,6 +214,7 @@ Scenario: Check user can be updated (HTTP PUT)
Then HTTP HEADER contains 'ETag'
Then JSON 'schemas[0]'='urn:ietf:params:scim:schemas:core:2.0:User'
Then JSON 'userName'='bjen'
Then JSON 'externalId'='newext'
Then JSON 'name.formatted'='newFormatted'
Then JSON 'name.familyName'='newFamilyName'
Then JSON 'name.givenName'='newGivenName'
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f439b65

Please sign in to comment.