Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Microsoft.IdentityModel.JsonWebTokens.Tests.JsonWebTokenHandlerTests.ValidateJsonWebTokenClaimMapping flaky test #2840

Closed
jennyf19 opened this issue Sep 23, 2024 · 1 comment · Fixed by #2859
Assignees
Labels
Fundamentals Good First Issue This is a good item for new team members Internal Indicates issue was opened by the IdentityModel team

Comments

@jennyf19
Copy link
Collaborator

jennyf19 commented Sep 23, 2024

Run all the tests at once and Microsoft.IdentityModel.JsonWebTokens.Tests.JsonWebTokenHandlerTests.ValidateJsonWebTokenClaimMapping consistently fails but passes when run individually.

More details

 Microsoft.IdentityModel.JsonWebTokens.Tests.JsonWebTokenHandlerTests.ValidateJsonWebTokenClaimMapping
 Source: JsonWebTokenHandlerTests.cs line 3076
 Duration: 184 ms

Message: 
Microsoft.IdentityModel.TestUtils.TestException : CompareAllPublicProperties: Microsoft.IdentityModel.Tokens.TokenValidationResult
Claims:
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/claims/authnclassreference
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/ws/2009/09/identity/claims/actor
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/claims/authnmethodsreferences
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/dateofbirth
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/gender
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/webpage
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/claims/EmailAddress
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/extension/applicationpolicy
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/extension/authoritykeyidentifier
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/extension/basicconstraints
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/extension/eku
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/field/issuer
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/field/issuername
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/extension/keyusage
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/field/notafter
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/field/notbefore
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/extension/certificatepolicy
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/rsa
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/field/rawdata
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/ws/2008/06/identity/claims/serialnumber
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/field/signaturealgorithm
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/field/subject
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/extension/san
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/extension/subjectkeyidentifier
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/field/subjectname
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/extension/certificatetemplateinformation
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/extension/certificatetemplatename
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/thumbprint
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/12/certificatecontext/field/x509version
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-client-application
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-client-ip
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-client-user-agent
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/claims/CommonName
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlyprimarygroupsid
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlyprimarysid
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/denyonlysid
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/devicecontext/claims/displayname
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/devicecontext/claims/identifier
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/devicecontext/claims/ismanaged
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/devicecontext/claims/ostype
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/devicecontext/claims/osversion
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/devicecontext/claims/userowner
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/devicecontext/claims/registrationid
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-endpoint-absolute-path
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-forwarded-client-ip
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/claims/Group
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/identity/claims/identityprovider
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/ws/2012/01/insidecorporatenetwork
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/devicecontext/claims/isregistereduser
dictionary1[key] ! found in dictionary2. key: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/ws/2008/06/identity/claims/primarygroupsid
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-proxy
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/ws/2012/01/passwordchangeurl
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/ws/2012/01/passwordexpirationdays
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/ws/2012/01/passwordexpirationtime
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/2012/01/requestcontext/claims/relyingpartytrustid
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/ws/2008/06/identity/claims/role
dictionary1[key] ! found in dictionary2. key: http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname
ClaimsIdentity:
CompareAllPublicProperties: Microsoft.IdentityModel.Tokens.CaseSensitiveClaimsIdentity
Claims:

numMatched != numToMatch: 6, 71

