Skip to content

Commit

Permalink
Merge 37f0ea6 into b799fc4
Browse files Browse the repository at this point in the history
  • Loading branch information
magnus-tretton37 committed Mar 27, 2019
2 parents b799fc4 + 37f0ea6 commit 3f0ff7a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Castle.Sdk/CastleClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ public async Task ImpersonateEnd(ImpersonateEndRequest request)
await TryRequest(() => _messageSender.Delete<VoidResponse>("/v1/impersonate", request));
}

public async Task ArchiveDevices(string userId)
{
await TryRequest(() => _messageSender.Put<VoidResponse>($"/v1/users/{userId}/archive_devices"));
}

private async Task<T> TryRequest<T>(Func<Task<T>> request)
where T : new()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Castle.Sdk/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static RequestContext FromHttpRequest(Microsoft.AspNetCore.Http.HttpReque
{
ClientId = GetClientIdForCore(request.Headers, request.Cookies),
Headers = request.Headers.ToDictionary(x => x.Key, y => y.Value.FirstOrDefault()),
Ip = GetIpForCore(request.Headers, ipHeaders, () => request.HttpContext.Connection.RemoteIpAddress.ToString())
Ip = GetIpForCore(request.Headers, ipHeaders, () => request.HttpContext.Connection.RemoteIpAddress?.ToString())
};
}

Expand Down
7 changes: 7 additions & 0 deletions src/Tests/When_calling_client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,12 @@ public void Should_end_impersonation(ImpersonateEndRequest request, CastleClient
Func<Task> act = async () => await sut.ImpersonateEnd(request);
act.Should().NotThrow();
}

[Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))]
public void Should_archive_devices(string userId, CastleClient sut)
{
Func<Task> act = async () => await sut.ArchiveDevices(userId);
act.Should().NotThrow();
}
}
}

0 comments on commit 3f0ff7a

Please sign in to comment.