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

Unit tests are failing with DTFoundation version 1.7.18 #22

Closed
jlajlar opened this issue Jul 8, 2021 · 5 comments
Closed

Unit tests are failing with DTFoundation version 1.7.18 #22

jlajlar opened this issue Jul 8, 2021 · 5 comments

Comments

@jlajlar
Copy link

jlajlar commented Jul 8, 2021

Hey,

We recently updated swift packages in our app and with the updates came DTFoundation 1.7.18. In our tests, receipt parsing stopped working in our app with combination of Kvitto (version 1.0.6) and DTFoundation (version 1.7.18). On older version 1.7.17 receipts are parsed successfully and unit tests are all green as well.

@odrobnik
Copy link
Collaborator

odrobnik commented Jul 8, 2021

It would be helpful if you could tell me specifically what broke.

@jlajlar
Copy link
Author

jlajlar commented Jul 8, 2021

Specifically, the problem is in unwrapRootSequence function in PKCS7Container.

func unwrapRootSequence(_ sequence: [AnyObject]) -> Data?
    {
        guard sequence.count==2,
              let OID = sequence[0] as? String, OID == "1.2.840.113549.1.7.2",
              let containedSequence = sequence[1] as? [AnyObject], containedSequence.count == 1,
              let actualSequence = containedSequence[0] as? [AnyObject], actualSequence.count > 2,
              let dataSequence = actualSequence[2] as? [AnyObject]
        else
        {
            return nil
        }
        
        return unwrapSignedDataSequence(dataSequence)
    }

The guard statement fails in line 45, where we try to unwrap second element of the sequence to [AnyObject] type. let containedSequence = sequence[1] as? [AnyObject], containedSequence.count == 1, this line.

It seems the type changed to Dictionary with the new version. I suspect this commit is the cause for this change: Cocoanetics/DTFoundation@2bf3efc

@odrobnik
Copy link
Collaborator

odrobnik commented Jul 8, 2021

Is that in the Kvitto unit tests?

The context was missing, now there is an additional container that needs to be ignored

@jlajlar
Copy link
Author

jlajlar commented Jul 8, 2021

@odrobnik yes, in Kvitto all unit tests that are trying to initialize Receipt with valid data are failing, because PKCS7Container can't be initialized.

@odrobnik
Copy link
Collaborator

@jlajlar I updated and re-released 1.0.6. I've updated the code to handle both cases (old parsing style and new parsing that includes context containers). I've tested with both versions of DTFoundation..

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

2 participants