Skip to content

Commit 248a9ca

Browse files
committed
refactor: use Duende.IdentityModel.Client
1 parent 6cd7977 commit 248a9ca

28 files changed

+217
-215
lines changed

src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/ClientAssertionClient.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44

5-
using System;
6-
using System.Collections.Generic;
7-
using System.IdentityModel.Tokens.Jwt;
8-
using System.Linq;
9-
using System.Net.Http;
10-
using System.Security.Claims;
11-
using System.Text;
12-
using System.Threading.Tasks;
13-
using FluentAssertions;
145
using Duende.IdentityModel;
15-
using IdentityModel.Client;
6+
using Duende.IdentityModel.Client;
7+
using FluentAssertions;
168
using IdentityServer.IntegrationTests.Clients.Setup;
179
using IdentityServer.IntegrationTests.Common;
1810
using Microsoft.AspNetCore.Hosting;
1911
using Microsoft.AspNetCore.TestHost;
2012
using Microsoft.IdentityModel.Tokens;
2113
using Newtonsoft.Json;
2214
using Newtonsoft.Json.Linq;
15+
using System;
16+
using System.Collections.Generic;
17+
using System.IdentityModel.Tokens.Jwt;
18+
using System.Linq;
19+
using System.Net.Http;
20+
using System.Security.Claims;
21+
using System.Text;
22+
using System.Threading.Tasks;
2323
using Xunit;
2424

2525
namespace IdentityServer.IntegrationTests.Clients

src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/ClientCredentialsAndResourceOwnerClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44

5-
using System.Net.Http;
6-
using System.Threading.Tasks;
5+
using Duende.IdentityModel.Client;
76
using FluentAssertions;
8-
using IdentityModel.Client;
97
using IdentityServer.IntegrationTests.Clients.Setup;
108
using Microsoft.AspNetCore.Hosting;
119
using Microsoft.AspNetCore.TestHost;
10+
using System.Net.Http;
11+
using System.Threading.Tasks;
1212
using Xunit;
1313

1414
namespace IdentityServer.IntegrationTests.Clients

src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/ClientCredentialsClient.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44

5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Net;
8-
using System.Net.Http;
9-
using System.Text;
10-
using System.Threading.Tasks;
11-
using FluentAssertions;
125
using Duende.IdentityModel;
13-
using IdentityModel.Client;
6+
using Duende.IdentityModel.Client;
7+
using FluentAssertions;
148
using IdentityServer.IntegrationTests.Clients.Setup;
159
using Microsoft.AspNetCore.Hosting;
1610
using Microsoft.AspNetCore.TestHost;
1711
using Newtonsoft.Json;
1812
using Newtonsoft.Json.Linq;
13+
using System.Collections.Generic;
14+
using System.Linq;
15+
using System.Net;
16+
using System.Net.Http;
17+
using System.Text;
18+
using System.Threading.Tasks;
1919
using Xunit;
2020

2121
namespace IdentityServer.IntegrationTests.Clients
@@ -108,7 +108,7 @@ public async Task Valid_request_multiple_audiences_should_return_expected_payloa
108108
payload.Keys.Should().Contain("jti");
109109
payload.Keys.Should().Contain("iat");
110110

111-
var audiences = ((JArray)payload["aud"]).Select(x => x.ToString());
111+
var audiences = ((JArray) payload["aud"]).Select(x => x.ToString());
112112
audiences.Count().Should().Be(2);
113113
audiences.Should().Contain("api");
114114
audiences.Should().Contain("other_api");
@@ -208,12 +208,12 @@ public async Task Request_with_no_explicit_scopes_should_return_expected_payload
208208
payload.Keys.Should().Contain("jti");
209209
payload.Keys.Should().Contain("iat");
210210

211-
var audiences = ((JArray)payload["aud"]).Select(x => x.ToString());
211+
var audiences = ((JArray) payload["aud"]).Select(x => x.ToString());
212212
audiences.Count().Should().Be(2);
213213
audiences.Should().Contain("api");
214214
audiences.Should().Contain("other_api");
215215

