Skip to content

Order of claims not reproducible for unit tests #120

Description

@Jeehut

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions