Skip to content

Commit ac977cc

Browse files
committed
add missing ConfigureAwait(false)
1 parent fa3920e commit ac977cc

File tree

23 files changed

+256
-256
lines changed

23 files changed

+256
-256
lines changed

src/Keycloak.Net/Common/Extensions/FlurlRequestExtensions.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ public static class FlurlRequestExtensions
1010
{
1111
private static async Task<string> GetAccessTokenAsync(string url, string realm, string userName, string password)
1212
{
13-
var result = await url
14-
.AppendPathSegment($"/auth/realms/{realm}/protocol/openid-connect/token")
15-
.WithHeader("Accept", "application/json")
16-
.PostUrlEncodedAsync(new List<KeyValuePair<string, string>>
17-
{
18-
new KeyValuePair<string, string>("grant_type", "password"),
19-
new KeyValuePair<string, string>("username", userName),
20-
new KeyValuePair<string, string>("password", password),
21-
new KeyValuePair<string, string>("client_id", "admin-cli")
22-
})
23-
.ReceiveJson();
13+
var result = await url
14+
.AppendPathSegment($"/auth/realms/{realm}/protocol/openid-connect/token")
15+
.WithHeader("Accept", "application/json")
16+
.PostUrlEncodedAsync(new List<KeyValuePair<string, string>>
17+
{
18+
new KeyValuePair<string, string>("grant_type", "password"),
19+
new KeyValuePair<string, string>("username", userName),
20+
new KeyValuePair<string, string>("password", password),
21+
new KeyValuePair<string, string>("client_id", "admin-cli")
22+
})
23+
.ReceiveJson().ConfigureAwait(false);
2424

2525
string accessToken = result
2626
.access_token.ToString();

src/Keycloak.Net/Users/KeycloakClient.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public partial class KeycloakClient
1313
{
1414
public async Task<bool> CreateUserAsync(string realm, User user)
1515
{
16-
var response = await InternalCreateUserAsync(realm, user);
16+
var response = await InternalCreateUserAsync(realm, user).ConfigureAwait(false);
1717
return response.IsSuccessStatusCode;
1818
}
1919

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

2525
public async Task<string> CreateAndRetrieveUserIdAsync(string realm, User user)
2626
{
27-
var response = await InternalCreateUserAsync(realm, user);
27+
var response = await InternalCreateUserAsync(realm, user).ConfigureAwait(false);
2828
string locationPathAndQuery = response.Headers.Location.PathAndQuery;
2929
string userId = response.IsSuccessStatusCode ? locationPathAndQuery.Substring(locationPathAndQuery.LastIndexOf("/", StringComparison.Ordinal) + 1) : null;
3030
return userId;

test/Keycloak.Net.Tests/AttackDetection/KeycloakClientShould.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ public partial class KeycloakClientShould
1010
[InlineData("Insurance", "vermeulen")]
1111
public async Task GetUserNameStatusInBruteForceDetectionAsync(string realm, string search)
1212
{
13-
var users = await _client.GetUsersAsync(realm, search: search);
13+
var users = await _client.GetUsersAsync(realm, search: search).ConfigureAwait(false);
1414
string userId = users.FirstOrDefault()?.Id;
1515
if (userId != null)
1616
{
17-
var result = await _client.GetUserNameStatusInBruteForceDetectionAsync(realm, userId);
17+
var result = await _client.GetUserNameStatusInBruteForceDetectionAsync(realm, userId).ConfigureAwait(false);
1818
Assert.NotNull(result);
1919
}
2020
}

test/Keycloak.Net.Tests/AuthenticationManagement/KeycloakClientShould.cs

+20-20
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,27 @@ public partial class KeycloakClientShould
1010
[InlineData("Insurance")]
1111
public async Task GetAuthenticatorProvidersAsync(string realm)
1212
{
13-
var result = await _client.GetAuthenticatorProvidersAsync(realm);
13+
var result = await _client.GetAuthenticatorProvidersAsync(realm).ConfigureAwait(false);
1414
Assert.NotNull(result);
1515
}
1616

1717
[Theory]
1818
[InlineData("Insurance")]
1919
public async Task GetClientAuthenticatorProvidersAsync(string realm)
2020
{
21-
var result = await _client.GetClientAuthenticatorProvidersAsync(realm);
21+
var result = await _client.GetClientAuthenticatorProvidersAsync(realm).ConfigureAwait(false);
2222
Assert.NotNull(result);
2323
}
2424

2525
[Theory]
2626
[InlineData("Insurance")]
2727
public async Task GetAuthenticatorProviderConfigurationDescriptionAsync(string realm)
2828
{
29-
var providers = await _client.GetAuthenticatorProvidersAsync(realm);
29+
var providers = await _client.GetAuthenticatorProvidersAsync(realm).ConfigureAwait(false);
3030
string providerId = providers.FirstOrDefault()?.FirstOrDefault(x => x.Key == "id").Value.ToString();
3131
if (providerId != null)
3232
{
33-
var result = await _client.GetAuthenticatorProviderConfigurationDescriptionAsync(realm, providerId);
33+
var result = await _client.GetAuthenticatorProviderConfigurationDescriptionAsync(realm, providerId).ConfigureAwait(false);
3434
Assert.NotNull(result);
3535
}
3636
}
@@ -42,7 +42,7 @@ public async Task GetAuthenticatorConfigurationAsync(string realm)
4242
string configurationId = ""; //TODO
4343
if (configurationId != null)
4444
{
45-
var result = await _client.GetAuthenticatorConfigurationAsync(realm, configurationId);
45+
var result = await _client.GetAuthenticatorConfigurationAsync(realm, configurationId).ConfigureAwait(false);
4646
Assert.NotNull(result);
4747
}
4848
}
@@ -51,15 +51,15 @@ public async Task GetAuthenticatorConfigurationAsync(string realm)
5151
[InlineData("Insurance")]
5252
public async Task GetAuthenticationExecutionAsync(string realm)
5353
{
54-
var flows = await _client.GetAuthenticationFlowsAsync(realm);
54+
var flows = await _client.GetAuthenticationFlowsAsync(realm).ConfigureAwait(false);
5555
string flowAlias = flows.FirstOrDefault()?.Alias;
5656
if (flowAlias != null)
5757
{
58-
var executions = await _client.GetAuthenticationFlowExecutionsAsync(realm, flowAlias);
58+
var executions = await _client.GetAuthenticationFlowExecutionsAsync(realm, flowAlias).ConfigureAwait(false);
5959
string executionId = executions.FirstOrDefault()?.Id;
6060
if (executionId != null)
6161
{
62-
var result = await _client.GetAuthenticationExecutionAsync(realm, executionId);
62+
var result = await _client.GetAuthenticationExecutionAsync(realm, executionId).ConfigureAwait(false);
6363
Assert.NotNull(result);
6464
}
6565
}
@@ -69,19 +69,19 @@ public async Task GetAuthenticationExecutionAsync(string realm)
6969
[InlineData("Insurance")]
7070
public async Task GetAuthenticationFlowsAsync(string realm)
7171
{
72-
var result = await _client.GetAuthenticationFlowsAsync(realm);
72+
var result = await _client.GetAuthenticationFlowsAsync(realm).ConfigureAwait(false);
7373
Assert.NotNull(result);
7474
}
7575

7676
[Theory]
7777
[InlineData("Insurance")]
7878
public async Task GetAuthenticationFlowExecutionsAsync(string realm)
7979
{
80-
var flows = await _client.GetAuthenticationFlowsAsync(realm);
80+
var flows = await _client.GetAuthenticationFlowsAsync(realm).ConfigureAwait(false);
8181
string flowAlias = flows.FirstOrDefault()?.Alias;
8282
if (flowAlias != null)
8383
{
84-
var result = await _client.GetAuthenticationFlowExecutionsAsync(realm, flowAlias);
84+
var result = await _client.GetAuthenticationFlowExecutionsAsync(realm, flowAlias).ConfigureAwait(false);
8585
Assert.NotNull(result);
8686
}
8787
}
@@ -90,11 +90,11 @@ public async Task GetAuthenticationFlowExecutionsAsync(string realm)
9090
[InlineData("Insurance")]
9191
public async Task GetAuthenticationFlowByIdAsync(string realm)
9292
{
93-
var flows = await _client.GetAuthenticationFlowsAsync(realm);
93+
var flows = await _client.GetAuthenticationFlowsAsync(realm).ConfigureAwait(false);
9494
string flowId = flows.FirstOrDefault()?.Id;
9595
if (flowId != null)
9696
{
97-
var result = await _client.GetAuthenticationFlowByIdAsync(realm, flowId);
97+
var result = await _client.GetAuthenticationFlowByIdAsync(realm, flowId).ConfigureAwait(false);
9898
Assert.NotNull(result);
9999
}
100100
}
@@ -103,43 +103,43 @@ public async Task GetAuthenticationFlowByIdAsync(string realm)
103103
[InlineData("Insurance")]
104104
public async Task GetFormActionProvidersAsync(string realm)
105105
{
106-
var result = await _client.GetFormActionProvidersAsync(realm);
106+
var result = await _client.GetFormActionProvidersAsync(realm).ConfigureAwait(false);
107107
Assert.NotNull(result);
108108
}
109109

110110
[Theory]
111111
[InlineData("Insurance")]
112112
public async Task GetFormProvidersAsync(string realm)
113113
{
114-
var result = await _client.GetFormProvidersAsync(realm);
114+
var result = await _client.GetFormProvidersAsync(realm).ConfigureAwait(false);
115115
Assert.NotNull(result);
116116
}
117117

118118
[Theory]
119119
[InlineData("Insurance")]
120120
public async Task GetConfigurationDescriptionsForAllClientsAsync(string realm)
121121
{
122-
var result = await _client.GetConfigurationDescriptionsForAllClientsAsync(realm);
122+
var result = await _client.GetConfigurationDescriptionsForAllClientsAsync(realm).ConfigureAwait(false);
123123
Assert.NotNull(result);
124124
}
125125

126126
[Theory]
127127
[InlineData("Insurance")]
128128
public async Task GetRequiredActionsAsync(string realm)
129129
{
130-
var result = await _client.GetRequiredActionsAsync(realm);
130+
var result = await _client.GetRequiredActionsAsync(realm).ConfigureAwait(false);
131131
Assert.NotNull(result);
132132
}
133133

134134
[Theory]
135135
[InlineData("Insurance")]
136136
public async Task GetRequiredActionByAliasAsync(string realm)
137137
{
138-
var requiredActions = await _client.GetRequiredActionsAsync(realm);
138+
var requiredActions = await _client.GetRequiredActionsAsync(realm).ConfigureAwait(false);
139139
string requiredActionAlias = requiredActions.FirstOrDefault()?.Alias;
140140
if (requiredActionAlias != null)
141141
{
142-
var result = await _client.GetRequiredActionByAliasAsync(realm, requiredActionAlias);
142+
var result = await _client.GetRequiredActionByAliasAsync(realm, requiredActionAlias).ConfigureAwait(false);
143143
Assert.NotNull(result);
144144
}
145145
}
@@ -148,7 +148,7 @@ public async Task GetRequiredActionByAliasAsync(string realm)
148148
[InlineData("Insurance")]
149149
public async Task GetUnregisteredRequiredActionsAsync(string realm)
150150
{
151-
var result = await _client.GetUnregisteredRequiredActionsAsync(realm);
151+
var result = await _client.GetUnregisteredRequiredActionsAsync(realm).ConfigureAwait(false);
152152
Assert.NotNull(result);
153153
}
154154
}

test/Keycloak.Net.Tests/ClientAttributeCertificate/KeycloakClientShould.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ public partial class KeycloakClientShould
1010
[InlineData("Insurance")]
1111
public async Task GetKeyInfoAsync(string realm)
1212
{
13-
var clients = await _client.GetClientsAsync(realm);
13+
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
1414
(string clientId, string attribute) = clients
1515
.Where(x => x.Attributes.Any())
1616
.Select(client => (client.Id, client.Attributes.FirstOrDefault().Key))
1717
.FirstOrDefault();
1818
if (clientId != null)
1919
{
20-
var result = await _client.GetKeyInfoAsync(realm, clientId, attribute);
20+
var result = await _client.GetKeyInfoAsync(realm, clientId, attribute).ConfigureAwait(false);
2121
Assert.NotNull(result);
2222
}
2323
}

test/Keycloak.Net.Tests/ClientInitialAccess/KeycloakClientShould.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public partial class KeycloakClientShould
99
[InlineData("Insurance")]
1010
public async Task GetClientInitialAccessAsync(string realm)
1111
{
12-
var result = await _client.GetClientInitialAccessAsync(realm);
12+
var result = await _client.GetClientInitialAccessAsync(realm).ConfigureAwait(false);
1313
Assert.NotNull(result);
1414
}
1515
}

test/Keycloak.Net.Tests/ClientRegistrationPolicy/KeycloakClientShould.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public partial class KeycloakClientShould
99
[InlineData("Insurance")]
1010
public async Task GetRetrieveProvidersBasePathAsync(string realm)
1111
{
12-
var result = await _client.GetRetrieveProvidersBasePathAsync(realm);
12+
var result = await _client.GetRetrieveProvidersBasePathAsync(realm).ConfigureAwait(false);
1313
Assert.NotNull(result);
1414
}
1515
}

test/Keycloak.Net.Tests/ClientRoleMappings/KeycloakClientShould.cs

+18-18
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ public partial class KeycloakClientShould
1010
[InlineData("Insurance", "insurance-product")]
1111
public async Task GetClientRoleMappingsForGroupAsync(string realm, string clientId)
1212
{
13-
var groups = await _client.GetGroupHierarchyAsync(realm);
13+
var groups = await _client.GetGroupHierarchyAsync(realm).ConfigureAwait(false);
1414
string groupId = groups.FirstOrDefault()?.Id;
1515
if (groupId != null)
1616
{
17-
var clients = await _client.GetClientsAsync(realm);
17+
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
1818
string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
1919
if (clientId != null)
2020
{
21-
var result = await _client.GetClientRoleMappingsForGroupAsync(realm, groupId, clientsId);
21+
var result = await _client.GetClientRoleMappingsForGroupAsync(realm, groupId, clientsId).ConfigureAwait(false);
2222
Assert.NotNull(result);
2323
}
2424
}
@@ -28,15 +28,15 @@ public async Task GetClientRoleMappingsForGroupAsync(string realm, string client
2828
[InlineData("Insurance", "insurance-product")]
2929
public async Task GetAvailableClientRoleMappingsForGroupAsync(string realm, string clientId)
3030
{
31-
var groups = await _client.GetGroupHierarchyAsync(realm);
31+
var groups = await _client.GetGroupHierarchyAsync(realm).ConfigureAwait(false);
3232
string groupId = groups.FirstOrDefault()?.Id;
3333
if (groupId != null)
3434
{
35-
var clients = await _client.GetClientsAsync(realm);
35+
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
3636
string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
3737
if (clientId != null)
3838
{
39-
var result = await _client.GetAvailableClientRoleMappingsForGroupAsync(realm, groupId, clientsId);
39+
var result = await _client.GetAvailableClientRoleMappingsForGroupAsync(realm, groupId, clientsId).ConfigureAwait(false);
4040
Assert.NotNull(result);
4141
}
4242
}
@@ -46,15 +46,15 @@ public async Task GetAvailableClientRoleMappingsForGroupAsync(string realm, stri
4646
[InlineData("Insurance", "insurance-product")]
4747
public async Task GetEffectiveClientRoleMappingsForGroupAsync(string realm, string clientId)
4848
{
49-
var groups = await _client.GetGroupHierarchyAsync(realm);
49+
var groups = await _client.GetGroupHierarchyAsync(realm).ConfigureAwait(false);
5050
string groupId = groups.FirstOrDefault()?.Id;
5151
if (groupId != null)
5252
{
53-
var clients = await _client.GetClientsAsync(realm);
53+
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
5454
string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
5555
if (clientId != null)
5656
{
57-
var result = await _client.GetEffectiveClientRoleMappingsForGroupAsync(realm, groupId, clientsId);
57+
var result = await _client.GetEffectiveClientRoleMappingsForGroupAsync(realm, groupId, clientsId).ConfigureAwait(false);
5858
Assert.NotNull(result);
5959
}
6060
}
@@ -64,15 +64,15 @@ public async Task GetEffectiveClientRoleMappingsForGroupAsync(string realm, stri
6464
[InlineData("Insurance", "insurance-product")]
6565
public async Task GetClientRoleMappingsForUserAsync(string realm, string clientId)
6666
{
67-
var users = await _client.GetUsersAsync(realm);
67+
var users = await _client.GetUsersAsync(realm).ConfigureAwait(false);
6868
string userId = users.FirstOrDefault()?.Id;
6969
if (userId != null)
7070
{
71-
var clients = await _client.GetClientsAsync(realm);
71+
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
7272
string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
7373
if (clientId != null)
7474
{
75-
var result = await _client.GetClientRoleMappingsForUserAsync(realm, userId, clientsId);
75+
var result = await _client.GetClientRoleMappingsForUserAsync(realm, userId, clientsId).ConfigureAwait(false);
7676
Assert.NotNull(result);
7777
}
7878
}
@@ -82,15 +82,15 @@ public async Task GetClientRoleMappingsForUserAsync(string realm, string clientI
8282
[InlineData("Insurance", "insurance-product")]
8383
public async Task GetAvailableClientRoleMappingsForUserAsync(string realm, string clientId)
8484
{
85-
var users = await _client.GetUsersAsync(realm);
85+
var users = await _client.GetUsersAsync(realm).ConfigureAwait(false);
8686
string userId = users.FirstOrDefault()?.Id;
8787
if (userId != null)
8888
{
89-
var clients = await _client.GetClientsAsync(realm);
89+
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
9090
string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
9191
if (clientId != null)
9292
{
93-
var result = await _client.GetAvailableClientRoleMappingsForUserAsync(realm, userId, clientsId);
93+
var result = await _client.GetAvailableClientRoleMappingsForUserAsync(realm, userId, clientsId).ConfigureAwait(false);
9494
Assert.NotNull(result);
9595
}
9696
}
@@ -100,15 +100,15 @@ public async Task GetAvailableClientRoleMappingsForUserAsync(string realm, strin
100100
[InlineData("Insurance", "insurance-product")]
101101
public async Task GetEffectiveClientRoleMappingsForUserAsync(string realm, string clientId)
102102
{
103-
var users = await _client.GetUsersAsync(realm);
103+
var users = await _client.GetUsersAsync(realm).ConfigureAwait(false);
104104
string userId = users.FirstOrDefault()?.Id;
105105
if (userId != null)
106106
{
107-
var clients = await _client.GetClientsAsync(realm);
107+
var clients = await _client.GetClientsAsync(realm).ConfigureAwait(false);
108108
string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
109109
if (clientId != null)
110110
{
111-
var result = await _client.GetEffectiveClientRoleMappingsForUserAsync(realm, userId, clientsId);
111+
var result = await _client.GetEffectiveClientRoleMappingsForUserAsync(realm, userId, clientsId).ConfigureAwait(false);
112112
Assert.NotNull(result);
113113
}
114114
}

0 commit comments

Comments
 (0)