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

Make processor aware of assertion types #240

Merged

Conversation

MKodde
Copy link
Contributor

@MKodde MKodde commented Aug 18, 2020

Both the Encrypted and regular Assertion classes should be passable in the decryptAssertion method. If not, you would never be able to process a SAML Response consisting of regular Assertion objects.

The test merely verifies the behavior that was changed in this commit. No additional processor tests where added. But that should be simple enough in the future.

} elseif ($assertion instanceof Assertion) {
$decrypted->add($assertion);
} else {
throw new InvalidAssertionException('The assertion is neither of type: EncryptedAssertion nor Assertion.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: using neither ... nor over a colon looks weird.
Suggestions:
"The assertion is neither of type EncryptedAssertion nor of type Assertion."
"The assertion must be of type: EncryptedAssertion or Assertion"

@thijskh thijskh requested a review from tvdijen August 18, 2020 12:18
Copy link
Member

@thijskh thijskh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks correct to me, and makes the method behave conforming to how the docblock that describes that it will. But would prefer if Tim or Jaime could comment whether this is the way to go.

It should also be merged to master so it will not break in 5.x again.

@MKodde
Copy link
Contributor Author

MKodde commented Aug 18, 2020

Thanks for the review @pmeulen and @thijskh! Good suggestions.

@MKodde MKodde force-pushed the bugfix/prevent-decryption-of-unencrypted-assertions branch 2 times, most recently from 473b420 to 9933693 Compare August 18, 2020 14:10
@MKodde
Copy link
Contributor Author

MKodde commented Aug 18, 2020

@tvdijen the unit tests seem somewhat fragile. Autoload problems occurred after adding the ProcessorTest. Only, they did not occur on my tests but on some other test cases. They where caused by me using a data provider. Removing the provider and using the runTestsInSeparateProcesses annotation fixed the issue. I came across some Mockery Github issues describing similar problems.

Is this something you are aware of? Or am I doing something wrong here?

Both the Encrypted and regular Assertion classes should be passable in
the decryptAssertion method. If not, you would never be able to process
a SAML Response consisting of regular Assertion objects.

The test merely verifies the behaviour that was changed in this commit.
No additional processor tests where added. But that should be simple
enough in the future.

For some odd reason using a data provider for the
processor_correctly_encrypts_assertions caused issues in other tests.
The test suite does not seem to be fully idempotent.
@MKodde MKodde force-pushed the bugfix/prevent-decryption-of-unencrypted-assertions branch from 9933693 to 151a418 Compare August 18, 2020 14:26
@tvdijen
Copy link
Member

tvdijen commented Aug 18, 2020

I haven't really paid much attention to this part of the library.. Jaime and I mostly worked on the classes in the XML-dir..
The validators/processors are a bit hard to follow, but this change seems fine.
The issue iwth the dataprovider surprises me.. I'm pretty sure we use them in other places.. We should take a closer look at the tests for v5 and try to avoid the use of mocks whenever possible..

@MKodde
Copy link
Contributor Author

MKodde commented Aug 19, 2020

Hi Tim, on our OpenConext phpunit tests we never have issues with Mockery mocks. Maybe a side by side comparison of the PHPUnit/PSR autoloading will give some insights. Although i did not find a problem in plain sight yesterday.

Regarding hoisting this change to master; what would you like me to do? Open a new PR or simply cherry pick these commits on master?

@MKodde MKodde merged commit ff19d04 into release-4.x Aug 19, 2020
@tvdijen
Copy link
Member

tvdijen commented Aug 19, 2020

Cherry-picking is fine, just make sure to use the correct namespaces for the Assertion/EncryptedAssertion classes.. They have been changed.

@MKodde
Copy link
Contributor Author

MKodde commented Aug 20, 2020

Opened #242 to get these changes into master

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants