Skip to content

Commit ea300c9

Browse files
committed
Fix test failures in IdentityServer.IntegrationTests
1 parent 5b02884 commit ea300c9

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

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

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public async Task Valid_client_should_succeed()
6767
{
6868
Address = TokenEndpoint,
6969

70-
ClientId = ClientId,
7170
ClientAssertion =
7271
{
7372
Type = OidcConstants.ClientAssertionTypes.JwtBearer,
@@ -88,8 +87,6 @@ public async Task Valid_client_with_implicit_clientId_should_succeed()
8887
var response = await _client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
8988
{
9089
Address = TokenEndpoint,
91-
ClientId = "client",
92-
9390
ClientAssertion =
9491
{
9592
Type = OidcConstants.ClientAssertionTypes.JwtBearer,
@@ -101,7 +98,7 @@ public async Task Valid_client_with_implicit_clientId_should_succeed()
10198

10299
AssertValidToken(response);
103100
}
104-
101+
105102
[Fact]
106103
public async Task Valid_client_with_token_replay_should_fail()
107104
{
@@ -110,8 +107,6 @@ public async Task Valid_client_with_token_replay_should_fail()
110107
var response = await _client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
111108
{
112109
Address = TokenEndpoint,
113-
114-
ClientId = ClientId,
115110
ClientAssertion =
116111
{
117112
Type = OidcConstants.ClientAssertionTypes.JwtBearer,
@@ -122,13 +117,11 @@ public async Task Valid_client_with_token_replay_should_fail()
122117
});
123118

124119
AssertValidToken(response);
125-
120+
126121
// replay
127122
response = await _client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
128123
{
129124
Address = TokenEndpoint,
130-
131-
ClientId = ClientId,
132125
ClientAssertion =
133126
{
134127
Type = OidcConstants.ClientAssertionTypes.JwtBearer,
@@ -148,11 +141,9 @@ public async Task Client_with_invalid_secret_should_fail()
148141
var response = await _client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
149142
{
150143
Address = TokenEndpoint,
151-
152-
ClientId = ClientId,
153144
ClientAssertion =
154145
{
155-
Type = OidcConstants.ClientAssertionTypes.JwtBearer,
146+
Type = OidcConstants.ClientAssertionTypes.JwtBearer,
156147
Value = "invalid"
157148
},
158149

@@ -173,8 +164,6 @@ public async Task Invalid_client_should_fail()
173164
var response = await _client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
174165
{
175166
Address = TokenEndpoint,
176-
177-
ClientId = clientId,
178167
ClientAssertion =
179168
{
180169
Type = OidcConstants.ClientAssertionTypes.JwtBearer,
@@ -204,12 +193,12 @@ private void AssertValidToken(TokenResponse response)
204193
response.RefreshToken.Should().BeNull();
205194

206195
var payload = GetPayload(response);
207-
196+
208197
payload.Count().Should().Be(8);
209198
payload.Should().Contain("iss", "https://idsvr4");
210199
payload.Should().Contain("client_id", ClientId);
211200
payload.Keys.Should().Contain("iat");
212-
201+
213202
var scopes = payload["scope"] as JArray;
214203
scopes.First().ToString().Should().Be("api1");
215204

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +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-
54
using System.Collections.Generic;
65
using System.Net.Http;
7-
using System.Text.Json;
86
using System.Threading.Tasks;
97
using FluentAssertions;
108
using IdentityModel.Client;
119
using IdentityServer.IntegrationTests.Clients.Setup;
1210
using Microsoft.AspNetCore.Hosting;
1311
using Microsoft.AspNetCore.TestHost;
12+
using Newtonsoft.Json;
1413
using Xunit;
1514

1615
namespace IdentityServer.IntegrationTests.Clients
@@ -120,7 +119,7 @@ public async Task Extension_grant_request_should_contain_custom_response()
120119

121120
private Dictionary<string, object> GetFields(TokenResponse response)
122121
{
123-
return response.Json.Deserialize<Dictionary<string, object>>();
122+
return JsonConvert.DeserializeObject<Dictionary<string, object>>(response.Json.ToString());
124123
}
125124
}
126125
}

src/IdentityServer4/test/IdentityServer.IntegrationTests/Endpoints/Introspection/IntrospectionTests.cs

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

44

5+
using System;
56
using System.Collections.Generic;
67
using System.Linq;
78
using System.Net;
@@ -181,7 +182,7 @@ public async Task Response_data_should_be_valid_using_single_scope()
181182
Token = tokenResponse.AccessToken
182183
});
183184

184-
var values = introspectionResponse.Json.Deserialize<Dictionary<string, object>>();
185+
var values = JsonConvert.DeserializeObject<Dictionary<string, object>>(introspectionResponse.Json.ToString());
185186

186187
values["aud"].GetType().Name.Should().Be("String");
187188
values["iss"].GetType().Name.Should().Be("String");
@@ -220,7 +221,7 @@ public async Task Response_data_with_user_authentication_should_be_valid_using_s
220221
Token = tokenResponse.AccessToken
221222
});
222223

223-
var values = introspectionResponse.Json.Deserialize<Dictionary<string, object>>();
224+
var values = JsonConvert.DeserializeObject<Dictionary<string, object>>(introspectionResponse.Json.ToString());
224225

225226
values["aud"].GetType().Name.Should().Be("String");
226227
values["iss"].GetType().Name.Should().Be("String");

0 commit comments

Comments
 (0)