diff --git a/codecov.yml b/codecov.yml index b381bc556033d3789deb90da799f4b9869132e4f..eb2a03b3893532760c9bcc4afc6015bd3743bfc4 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,6 +1,9 @@ coverage: status: project: yes + default: + target: 0% + threshold: 2% patch: off comment: layout: "diff" diff --git a/docs/simplesamlphp-modules.md b/docs/simplesamlphp-modules.md index c50bffb1d7706614d21d2885314cf8ca1ddd2143..33f32df95b0d7b5fe371f7b152133d4b549498ea 100644 --- a/docs/simplesamlphp-modules.md +++ b/docs/simplesamlphp-modules.md @@ -205,12 +205,7 @@ function named `<module name>_hook_<hook name>`. Each hook function accepts a single argument. This argument will be passed by reference, which allows each hook to update that argument. -There is currently a single user of the hook interface - the front -page. The front page defines a hook named `frontpage`, which allows -modules to add things to the different sections on the front page. For -an example of this, see the `modules/modinfo/hooks/hook_frontpage.php` -file in the -[modinfo module](https://github.com/simplesamlphp/simplesamlphp-module-modinfo). - - +For an example of hook usage, see the cron module, which adds a link +to its information page in the Configuration section of the admin +module, through the file `modules/cron/hooks/hook_configpage.php`. diff --git a/modules/admin/lib/Controller/Test.php b/modules/admin/lib/Controller/Test.php index 355e876363c87d0de709675e63316c87d06a7ff1..c74462d2dd91f5b69231195c1f647170accde0c3 100644 --- a/modules/admin/lib/Controller/Test.php +++ b/modules/admin/lib/Controller/Test.php @@ -157,9 +157,6 @@ class Test ]; } - Module::callHooks('configpage', $t); - Assert::isInstanceOf($t, Template::class); - $this->menu->addOption('logout', $this->authUtils->getAdminLogoutURL(), Translate::noop('Log out')); return $this->menu->insert($t); } diff --git a/modules/cron/hooks/hook_frontpage.php b/modules/cron/hooks/hook_frontpage.php deleted file mode 100644 index bf57406cb592d08576d464dc08f90c826d2469d5..0000000000000000000000000000000000000000 --- a/modules/cron/hooks/hook_frontpage.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php - -use SimpleSAML\Assert\Assert; -use SimpleSAML\Module; - -/** - * Hook to add the modinfo module to the frontpage. - * - * @param array &$links The links on the frontpage, split into sections. - */ -function cron_hook_frontpage(array &$links): void -{ - Assert::keyExists($links, 'links'); - - $links['config'][] = [ - 'href' => Module::getModuleURL('cron/info'), - 'text' => '{cron:cron:link_cron}', - ]; -} diff --git a/modules/saml/hooks/hook_metadata_hosted.php b/modules/saml/hooks/hook_metadata_hosted.php deleted file mode 100644 index 45c8021fbc4eed132ff88f1cf4fdaad9bb3620fe..0000000000000000000000000000000000000000 --- a/modules/saml/hooks/hook_metadata_hosted.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -use SimpleSAML\Assert\Assert; -use SimpleSAML\Auth; - -/** - * Hook to add the metadata for hosted entities to the frontpage. - * - * @param array &$metadataHosted The metadata links for hosted metadata on the frontpage. - */ -function saml_hook_metadata_hosted(array &$metadataHosted) -{ - $sources = Auth\Source::getSourcesOfType('saml:SP'); - - foreach ($sources as $source) { - /** @var \SimpleSAML\Module\saml\Auth\Source\SP $source */ - $metadata = $source->getMetadata(); - - $name = $metadata->getValue('name', null); - if ($name === null) { - $name = $metadata->getValue('OrganizationDisplayName', null); - } - if ($name === null) { - $name = $source->getAuthId(); - } - - $md = [ - 'entityid' => $source->getEntityId(), - 'metadata-index' => $source->getEntityId(), - 'metadata-set' => 'saml20-sp-hosted', - 'metadata-url' => $source->getMetadataURL() . '?output=xhtml', - 'name' => $name, - ]; - - $metadataHosted[] = $md; - } -} diff --git a/tests/lib/SimpleSAML/ModuleTest.php b/tests/lib/SimpleSAML/ModuleTest.php index 543e3070905468c636a33380fbf9aa201ad51a21..966f9c75f74cddfee3555f8a0ad90b5ac922cbe6 100644 --- a/tests/lib/SimpleSAML/ModuleTest.php +++ b/tests/lib/SimpleSAML/ModuleTest.php @@ -118,11 +118,11 @@ class ModuleTest extends TestCase */ public function testGetModuleHooks(): void { - $hooks = Module::getModuleHooks('saml'); - $this->assertArrayHasKey('metadata_hosted', $hooks); - $this->assertEquals('saml_hook_metadata_hosted', $hooks['metadata_hosted']['func']); - $expectedFile = dirname(__DIR__, 3) . '/modules/saml/hooks/hook_metadata_hosted.php'; - $this->assertEquals($expectedFile, $hooks['metadata_hosted']['file']); + $hooks = Module::getModuleHooks('cron'); + $this->assertArrayHasKey('configpage', $hooks); + $this->assertEquals('cron_hook_configpage', $hooks['configpage']['func']); + $expectedFile = dirname(__DIR__, 3) . '/modules/cron/hooks/hook_configpage.php'; + $this->assertEquals($expectedFile, $hooks['configpage']['file']); } /**