Skip to content

Commit

Permalink
add missing ConfigureAwait(false)
Browse files Browse the repository at this point in the history
  • Loading branch information
lvermeulen committed Aug 22, 2020
1 parent fa3920e commit ac977cc
Show file tree
Hide file tree
Showing 23 changed files with 256 additions and 256 deletions.
22 changes: 11 additions & 11 deletions src/Keycloak.Net/Common/Extensions/FlurlRequestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ public static class FlurlRequestExtensions
{
private static async Task<string> GetAccessTokenAsync(string url, string realm, string userName, string password)
{
var result = await url
.AppendPathSegment($"/auth/realms/{realm}/protocol/openid-connect/token")
.WithHeader("Accept", "application/json")
.PostUrlEncodedAsync(new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("grant_type", "password"),
new KeyValuePair<string, string>("username", userName),
new KeyValuePair<string, string>("password", password),
new KeyValuePair<string, string>("client_id", "admin-cli")
})
.ReceiveJson();
var result = await url
.AppendPathSegment($"/auth/realms/{realm}/protocol/openid-connect/token")
.WithHeader("Accept", "application/json")
.PostUrlEncodedAsync(new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("grant_type", "password"),
new KeyValuePair<string, string>("username", userName),
new KeyValuePair<string, string>("password", password),
new KeyValuePair<string, string>("client_id", "admin-cli")
})
.ReceiveJson().ConfigureAwait(false);

