-
Notifications
You must be signed in to change notification settings - Fork 48
Issue/94 - Multiple Authenticators #95
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
base: 2
Are you sure you want to change the base?
Conversation
|
Definitely a nice addition, but I think we need some tests to cover this change |
|
The tests now cover multiple authenticators. |
|
|
||
| $_SERVER['PHP_AUTH_USER'] = '[email protected]'; | ||
|
|
||
| $response = Director::test($url, $data, null, 'PUT'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't shoe-horn a fairly fundamental authentication test into another unrelated test.
Please can you create a new test function like testApiAccess which adds additional authenticators and then asserts that the second authenticator works even if the first fails?
| Director::config()->set('alternate_base_url', $this->baseURI); | ||
| RestfulServer::config()->set('authenticators', [ | ||
| BasicRestfulAuthenticator::class, | ||
| EmailOnlyAuthenticator::class, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't add this authenticator to all tests if they don't need/want it as it may result in unintended side-affects in future tests. Just add it to the specific test for this situation.
| } | ||
|
|
||
| /** @var null|Member $member */ | ||
| $member = Member::get()->find('Email', $_SERVER['PHP_AUTH_USER']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a very good way to perform the test because we could see tests passing that shouldn't if (for example) the first authenticator has a bug that means passwords are not validated properly.
You could either create an actual mock instance of an authenticator (assuming there's an interface to mock) or create some kind of hard-coded token authenticator (eg: if AUTH_USER === 'SOME-TOKEN' return a user).
Ideally this user will be a new user added to the fixtures too.
|
Thanks for the work on this @nykkl - but we need to make the test a bit more specific / thorough I think. |
|
I also feel this should target the |
Reference Issues
Multiple Authenticators
Changes
$authenticatorvariable was changed to an array and renamed to$authenticatorsto allow multiple authenticators