216-
var scopes = ((JArray)payload["scope"]).Select(x => x.ToString());
216+
var scopes = ((JArray) payload["scope"]).Select(x => x.ToString());
217217
scopes.Count().Should().Be(3);
218218
scopes.Should().Contain("api1");
219219
scopes.Should().Contain("api2");

src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/CustomTokenRequestValidatorClient.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4-
using System.Collections.Generic;
5-
using System.Net.Http;
6-
using System.Threading.Tasks;
4+
using Duende.IdentityModel.Client;
75
using FluentAssertions;
8-
using IdentityModel.Client;
96
using IdentityServer.IntegrationTests.Clients.Setup;
107
using Microsoft.AspNetCore.Hosting;
118
using Microsoft.AspNetCore.TestHost;
129
using Newtonsoft.Json;
10+
using System.Collections.Generic;
11+
using System.Net.Http;
12+
using System.Threading.Tasks;
1313
using Xunit;
1414

1515
namespace IdentityServer.IntegrationTests.Clients

src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/CustomTokenResponseClients.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44

5-
using System;
6-
using System.Collections.Generic;
7-
using System.Linq;
8-
using System.Net.Http;
9-
using System.Text;
10-
using System.Text.Json;
11-
using System.Threading.Tasks;
12-
using FluentAssertions;
135
using Duende.IdentityModel;
14-
using IdentityModel.Client;
6+
using Duende.IdentityModel.Client;
7+
using FluentAssertions;
158
using IdentityServer.IntegrationTests.Clients.Setup;
169
using Microsoft.AspNetCore.Hosting;
1710
using Microsoft.AspNetCore.TestHost;
1811
using Newtonsoft.Json;
1912
using Newtonsoft.Json.Linq;
13+
using System;
14+
using System.Collections.Generic;
15+
using System.Linq;
16+
using System.Net.Http;
17+
using System.Text;
18+
using System.Threading.Tasks;
2019
using Xunit;
2120

2221
namespace IdentityServer.IntegrationTests.Clients
@@ -53,7 +52,7 @@ public async Task Resource_owner_success_should_return_custom_response()
5352
// raw fields
5453
var fields = GetFields(response);
5554
fields.Should().Contain("string_value", "some_string");
56-
((Int64)fields["int_value"]).Should().Be(42);
55+
((Int64) fields["int_value"]).Should().Be(42);
5756

5857
object temp;
5958
fields.TryGetValue("identity_token", out temp).Should().BeFalse();
@@ -118,7 +117,7 @@ public async Task Resource_owner_failure_should_return_custom_error_response()
118117
// raw fields
119118
var fields = GetFields(response);
120119
fields.Should().Contain("string_value", "some_string");
121-
((Int64)fields["int_value"]).Should().Be(42);
120+
((Int64) fields["int_value"]).Should().Be(42);
122121

123122
object temp;
124123
fields.TryGetValue("identity_token", out temp).Should().BeFalse();
@@ -172,7 +171,7 @@ public async Task Extension_grant_success_should_return_custom_response()
172171
// raw fields
173172
var fields = GetFields(response);
174173
fields.Should().Contain("string_value", "some_string");
175-
((Int64)fields["int_value"]).Should().Be(42);
174+
((Int64) fields["int_value"]).Should().Be(42);
176175

177176
object temp;
178177
fields.TryGetValue("identity_token", out temp).Should().BeFalse();
@@ -243,7 +242,7 @@ public async Task Extension_grant_failure_should_return_custom_error_response()
243242
// raw fields
244243
var fields = GetFields(response);
245244
fields.Should().Contain("string_value", "some_string");
246-
((Int64)fields["int_value"]).Should().Be(42);
245+
((Int64) fields["int_value"]).Should().Be(42);
247246

248247
object temp;
249248
fields.TryGetValue("identity_token", out temp).Should().BeFalse();

src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/DiscoveryClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44