Claims1 NOT Matched:

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress: Bob@contoso.com: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress: bob@contoso.com: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname: Bob: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/claims/authnclassreference: contoso-loa-1: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/ws/2009/09/identity/claims/actor: d44840f5-ea85-4e1f-98cf-d72620e0c85a,338e9f46-5dba-489b-ba9d-f263753e3e31,27c98e63-4e1c-4c7c-b0c4-4e325dbd82fe: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/claims/authnmethodsreferences: Default.Amr: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/dateofbirth: 953366400: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/gender: male: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier: NameId1: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/webpage: http://referenceUri: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/claims/EmailAddress: adfs@contoso.com: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod: introspection_endpoint_auth_methods_supported: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/extension/applicationpolicy: certapppolicy: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/extension/authoritykeyidentifier: 1222c038-fce9-47d1-8ffe-e2463170e0bd: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/extension/basicconstraints: not_null: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/extension/eku: 31098a9b-d8bd-4207-8b4d-83444e6ae18c: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/field/issuer: http://Default.Issuer.com: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/field/issuername: Name2: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/extension/keyusage: signing: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/field/notafter: 1727739135: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/field/notbefore: 1727047935: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/extension/certificatepolicy: certpolicy: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/rsa: Microsoft.IdentityModel.Tokens.X509SecurityKey, KeyId: 'A6AA1E6A66F67B9615CD1EBFAEA169882AC5660C', InternalId: 'pqoeamb2e5YVzR6_rqFpiCrFZgw'.: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/field/rawdata: raw data: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/ws/2008/06/identity/claims/serialnumber: 05f454ba-13da-4603-b5f1-4e297fa26fd1: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/field/signaturealgorithm: http://www.w3.org/2001/04/xmldsig-more#rsa-sha256: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/field/subject: welcome: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/extension/san: Name2: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/extension/subjectkeyidentifier: cc5510f7-32ce-48a8-a238-c702f9b3e33b: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/field/subjectname: Name2: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/extension/certificatetemplateinformation: information: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/extension/certificatetemplatename: templatename: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/thumbprint: 31b1134f-3de5-4820-be78-963fa531b4dd: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/12/certificatecontext/field/x509version: 3: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-client-application: clientapplication: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-client-ip: 50.46.159.51: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-client-user-agent: {
"applicationVersion": "2.0",
"headerValue": "user-agent header",
"platform": "windows",
"productFamily": "teams"
}: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/claims/CommonName: http://referenceUri: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlyprimarygroupsid: http://referenceUri: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlyprimarysid: http://referenceUri: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/denyonlysid: http://referenceUri: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/devicecontext/claims/displayname: http://referenceUri: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/devicecontext/claims/identifier: f0e7c5d0-01f1-4476-89dc-a2fc9720af8e: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/devicecontext/claims/ismanaged: false: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/devicecontext/claims/ostype: windows: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/devicecontext/claims/osversion: 2017: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/devicecontext/claims/userowner: Microsoft: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/devicecontext/claims/registrationid: deviceregid: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-endpoint-absolute-path: /resource/a: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-forwarded-client-ip: 50.46.159.52: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/claims/Group: group: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid: fb3f14bc-ee3b-4295-a7c8-1c919d2edf76: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/identity/claims/identityprovider: https://sts.windows.net2/add29489-7269-41f4-8841-b63c95564422/: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/ws/2012/01/insidecorporatenetwork: true: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/devicecontext/claims/isregistereduser: true: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier: 5e8a936a-8c84-4d00-a1df-ec52a6185699: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/ws/2008/06/identity/claims/primarygroupsid: 9c5b5981-9752-4517-9082-fdc077fda434: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid: 6425920d-f7ad-47e9-b50d-30993dc5a553: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-proxy: proxy: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/ws/2012/01/passwordchangeurl: pwdchgurl: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/ws/2012/01/passwordexpirationdays: 90: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/ws/2012/01/passwordexpirationtime: 1734910335: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/2012/01/requestcontext/claims/relyingpartytrustid: 504d7294-83d4-4fcc-97ee-14ee007f52b7: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/ws/2008/06/identity/claims/role: Sales: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname: Name2: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com

Claims2 NOT Matched:

