-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fixed relative address construction for manual HTTP client (#156)
* Fixed relative URI construction error in ApiUrls * Added relative uri test --------- Co-authored-by: Juan Santos <[email protected]>
- Loading branch information
1 parent
6075dc3
commit 0e1ae3c
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
tests/Keycloak.AuthServices.Sdk.Tests/KeycloakClientRelativeAddressTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace Keycloak.AuthServices.Sdk.Tests; | ||
|
||
using System.Net; | ||
using Admin; | ||
using RichardSzalay.MockHttp; | ||
|
||
public class KeycloakClientRelativeAddressTests | ||
{ | ||
private const string BaseAddress = "http://localhost:8080/identity/"; | ||
private const string MediaType = "application/json"; | ||
private readonly MockHttpMessageHandler handler = new(); | ||
private readonly IKeycloakRealmClient keycloakRealmClient; | ||
|
||
public KeycloakClientRelativeAddressTests() | ||
{ | ||
var httpClient = this.handler.ToHttpClient(); | ||
httpClient.BaseAddress = new Uri(BaseAddress); | ||
|
||
this.keycloakRealmClient = new KeycloakClient(httpClient); | ||
} | ||
|
||
[Fact] | ||
public async Task GetRealmShouldCallRealmRelativeEndpoint() | ||
{ | ||
this.handler.Expect(HttpMethod.Get, "/identity/admin/realms/master") | ||
.Respond(HttpStatusCode.OK, MediaType, "{}"); | ||
|
||
await this.keycloakRealmClient.GetRealmAsync("master"); | ||
|
||
this.handler.VerifyNoOutstandingExpectation(); | ||
} | ||
} |