Skip to content

Commit

Permalink
MDL-62351 privacy: check that subsystem/plugintype exist
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed May 9, 2018
1 parent 02c7769 commit 468c8d3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion blog/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static function get_metadata(collection $collection) : collection {
// coursemoduleid, courseid, moduleid, groupid, rating, usermodified.
], 'privacy:metadata:post');

$collection->link_subsystem('core_comments', 'privacy:metadata:core_comments');
$collection->link_subsystem('core_comment', 'privacy:metadata:core_comments');
$collection->link_subsystem('core_files', 'privacy:metadata:core_files');
$collection->link_subsystem('core_tag', 'privacy:metadata:core_tag');

Expand Down
2 changes: 1 addition & 1 deletion competency/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public static function get_metadata(collection $collection) : collection {
], 'privacy:metadata:competency_userevidencecomp');

// Comments can be left on learning plans and competencies.
$collection->link_subsystem('core_comments', 'privacy:metadata:core_comments');
$collection->link_subsystem('core_comment', 'privacy:metadata:core_comments');

return $collection;
}
Expand Down
2 changes: 1 addition & 1 deletion mod/assign/feedback/editpdf/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function get_metadata(collection $collection) : collection {
];
$collection->add_database_table('assignfeedback_editpdf_quick', $quickdata, 'privacy:metadata:tablepurpose');
$collection->add_subsystem_link('core_files', [], 'privacy:metadata:filepurpose');
$collection->add_subsystem_link('core_fileconverted', [], 'privacy:metadata:conversionpurpose');
$collection->add_subsystem_link('core_fileconverter', [], 'privacy:metadata:conversionpurpose');
return $collection;
}

Expand Down
12 changes: 12 additions & 0 deletions privacy/tests/provider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ public function test_metadata_provider($component, $classname) {
$this->assertTrue($DB->get_manager()->table_exists($item->get_name()));
}

if ($item instanceof \core_privacy\local\metadata\types\plugintype_link) {
// Check that plugin type is valid.
$this->assertTrue(array_key_exists($item->get_name(), \core_component::get_plugin_types()));
}

if ($item instanceof subsystem_link) {
// Check that core subsystem exists.
list($plugintype, $pluginname) = \core_component::normalize_component($item->get_name());
$this->assertEquals('core', $plugintype);
$this->assertTrue(\core_component::is_core_subsystem($pluginname));
}

if ($summary = $item->get_summary()) {
// Summary is optional, but when provided must be a valid string identifier.
$this->assertInternalType('string', $summary);
Expand Down

0 comments on commit 468c8d3

Please sign in to comment.