Skip to content
This repository was archived by the owner on Feb 18, 2024. It is now read-only.

Commit 7df5a3e

Browse files
authored
Parse errors
1 parent cec15eb commit 7df5a3e

File tree

7 files changed

+50
-4
lines changed

7 files changed

+50
-4
lines changed

Gatekeeper.SCIM.Client.Tests.Integration/ClientTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using System.Text.Json;
54
using System.Threading.Tasks;
65
using Gatekeeper.SCIM.Client.Action;
76
using Gatekeeper.SCIM.Client.Result;
@@ -40,6 +39,7 @@ public async Task IntegrationTest()
4039
};
4140
CreateAction<User> createUserAction = new CreateAction<User>(user);
4241
CreateResult<User> createUserResult = await client.PerformAction<CreateResult<User>>(createUserAction);
42+
4343
Assert.Equal(StateEnum.Success, createUserResult.ResultStatus);
4444
user.AsSource()
4545
.OfLikeness<User>()

Gatekeeper.SCIM.Client/Client.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ public void SetAuthToken(string authToken)
4949
}
5050
else
5151
{
52+
ErrorResult errorResult = await response.Content.ReadFromJsonAsync<ErrorResult>();
53+
5254
return (TResult)(object)new CreateResult<User>
5355
{
5456
ResultStatus = StateEnum.Failure,
57+
ErrorDetail = (errorResult.Detail != null) ? errorResult.Detail : null,
58+
ScimType = (errorResult.ScimType != null) ? errorResult.ScimType : null,
5559
};
5660
}
5761

Gatekeeper.SCIM.Client/Gatekeeper.SCIM.Client.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<IncludeSymbols>true</IncludeSymbols>
77
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
88

9-
<Version>0.0.2-alpha</Version>
9+
<Version>0.0.3-alpha</Version>
1010
<Authors>Lukas Reschke</Authors>
1111
<Company>Gatekeeper</Company>
1212
<Description>
@@ -18,7 +18,7 @@
1818
<PackageProjectUrl>https://github.com/GetGatekeeper/SCIM.Client</PackageProjectUrl>
1919
<RepositoryUrl>https://github.com/GetGatekeeper/SCIM.Client.git</RepositoryUrl>
2020
<PackageReleaseNotes>
21-
Add support for email attribute.
21+
Parse Errors.
2222
</PackageReleaseNotes>
2323
<RepositoryType>git</RepositoryType>
2424
<Title>Gatekeeper.SCIM.Client</Title>

Gatekeeper.SCIM.Client/Result/CreateResult.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace Gatekeeper.SCIM.Client.Result
44
{
5-
public class CreateResult<T> : IResult where T : IResource
5+
public class CreateResult<T> : IResult, IError where T : IResource
66
{
77
public StateEnum ResultStatus { get; set; }
88
public T? Resource { get; set; }
9+
public string? ErrorDetail { get; set; }
10+
public ErrorResult.ScimTypeEnum? ScimType { get; set; }
911
}
1012
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace Gatekeeper.SCIM.Client.Result
4+
{
5+
public class ErrorResult
6+
{
7+
[JsonPropertyName("detail")]
8+
public string? Detail { get; set; }
9+
10+
[JsonPropertyName("scimType")]
11+
public ScimTypeEnum? ScimType { get; set; }
12+
13+
public enum ScimTypeEnum
14+
{
15+
invalidFilter = 1,
16+
tooMany = 2,
17+
uniqueness = 3,
18+
mutability = 4,
19+
invalidSyntax = 5,
20+
invalidPath = 6,
21+
noTarget = 7,
22+
invalidValue = 8,
23+
invalidVers = 9,
24+
sensitive = 10,
25+
}
26+
}
27+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using static Gatekeeper.SCIM.Client.Result.ErrorResult;
2+
3+
namespace Gatekeeper.SCIM.Client.Result
4+
{
5+
interface IError
6+
{
7+
public string? ErrorDetail { get; set; }
8+
public ScimTypeEnum? ScimType { get; set; }
9+
}
10+
}

Gatekeeper.SCIM.Client/Schema/Core/2.0/User.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public class EmailAttribute
6262
{
6363
[JsonPropertyName("value")]
6464
public string? Value { get; set; }
65+
66+
[JsonPropertyName("primary")]
67+
public bool Primary { get; set; }
6568
}
6669

6770
public class GroupMembership

0 commit comments

Comments
 (0)