email: Bob@contoso.com: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
email: bob@contoso.com: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
given_name: Bob: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
acr: contoso-loa-1: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
actort: d44840f5-ea85-4e1f-98cf-d72620e0c85a,338e9f46-5dba-489b-ba9d-f263753e3e31,27c98e63-4e1c-4c7c-b0c4-4e325dbd82fe: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
amr: Default.Amr: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
birthdate: 953366400: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
gender: male: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
nameid: NameId1: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
website: http://referenceUri: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
adfs1email: adfs@contoso.com: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
authmethod: introspection_endpoint_auth_methods_supported: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certapppolicy: certapppolicy: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certauthoritykeyidentifier: 1222c038-fce9-47d1-8ffe-e2463170e0bd: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certbasicconstraints: not_null: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certeku: 31098a9b-d8bd-4207-8b4d-83444e6ae18c: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certissuer: http://Default.Issuer.com: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certissuername: Name2: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certkeyusage: signing: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certnotafter: 1727739135: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certnotbefore: 1727047935: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certpolicy: certpolicy: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certpublickey: Microsoft.IdentityModel.Tokens.X509SecurityKey, KeyId: 'A6AA1E6A66F67B9615CD1EBFAEA169882AC5660C', InternalId: 'pqoeamb2e5YVzR6_rqFpiCrFZgw'.: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certrawdata: raw data: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certserialnumber: 05f454ba-13da-4603-b5f1-4e297fa26fd1: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certsignaturealgorithm: http://www.w3.org/2001/04/xmldsig-more#rsa-sha256: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certsubject: welcome: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certsubjectaltname: Name2: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certsubjectkeyidentifier: cc5510f7-32ce-48a8-a238-c702f9b3e33b: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certsubjectname: Name2: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certtemplateinformation: information: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certtemplatename: templatename: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certthumbprint: 31b1134f-3de5-4820-be78-963fa531b4dd: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
certx509version: 3: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
clientapplication: clientapplication: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
clientip: 50.46.159.51: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
clientuseragent: {
"applicationVersion": "2.0",
"headerValue": "user-agent header",
"platform": "windows",
"productFamily": "teams"
}: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
commonname: http://referenceUri: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
denyonlyprimarygroupsid: http://referenceUri: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
denyonlyprimarysid: http://referenceUri: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
denyonlysid: http://referenceUri: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
devicedispname: http://referenceUri: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
deviceid: f0e7c5d0-01f1-4476-89dc-a2fc9720af8e: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
deviceismanaged: false: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
deviceostype: windows: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
deviceosver: 2017: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
deviceowner: Microsoft: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
deviceregid: deviceregid: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
endpointpath: /resource/a: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
forwardedclientip: 50.46.159.52: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
group: group: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
groupsid: fb3f14bc-ee3b-4295-a7c8-1c919d2edf76: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
idp: https://sts.windows.net2/add29489-7269-41f4-8841-b63c95564422/: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
insidecorporatenetwork: true: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
isregistereduser: true: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
ppid: 5e8a936a-8c84-4d00-a1df-ec52a6185699: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
primarygroupsid: 9c5b5981-9752-4517-9082-fdc077fda434: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
primarysid: 6425920d-f7ad-47e9-b50d-30993dc5a553: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
proxy: proxy: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
pwdchgurl: pwdchgurl: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
pwdexpdays: 90: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
pwdexptime: 1734910335: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
relyingpartytrustid: 504d7294-83d4-4fcc-97ee-14ee007f52b7: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
role: Sales: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
winaccountname: Name2: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com

Claims Matched:

iss: http://Default.Issuer.com: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
aud: http://Default.Audience.com: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com
iat: 1489775617: http://www.w3.org/2001/XMLSchema#integer64: http://Default.Issuer.com: http://Default.Issuer.com
nbf: 1489775617: http://www.w3.org/2001/XMLSchema#integer64: http://Default.Issuer.com: http://Default.Issuer.com
exp: 253402300799: http://www.w3.org/2001/XMLSchema#integer64: http://Default.Issuer.com: http://Default.Issuer.com
idtyp: app: http://www.w3.org/2001/XMLSchema#string: http://Default.Issuer.com: http://Default.Issuer.com

jsonValidationResult.IsValid && jwtValidationResult.IsValid, Validation results are not equal

Stack Trace: 
TestUtilities.AssertFailIfErrors(String testId, List`1 errors) line 369
TestUtilities.AssertFailIfErrors(CompareContext context) line 352
JsonWebTokenHandlerTests.ValidateJsonWebTokenClaimMapping() line 3134
--- End of stack trace from previous location ---

@jennyf19 jennyf19 added Internal Indicates issue was opened by the IdentityModel team Good First Issue This is a good item for new team members Fundamentals labels Sep 23, 2024
@kllysng kllysng assigned kllysng and unassigned kllysng Oct 1, 2024
@kllysng
Copy link
Contributor

kllysng commented Oct 1, 2024

Root Cause

When run independently, JwtSecurityTokenHandler:
image
image

When run with other tests, JwtSecurityTokenHandler:
image
image

In another test, we instantiate jwtClaimsMapping as a reference to JwtSecurityTokenHandler.DefaultInboundClaimTypeMap, and then call:

We need to not modify static fields in tests, or at least restore their original state if we have to.

Tests aside, in JwtSecurityTokenHandler, DefaultInboundClaimTypeMap is declared as a public, mutable, static field which is ill-advised, but appears to be done on purpose according to this PR comment.

Proposed fix 1:

We restore the state of JwtSecurityTokenHandler.DefaultInboundClaimTypeMap after calling .Clear(), and add the two tests to a collection so that they never run in parallel.

This should fix the flakiness of this test in the immediate term.

Proposed fix 2:

We follow Microsoft Learn: Field Design and don't declare public mutable static fields. If we're interested in this, and the PR comment mentioned above no longer stands, I will open an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fundamentals Good First Issue This is a good item for new team members Internal Indicates issue was opened by the IdentityModel team
Projects
None yet
2 participants