string accessToken = result
.access_token.ToString();
Expand Down
4 changes: 2 additions & 2 deletions src/Keycloak.Net/Users/KeycloakClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class KeycloakClient
{
public async Task<bool> CreateUserAsync(string realm, User user)
{
var response = await InternalCreateUserAsync(realm, user);
var response = await InternalCreateUserAsync(realm, user).ConfigureAwait(false);
return response.IsSuccessStatusCode;
}

Expand All @@ -24,7 +24,7 @@ private async Task<HttpResponseMessage> InternalCreateUserAsync(string realm, Us

public async Task<string> CreateAndRetrieveUserIdAsync(string realm, User user)
{
var response = await InternalCreateUserAsync(realm, user);
var response = await InternalCreateUserAsync(realm, user).ConfigureAwait(false);
string locationPathAndQuery = response.Headers.Location.PathAndQuery;
string userId = response.IsSuccessStatusCode ? locationPathAndQuery.Substring(locationPathAndQuery.LastIndexOf("/", StringComparison.Ordinal) + 1) : null;
return userId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ public partial class KeycloakClientShould
[InlineData("Insurance", "vermeulen")]
public async Task GetUserNameStatusInBruteForceDetectionAsync(string realm, string search)
{
var users = await _client.GetUsersAsync(realm, search: search);
var users = await _client.GetUsersAsync(realm, search: search).ConfigureAwait(false);
string userId = users.FirstOrDefault()?.Id;
if (userId != null)
{
var result = await _client.GetUserNameStatusInBruteForceDetectionAsync(realm, userId);
var result = await _client.GetUserNameStatusInBruteForceDetectionAsync(realm, userId).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ public partial class KeycloakClientShould
[InlineData("Insurance")]
public async Task GetAuthenticatorProvidersAsync(string realm)
{
var result = await _client.GetAuthenticatorProvidersAsync(realm);
var result = await _client.GetAuthenticatorProvidersAsync(realm).ConfigureAwait(false);
Assert.NotNull(result);
}

[Theory]
[InlineData("Insurance")]
public async Task GetClientAuthenticatorProvidersAsync(string realm)
{
var result = await _client.GetClientAuthenticatorProvidersAsync(realm);
var result = await _client.GetClientAuthenticatorProvidersAsync(realm).ConfigureAwait(false);
Assert.NotNull(result);
}

[Theory]
[InlineData("Insurance")]
public async Task GetAuthenticatorProviderConfigurationDescriptionAsync(string realm)
{
var providers = await _client.GetAuthenticatorProvidersAsync(realm);
var providers = await _client.GetAuthenticatorProvidersAsync(realm).ConfigureAwait(false);
string providerId = providers.FirstOrDefault()?.FirstOrDefault(x => x.Key == "id").Value.ToString();
if (providerId != null)
{
var result = await _client.GetAuthenticatorProviderConfigurationDescriptionAsync(realm, providerId);
var result = await _client.GetAuthenticatorProviderConfigurationDescriptionAsync(realm, providerId).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand All @@ -42,7 +42,7 @@ public async Task GetAuthenticatorConfigurationAsync(string realm)
string configurationId = ""; //TODO
if (configurationId != null)
{
var result = await _client.GetAuthenticatorConfigurationAsync(realm, configurationId);
var result = await _client.GetAuthenticatorConfigurationAsync(realm, configurationId).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand All @@ -51,15 +51,15 @@ public async Task GetAuthenticatorConfigurationAsync(string realm)
[InlineData("Insurance")]
public async Task GetAuthenticationExecutionAsync(string realm)
{
var flows = await _client.GetAuthenticationFlowsAsync(realm);
var flows = await _client.GetAuthenticationFlowsAsync(realm).ConfigureAwait(false);
string flowAlias = flows.FirstOrDefault()?.Alias;
if (flowAlias != null)
{
var executions = await _client.GetAuthenticationFlowExecutionsAsync(realm, flowAlias);
var executions = await _client.GetAuthenticationFlowExecutionsAsync(realm, flowAlias).ConfigureAwait(false);
string executionId = executions.FirstOrDefault()?.Id;
if (executionId != null)
{
var result = await _client.GetAuthenticationExecutionAsync(realm, executionId);
var result = await _client.GetAuthenticationExecutionAsync(realm, executionId).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand All @@ -69,19 +69,19 @@ public async Task GetAuthenticationExecutionAsync(string realm)
[InlineData("Insurance")]
public async Task GetAuthenticationFlowsAsync(string realm)
{
var result = await _client.GetAuthenticationFlowsAsync(realm);
var result = await _client.GetAuthenticationFlowsAsync(realm).ConfigureAwait(false);
Assert.NotNull(result);
}

[Theory]
[InlineData("Insurance")]
public async Task GetAuthenticationFlowExecutionsAsync(string realm)
{
var flows = await _client.GetAuthenticationFlowsAsync(realm);
var flows = await _client.GetAuthenticationFlowsAsync(realm).ConfigureAwait(false);
string flowAlias = flows.FirstOrDefault()?.Alias;
if (flowAlias != null)
{
var result = await _client.GetAuthenticationFlowExecutionsAsync(realm, flowAlias);
var result = await _client.GetAuthenticationFlowExecutionsAsync(realm, flowAlias).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand All @@ -90,11 +90,11 @@ public async Task GetAuthenticationFlowExecutionsAsync(string realm)
[InlineData("Insurance")]
public async Task GetAuthenticationFlowByIdAsync(string realm)
{
var flows = await _client.GetAuthenticationFlowsAsync(realm);
var flows = await _client.GetAuthenticationFlowsAsync(realm).ConfigureAwait(false);
string flowId = flows.FirstOrDefault()?.Id;
if (flowId != null)
{
var result = await _client.GetAuthenticationFlowByIdAsync(realm, flowId);
var result = await _client.GetAuthenticationFlowByIdAsync(realm, flowId).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand All @@ -103,43 +103,43 @@ public async Task GetAuthenticationFlowByIdAsync(string realm)
[InlineData("Insurance")]
public async Task GetFormActionProvidersAsync(string realm)
{
var result = await _client.GetFormActionProvidersAsync(realm);
var result = await _client.GetFormActionProvidersAsync(realm).ConfigureAwait(false);
Assert.NotNull(result);
}

[Theory]
[InlineData("Insurance")]
public async Task GetFormProvidersAsync(string realm)
{
var result = await _client.GetFormProvidersAsync(realm);
var result = await _client.GetFormProvidersAsync(realm).ConfigureAwait(false);
Assert.NotNull(result);
}

[Theory]
[InlineData("Insurance")]
public async Task GetConfigurationDescriptionsForAllClientsAsync(string realm)
{
var result = await _client.GetConfigurationDescriptionsForAllClientsAsync(realm);
var result = await _client.GetConfigurationDescriptionsForAllClientsAsync(realm).ConfigureAwait(false);
Assert.NotNull(result);
}

[Theory]
[InlineData("Insurance")]
public async Task GetRequiredActionsAsync(string realm)
{
var result = await _client.GetRequiredActionsAsync(realm);
var result = await _client.GetRequiredActionsAsync(realm).ConfigureAwait(false);
Assert.NotNull(result);
}

[Theory]
[InlineData("Insurance")]
public async Task GetRequiredActionByAliasAsync(string realm)
{
var requiredActions = await _client.GetRequiredActionsAsync(realm);
var requiredActions = await _client.GetRequiredActionsAsync(realm).ConfigureAwait(false);
string requiredActionAlias = requiredActions.FirstOrDefault()?.Alias;
if (requiredActionAlias != null)
{
var result = await _client.GetRequiredActionByAliasAsync(realm, requiredActionAlias);
var result = await _client.GetRequiredActionByAliasAsync(realm, requiredActionAlias).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand All @@ -148,7 +148,7 @@ public async Task GetRequiredActionByAliasAsync(string realm)
[InlineData("Insurance")]
public async Task GetUnregisteredRequiredActionsAsync(string realm)
{
var result = await _client.GetUnregisteredRequiredActionsAsync(realm);
var result = await _client.GetUnregisteredRequiredActionsAsync(realm).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ public partial class KeycloakClientShould
[InlineData("Insurance")]
public async Task GetKeyInfoAsync(string realm)
{
var clients = await _client.GetClientsAsync(realm);
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
(string clientId, string attribute) = clients
.Where(x => x.Attributes.Any())
.Select(client => (client.Id, client.Attributes.FirstOrDefault().Key))
.FirstOrDefault();
if (clientId != null)
{
var result = await _client.GetKeyInfoAsync(realm, clientId, attribute);
var result = await _client.GetKeyInfoAsync(realm, clientId, attribute).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public partial class KeycloakClientShould
[InlineData("Insurance")]
public async Task GetClientInitialAccessAsync(string realm)
{
var result = await _client.GetClientInitialAccessAsync(realm);
var result = await _client.GetClientInitialAccessAsync(realm).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public partial class KeycloakClientShould
[InlineData("Insurance")]
public async Task GetRetrieveProvidersBasePathAsync(string realm)
{
var result = await _client.GetRetrieveProvidersBasePathAsync(realm);
var result = await _client.GetRetrieveProvidersBasePathAsync(realm).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand Down
36 changes: 18 additions & 18 deletions test/Keycloak.Net.Tests/ClientRoleMappings/KeycloakClientShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ public partial class KeycloakClientShould
[InlineData("Insurance", "insurance-product")]
public async Task GetClientRoleMappingsForGroupAsync(string realm, string clientId)
{
var groups = await _client.GetGroupHierarchyAsync(realm);
var groups = await _client.GetGroupHierarchyAsync(realm).ConfigureAwait(false);
string groupId = groups.FirstOrDefault()?.Id;
if (groupId != null)
{
var clients = await _client.GetClientsAsync(realm);
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
if (clientId != null)
{
var result = await _client.GetClientRoleMappingsForGroupAsync(realm, groupId, clientsId);
var result = await _client.GetClientRoleMappingsForGroupAsync(realm, groupId, clientsId).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand All @@ -28,15 +28,15 @@ public async Task GetClientRoleMappingsForGroupAsync(string realm, string client
[InlineData("Insurance", "insurance-product")]
public async Task GetAvailableClientRoleMappingsForGroupAsync(string realm, string clientId)
{
var groups = await _client.GetGroupHierarchyAsync(realm);
var groups = await _client.GetGroupHierarchyAsync(realm).ConfigureAwait(false);
string groupId = groups.FirstOrDefault()?.Id;
if (groupId != null)
{
var clients = await _client.GetClientsAsync(realm);
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
if (clientId != null)
{
var result = await _client.GetAvailableClientRoleMappingsForGroupAsync(realm, groupId, clientsId);
var result = await _client.GetAvailableClientRoleMappingsForGroupAsync(realm, groupId, clientsId).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand All @@ -46,15 +46,15 @@ public async Task GetAvailableClientRoleMappingsForGroupAsync(string realm, stri
[InlineData("Insurance", "insurance-product")]
public async Task GetEffectiveClientRoleMappingsForGroupAsync(string realm, string clientId)
{
var groups = await _client.GetGroupHierarchyAsync(realm);
var groups = await _client.GetGroupHierarchyAsync(realm).ConfigureAwait(false);
string groupId = groups.FirstOrDefault()?.Id;
if (groupId != null)
{
var clients = await _client.GetClientsAsync(realm);
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
if (clientId != null)
{
var result = await _client.GetEffectiveClientRoleMappingsForGroupAsync(realm, groupId, clientsId);
var result = await _client.GetEffectiveClientRoleMappingsForGroupAsync(realm, groupId, clientsId).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand All @@ -64,15 +64,15 @@ public async Task GetEffectiveClientRoleMappingsForGroupAsync(string realm, stri
[InlineData("Insurance", "insurance-product")]
public async Task GetClientRoleMappingsForUserAsync(string realm, string clientId)
{
var users = await _client.GetUsersAsync(realm);
var users = await _client.GetUsersAsync(realm).ConfigureAwait(false);
string userId = users.FirstOrDefault()?.Id;
if (userId != null)
{
var clients = await _client.GetClientsAsync(realm);
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
if (clientId != null)
{
var result = await _client.GetClientRoleMappingsForUserAsync(realm, userId, clientsId);
var result = await _client.GetClientRoleMappingsForUserAsync(realm, userId, clientsId).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand All @@ -82,15 +82,15 @@ public async Task GetClientRoleMappingsForUserAsync(string realm, string clientI
[InlineData("Insurance", "insurance-product")]
public async Task GetAvailableClientRoleMappingsForUserAsync(string realm, string clientId)
{
var users = await _client.GetUsersAsync(realm);
var users = await _client.GetUsersAsync(realm).ConfigureAwait(false);
string userId = users.FirstOrDefault()?.Id;
if (userId != null)
{
var clients = await _client.GetClientsAsync(realm);
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
if (clientId != null)
{
var result = await _client.GetAvailableClientRoleMappingsForUserAsync(realm, userId, clientsId);
var result = await _client.GetAvailableClientRoleMappingsForUserAsync(realm, userId, clientsId).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand All @@ -100,15 +100,15 @@ public async Task GetAvailableClientRoleMappingsForUserAsync(string realm, strin
[InlineData("Insurance", "insurance-product")]
public async Task GetEffectiveClientRoleMappingsForUserAsync(string realm, string clientId)
{
var users = await _client.GetUsersAsync(realm);
var users = await _client.GetUsersAsync(realm).ConfigureAwait(false);
string userId = users.FirstOrDefault()?.Id;
if (userId != null)
{
var clients = await _client.GetClientsAsync(realm);
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
if (clientId != null)
{
var result = await _client.GetEffectiveClientRoleMappingsForUserAsync(realm, userId, clientsId);
var result = await _client.GetEffectiveClientRoleMappingsForUserAsync(realm, userId, clientsId).ConfigureAwait(false);
Assert.NotNull(result);
}
}
Expand Down
Loading

0 comments on commit ac977cc

Please sign in to comment.