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

Order of claims not reproducible for unit tests #120

Open
Jeehut opened this issue Nov 3, 2023 · 0 comments
Open

Order of claims not reproducible for unit tests #120

Jeehut opened this issue Nov 3, 2023 · 0 comments

Comments

@Jeehut
Copy link

Jeehut commented Nov 3, 2023

I just used this library to sign the claims required by the App Store Connect API using JWTSigner.es256. As documented in the README, I defined a struct that conforms to Claims for my claims like so:

struct ConnectAPIClaims: Claims {
    /// Issuer ID.
    let iss: String
    /// Issued At Time
    let iat: UInt64
    /// Expiration Time
    let exp: UInt64
    /// Audience
    let aud: String
}

Then I wanted to write a unit test where I put an expected JWT that I generated on https://jwt.io and wanted to validate that the lib is generating the same JWT with the same input data. Unfortunately, this was not possible because on each run of the test, the order of the claims JSON would change.

While I can still use the lib since the Connect API seems to work fine with changing orders, this is not optimal for ensuring that my integration of the lib works as expected. While you might already have unit tests that ensure things work within the library, I'd like to be able to write tests that ensure my integration is correct, too. So it would be awesome if there was a (simple) way to get a reproducible order for the produced JSON by my ConnectAPIClaims struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant