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 Surf representative a role on its own #638

Merged
merged 2 commits into from
Jun 19, 2024

Conversation

MKodde
Copy link
Contributor

@MKodde MKodde commented Jun 17, 2024

Previously it inherited the default ROLE_USER role. Which also granted access to the /entity and /services pages. That is not required for now. The representative should only see the /connections page.

Disclaimer: The new addition to the phpstan baseline was 'required' as a more rigorous refactoring was required to fix the issue. And that was out of scope at this point.

@MKodde MKodde force-pushed the feature/surfconext-verantwoordelijke-authz branch 4 times, most recently from 116d0cf to 992153c Compare June 18, 2024 09:44
Base automatically changed from feature/surfconext-verantwoordelijke-page to main June 18, 2024 09:45
@MKodde MKodde force-pushed the feature/surfconext-verantwoordelijke-authz branch from 992153c to 51a098e Compare June 18, 2024 09:46
@MKodde MKodde requested a review from parijke June 18, 2024 09:48
@MKodde MKodde force-pushed the feature/surfconext-verantwoordelijke-authz branch from 51a098e to c9d7f20 Compare June 18, 2024 12:21
Copy link
Contributor

@parijke parijke left a comment

Choose a reason for hiding this comment

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

Small suggestions, feel free to ignore them as they are not blocking IMHO

Comment on lines +1769 to +1773
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$entityName of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityConnection constructor expects string, string\\|null given\\.$#',
'count' => 2,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Service/ServiceConnectionService.php',
];
Copy link
Contributor

Choose a reason for hiding this comment

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

Simple to fix with a ? in front of the variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, that could be a solution. But I do not want to loosen type safety, the creating side should be more defensive. And thats where this baseline entry came from.

$this->getTestIdpsIndexed(),
$service,
Copy link
Contributor

Choose a reason for hiding this comment

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

You could consider using named parameters, then the order doesn't matter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I never considered using that. in this case the service argument became optional, and needed to be moved to the bottom of the stack.

Leaving this as-is. But thanks for the suggestion for using the NamedParameters. Going to read up on them.

class EntrypointController extends AbstractController
{
#[Route(path: '/', name: 'entrypoint', methods: ['GET'])]
public function overview(): RedirectResponse
Copy link
Contributor

Choose a reason for hiding this comment

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

Love these simple controllers... The only change I would make is to use __invoke() instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes, another SF construction I need to get used to. Changing that

$service
);
}
if ($serviceCount === 0 && empty($allowedServices)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What does it mean in one word when serviceCount === 0 and allowedservices is empty (maybe use [] instead)

If it can be one word, then use a local method that explains this, because I do not see what is thi state represents

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Top feedback. I have replaced the expression with a boolean variable that suggests the state being tested.

@@ -88,6 +88,9 @@ class WebTestCase extends PantherTestCase

protected DevelopmentIssueRepository $jiraIssueRepository;

private string $surfConextRepresentativeAttributeName = '';
private string $surfConextRepresentativeAttributeValue = '';

public static function setUpBeforeClass(): void
{
exec('cd /var/www/html && composer dump-env test -q && chmod 777 /tmp/spdashboard-webtests.sqlite');
Copy link
Contributor

Choose a reason for hiding this comment

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

This we can do better by using sqlite in memory, I have an example setup in my private repo how to do this. Not for now, but later on. Basically I used this https://www.sitepoint.com/quick-tip-testing-symfony-apps-with-a-disposable-database/

Copy link
Contributor Author

@MKodde MKodde Jun 19, 2024

Choose a reason for hiding this comment

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

In this case, for the simple fixtures, I find it more flexible to simply store json blobs in txt files. I am interested in your thoughts about optimising our set up. Which is really basic, and bare bones at this point.

Also be aware that our SQL persistence layer is wafer thin, we store all the things in OpenConext Manage. The SQLite test substitute is a powerfull test option, but in this application of limited use.

Instead we opted to run our containers in test mode. Automatically switching to a set of test databases. (like we do in the stepup tests)

@MKodde MKodde force-pushed the feature/surfconext-verantwoordelijke-authz branch from c9d7f20 to 8c12aae Compare June 19, 2024 06:44
Previously it inherited the default ROLE_USER role. Which also granted
access to the /entity and /services pages. That is not required for now.
The representative should only see the /connections page.
The missing web test coverage was added in this commit.

Some notes:
- For now all IdPs are allowed for every SP (via allowedall)
- Only one test idp is configured, that could be expanded upon
@MKodde MKodde force-pushed the feature/surfconext-verantwoordelijke-authz branch from 8c12aae to e66a0ff Compare June 19, 2024 06:47
@MKodde MKodde merged commit 4b44c6e into main Jun 19, 2024
1 of 2 checks passed
@MKodde MKodde deleted the feature/surfconext-verantwoordelijke-authz branch June 19, 2024 06:48
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

Successfully merging this pull request may close these issues.

2 participants