5+
using Duende.IdentityModel.Client;
56
using FluentAssertions;
6-
using IdentityModel.Client;
7+
using IdentityServer.IntegrationTests.Clients.Setup;
78
using Microsoft.AspNetCore.Hosting;
89
using Microsoft.AspNetCore.TestHost;
910
using System.Linq;
1011
using System.Net.Http;
1112
using System.Threading.Tasks;
12-
using IdentityServer.IntegrationTests.Clients.Setup;
1313
using Xunit;
1414

1515
namespace IdentityServer.IntegrationTests.Clients

src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/ExtensionGrantClient.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44

5+
using Duende.IdentityModel;
6+
using Duende.IdentityModel.Client;
7+
using FluentAssertions;
8+
using IdentityServer.IntegrationTests.Clients.Setup;
9+
using Microsoft.AspNetCore.Hosting;
10+
using Microsoft.AspNetCore.TestHost;
11+
using Newtonsoft.Json;
12+
using Newtonsoft.Json.Linq;
513
using System;
614
using System.Collections.Generic;
715
using System.IdentityModel.Tokens.Jwt;
@@ -10,14 +18,6 @@
1018
using System.Net.Http;
1119
using System.Text;
1220
using System.Threading.Tasks;
13-
using FluentAssertions;
14-
using Duende.IdentityModel;
15-
using IdentityModel.Client;
16-
using IdentityServer.IntegrationTests.Clients.Setup;
17-
using Microsoft.AspNetCore.Hosting;
18-
using Microsoft.AspNetCore.TestHost;
19-
using Newtonsoft.Json;
20-
using Newtonsoft.Json.Linq;
2121
using Xunit;
2222

2323
namespace IdentityServer.IntegrationTests.Clients

src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/RefreshTokenClient.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44

5-
using System.Net.Http;
6-
using System.Threading.Tasks;
5+
using Duende.IdentityModel.Client;
76
using FluentAssertions;
8-
using IdentityModel.Client;
97
using IdentityServer.IntegrationTests.Clients.Setup;
108
using Microsoft.AspNetCore.Hosting;
119
using Microsoft.AspNetCore.TestHost;
10+
using System.Net.Http;
11+
using System.Threading.Tasks;
1212
using Xunit;
1313

1414
namespace IdentityServer.IntegrationTests.Clients
@@ -142,7 +142,7 @@ public async Task Refreshing_a_refresh_token_with_reuse_should_return_same_refre
142142

