|
12 | 12 | using IdentityServer4.Test;
|
13 | 13 | using Microsoft.IdentityModel.Logging;
|
14 | 14 | using Microsoft.IdentityModel.Tokens;
|
15 |
| -using Newtonsoft.Json; |
16 | 15 | using System;
|
17 | 16 | using System.Collections.Generic;
|
18 | 17 | using System.IdentityModel.Tokens.Jwt;
|
19 | 18 | using System.Net.Http;
|
20 | 19 | using System.Net.Http.Headers;
|
21 | 20 | using System.Security.Claims;
|
22 | 21 | using System.Security.Cryptography.X509Certificates;
|
| 22 | +using System.Text.Json; |
23 | 23 | using System.Threading.Tasks;
|
24 | 24 | using Xunit;
|
25 | 25 |
|
@@ -70,13 +70,13 @@ public JwtRequestAuthorizeTests()
|
70 | 70 | {
|
71 | 71 | // RSA key as JWK
|
72 | 72 | Type = IdentityServerConstants.SecretTypes.JsonWebKey,
|
73 |
| - Value = JsonConvert.SerializeObject(JsonWebKeyConverter.ConvertFromRSASecurityKey(_rsaKey)) |
| 73 | + Value = JsonSerializer.Serialize(JsonWebKeyConverter.ConvertFromRSASecurityKey(_rsaKey)) |
74 | 74 | },
|
75 | 75 | new Secret
|
76 | 76 | {
|
77 | 77 | // x509 cert as JWK
|
78 | 78 | Type = IdentityServerConstants.SecretTypes.JsonWebKey,
|
79 |
| - Value = JsonConvert.SerializeObject(JsonWebKeyConverter.ConvertFromX509SecurityKey(new X509SecurityKey(TestCert.Load()))) |
| 79 | + Value = JsonSerializer.Serialize(JsonWebKeyConverter.ConvertFromX509SecurityKey(new X509SecurityKey(TestCert.Load()))) |
80 | 80 | }
|
81 | 81 | },
|
82 | 82 |
|
@@ -114,13 +114,13 @@ public JwtRequestAuthorizeTests()
|
114 | 114 | {
|
115 | 115 | // RSA key as JWK
|
116 | 116 | Type = IdentityServerConstants.SecretTypes.JsonWebKey,
|
117 |
| - Value = JsonConvert.SerializeObject(JsonWebKeyConverter.ConvertFromRSASecurityKey(_rsaKey)) |
| 117 | + Value = JsonSerializer.Serialize(JsonWebKeyConverter.ConvertFromRSASecurityKey(_rsaKey)) |
118 | 118 | },
|
119 | 119 | new Secret
|
120 | 120 | {
|
121 | 121 | // x509 cert as JWK
|
122 | 122 | Type = IdentityServerConstants.SecretTypes.JsonWebKey,
|
123 |
| - Value = JsonConvert.SerializeObject(JsonWebKeyConverter.ConvertFromX509SecurityKey(new X509SecurityKey(TestCert.Load()))) |
| 123 | + Value = JsonSerializer.Serialize(JsonWebKeyConverter.ConvertFromX509SecurityKey(new X509SecurityKey(TestCert.Load()))) |
124 | 124 | }
|
125 | 125 | },
|
126 | 126 |
|
@@ -490,9 +490,9 @@ public async Task mismatch_in_jwt_values_should_error()
|
490 | 490 | public async Task authorize_should_accept_complex_objects_in_request_object()
|
491 | 491 | {
|
492 | 492 | var someObj = new { foo = new { bar = "bar" }, baz = "baz" };
|
493 |
| - var someObjJson = JsonConvert.SerializeObject(someObj); |
| 493 | + var someObjJson = JsonSerializer.Serialize(someObj); |
494 | 494 | var someArr = new[] { "a", "b", "c" };
|
495 |
| - var someArrJson = JsonConvert.SerializeObject(someArr); |
| 495 | + var someArrJson = JsonSerializer.Serialize(someArr); |
496 | 496 |
|
497 | 497 |
|
498 | 498 | var requestJwt = CreateRequestJwt(
|
@@ -527,19 +527,19 @@ public async Task authorize_should_accept_complex_objects_in_request_object()
|
527 | 527 | _mockPipeline.LoginRequest.Should().NotBeNull();
|
528 | 528 |
|
529 | 529 | _mockPipeline.LoginRequest.Parameters["someObj"].Should().NotBeNull();
|
530 |
| - var someObj2 = JsonConvert.DeserializeObject(_mockPipeline.LoginRequest.Parameters["someObj"], someObj.GetType()); |
| 530 | + var someObj2 = JsonSerializer.Deserialize(_mockPipeline.LoginRequest.Parameters["someObj"], someObj.GetType()); |
531 | 531 | someObj.Should().BeEquivalentTo(someObj2);
|
532 | 532 | _mockPipeline.LoginRequest.Parameters["someArr"].Should().NotBeNull();
|
533 |
| - var someArr2 = JsonConvert.DeserializeObject<string[]>(_mockPipeline.LoginRequest.Parameters["someArr"]); |
| 533 | + var someArr2 = JsonSerializer.Deserialize<string[]>(_mockPipeline.LoginRequest.Parameters["someArr"]); |
534 | 534 | someArr2.Should().Contain(new[] { "a", "c", "b" });
|
535 | 535 | someArr2.Length.Should().Be(3);
|
536 | 536 |
|
537 | 537 | _mockPipeline.LoginRequest.RequestObjectValues.Count.Should().Be(13);
|
538 | 538 | _mockPipeline.LoginRequest.RequestObjectValues["someObj"].Should().NotBeNull();
|
539 |
| - someObj2 = JsonConvert.DeserializeObject(_mockPipeline.LoginRequest.RequestObjectValues["someObj"], someObj.GetType()); |
| 539 | + someObj2 = JsonSerializer.Deserialize(_mockPipeline.LoginRequest.RequestObjectValues["someObj"], someObj.GetType()); |
540 | 540 | someObj.Should().BeEquivalentTo(someObj2);
|
541 | 541 | _mockPipeline.LoginRequest.RequestObjectValues["someArr"].Should().NotBeNull();
|
542 |
| - someArr2 = JsonConvert.DeserializeObject<string[]>(_mockPipeline.LoginRequest.Parameters["someArr"]); |
| 542 | + someArr2 = JsonSerializer.Deserialize<string[]>(_mockPipeline.LoginRequest.Parameters["someArr"]); |
543 | 543 | someArr2.Should().Contain(new[] { "a", "c", "b" });
|
544 | 544 | someArr2.Length.Should().Be(3);
|
545 | 545 | }
|
|
0 commit comments