MDL-62351 privacy: check that subsystem/plugintype exist
authorMarina Glancy <marina@moodle.com>
Wed, 9 May 2018 08:15:55 +0000 (16:15 +0800)
committerMarina Glancy <marina@moodle.com>
Wed, 9 May 2018 09:37:31 +0000 (17:37 +0800)
blog/classes/privacy/provider.php
competency/classes/privacy/provider.php
mod/assign/feedback/editpdf/classes/privacy/provider.php
privacy/tests/provider_test.php

index 398d5a3..7fb7853 100644 (file)
@@ -72,7 +72,7 @@ class provider implements
             // 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');
 
index fc99649..686d6a3 100644 (file)
@@ -211,7 +211,7 @@ class provider implements
         ], '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;
     }
index e61e781..7170604 100644 (file)
@@ -59,7 +59,7 @@ class provider implements metadataprovider, assignfeedback_provider {
         ];
         $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;
     }
 
index 3ca7e7e..943d54e 100644 (file)
@@ -128,6 +128,18 @@ class provider_testcase extends advanced_testcase {
                 $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);