143143
rt1.Should().BeEquivalentTo(rt2);
144144
}
145-
145+
146146
[Fact]
147147
public async Task Refreshing_a_refresh_token_with_one_time_only_should_return_different_refresh_token()
148148
{
@@ -184,7 +184,7 @@ public async Task Refreshing_a_refresh_token_with_one_time_only_should_return_di
184184

185185
rt1.Should().NotBeEquivalentTo(rt2);
186186
}
187-
187+
188188
[Fact]
189189
public async Task Replaying_a_rotated_token_should_fail()
190190
{
@@ -223,7 +223,7 @@ public async Task Replaying_a_rotated_token_should_fail()
223223
response.TokenType.Should().Be("Bearer");
224224
response.IdentityToken.Should().NotBeNull();
225225
response.RefreshToken.Should().NotBeNull();
226-
226+
227227
// refresh token (again)
228228
response = await _client.RequestRefreshTokenAsync(new RefreshTokenRequest
229229
{
@@ -237,7 +237,7 @@ public async Task Replaying_a_rotated_token_should_fail()
237237
response.IsError.Should().BeTrue();
238238
response.Error.Should().Be("invalid_grant");
239239
}
240-
240+
241241
[Fact]
242242
public async Task Using_a_valid_refresh_token_should_succeed()
243243
{
@@ -273,7 +273,7 @@ public async Task Using_a_valid_refresh_token_should_succeed()
273273

274274
response.IsError.Should().BeFalse();
275275
}
276-
276+
277277
[Fact]
278278
public async Task Using_a_revoked_refresh_token_should_fail()
279279
{
@@ -310,7 +310,7 @@ public async Task Using_a_revoked_refresh_token_should_fail()
310310
});
311311

312312
revocationResponse.IsError.Should().Be(false);
313-
313+
314314
// refresh token
315315
response = await _client.RequestRefreshTokenAsync(new RefreshTokenRequest
316316
{

src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/ResourceOwnerClient.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44

5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Net;
8-
using System.Net.Http;
9-
using System.Text;
10-
using System.Threading.Tasks;
11-
using FluentAssertions;
125
using Duende.IdentityModel;
13-
using IdentityModel.Client;
6+
using Duende.IdentityModel.Client;
7+
using FluentAssertions;
148
using IdentityServer.IntegrationTests.Clients.Setup;
159
using Microsoft.AspNetCore.Hosting;
1610
using Microsoft.AspNetCore.TestHost;
1711
using Newtonsoft.Json;
1812
using Newtonsoft.Json.Linq;
13+
using System.Collections.Generic;
14+
using System.Linq;
15+
using System.Net;
16+
using System.Net.Http;
17+
using System.Text;
18+
using System.Threading.Tasks;
1919
using Xunit;
2020

2121
namespace IdentityServer.IntegrationTests.Clients
@@ -67,7 +67,7 @@ public async Task Valid_user_should_succeed_with_expected_response_payload()
6767

6868
payload["aud"].Should().Be("api");
6969

70-
var scopes = ((JArray)payload["scope"]).Select(x => x.ToString());
70+
var scopes = ((JArray) payload["scope"]).Select(x => x.ToString());
7171
scopes.Count().Should().Be(1);
7272
scopes.Should().Contain("api1");
7373

@@ -108,7 +108,7 @@ public async Task Request_with_no_explicit_scopes_should_return_allowed_scopes()
108108
amr.Count().Should().Be(1);
109109
amr.First().ToString().Should().Be("pwd");
110110

111-
var scopes = ((JArray)payload["scope"]).Select(x => x.ToString());
111+
var scopes = ((JArray) payload["scope"]).Select(x => x.ToString());
112112
scopes.Count().Should().Be(8);
113113

114114
// {[ "address", "api1", "api2", "api4.with.roles", "email", "offline_access", "openid", "role"]}
@@ -159,7 +159,7 @@ public async Task Request_containing_identity_scopes_should_return_expected_payl
159159
amr.Count().Should().Be(1);
160160
amr.First().ToString().Should().Be("pwd");
161161

162-
var scopes = ((JArray)payload["scope"]).Select(x => x.ToString());
162+
var scopes = ((JArray) payload["scope"]).Select(x => x.ToString());
163163
scopes.Count().Should().Be(3);
164164
scopes.Should().Contain("api1");
165165
scopes.Should().Contain("email");
@@ -202,7 +202,7 @@ public async Task Request_for_refresh_token_should_return_expected_payload()
202202
amr.Count().Should().Be(1);
203203
amr.First().ToString().Should().Be("pwd");
204204

205-
var scopes = ((JArray)payload["scope"]).Select(x => x.ToString());
205+
var scopes = ((JArray) payload["scope"]).Select(x => x.ToString());
206206
scopes.Count().Should().Be(4);
207207
scopes.Should().Contain("api1");
208208
scopes.Should().Contain("email");
@@ -269,7 +269,7 @@ public async Task User_with_invalid_password_should_fail(string password)
269269
}
270270

271271

272-
private static Dictionary<string, object> GetPayload(IdentityModel.Client.TokenResponse response)
272+
private static Dictionary<string, object> GetPayload(TokenResponse response)
273273
{
274274
var token = response.AccessToken.Split('.').Skip(1).Take(1).First();
275275
var dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>(

src/IdentityServer4/test/IdentityServer.IntegrationTests/Clients/RevocationClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44

5-
using System.Net.Http;
6-
using System.Threading.Tasks;
5+
using Duende.IdentityModel.Client;
76
using FluentAssertions;
8-
using IdentityModel.Client;
97
using IdentityServer.IntegrationTests.Clients.Setup;
108
using Microsoft.AspNetCore.Hosting;
119
using Microsoft.AspNetCore.TestHost;
10+
using System.Net.Http;
11+
using System.Threading.Tasks;
1212
using Xunit;
1313

1414
namespace IdentityServer.IntegrationTests.Clients

0 commit comments

Comments
 (0)