tests: Test whether a plugin is allowed to be loaded
diff --git a/tests/format/project.py b/tests/format/project.py
index 5b6c474..e06e842 100644
--- a/tests/format/project.py
+++ b/tests/format/project.py
@@ -1,7 +1,7 @@
 import os
 import pytest
 from buildstream import _yaml
-from buildstream._exceptions import LoadError, LoadErrorReason
+from buildstream._exceptions import LoadError, LoadErrorReason, PluginError
 from tests.testutils.runcli import cli
 
 
@@ -13,6 +13,24 @@
 
 
 @pytest.mark.datafiles(DATA_DIR)
+def test_project_plugin_load_allowed(cli, datafiles):
+    project = os.path.join(datafiles.dirname, datafiles.basename, 'plugin-allowed')
+    result = cli.run(project=project, silent=True, args=[
+        'show', 'element.bst'])
+    assert result.exit_code == 0
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_project_plugin_load_forbidden(cli, datafiles):
+    project = os.path.join(datafiles.dirname, datafiles.basename, 'plugin-forbidden')
+    result = cli.run(project=project, silent=True, args=[
+        'show', 'element.bst'])
+    assert result.exit_code != 0
+    assert result.exception
+    assert isinstance(result.exception, PluginError)
+
+
+@pytest.mark.datafiles(DATA_DIR)
 def test_project_conf_duplicate_plugins(cli, datafiles):
     project = os.path.join(datafiles.dirname, datafiles.basename, 'duplicate-plugins')
     result = cli.run(project=project, silent=True, args=[
diff --git a/tests/format/project/plugin-allowed/__init__.py b/tests/format/project/plugin-allowed/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/format/project/plugin-allowed/__init__.py
diff --git a/tests/format/project/plugin-allowed/element.bst b/tests/format/project/plugin-allowed/element.bst
new file mode 100644
index 0000000..675938b
--- /dev/null
+++ b/tests/format/project/plugin-allowed/element.bst
@@ -0,0 +1 @@
+kind: foo
diff --git a/tests/format/project/plugin-allowed/plugins/__init__.py b/tests/format/project/plugin-allowed/plugins/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/format/project/plugin-allowed/plugins/__init__.py
diff --git a/tests/format/project/plugin-allowed/plugins/foo.py b/tests/format/project/plugin-allowed/plugins/foo.py
new file mode 100644
index 0000000..bf88423
--- /dev/null
+++ b/tests/format/project/plugin-allowed/plugins/foo.py
@@ -0,0 +1,16 @@
+from buildstream import Element
+
+
+class FooElement(Element):
+    def configure(self, config):
+        pass
+
+    def preflight(self):
+        pass
+
+    def get_unique_key(self):
+        return "foo"
+
+
+def setup():
+    return FooElement
diff --git a/tests/format/project/plugin-allowed/project.conf b/tests/format/project/plugin-allowed/project.conf
new file mode 100644
index 0000000..d49e40d
--- /dev/null
+++ b/tests/format/project/plugin-allowed/project.conf
@@ -0,0 +1,7 @@
+name: test
+
+plugins:
+- origin: local
+  path: plugins
+  elements:
+    foo: 0
diff --git a/tests/format/project/plugin-forbidden/__init__.py b/tests/format/project/plugin-forbidden/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/format/project/plugin-forbidden/__init__.py
diff --git a/tests/format/project/plugin-forbidden/element.bst b/tests/format/project/plugin-forbidden/element.bst
new file mode 100644
index 0000000..c8d5131
--- /dev/null
+++ b/tests/format/project/plugin-forbidden/element.bst
@@ -0,0 +1 @@
+kind: bar
diff --git a/tests/format/project/plugin-forbidden/forbidden-plugins/__init__.py b/tests/format/project/plugin-forbidden/forbidden-plugins/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/format/project/plugin-forbidden/forbidden-plugins/__init__.py
diff --git a/tests/format/project/plugin-forbidden/forbidden-plugins/forbidden-plugin.py b/tests/format/project/plugin-forbidden/forbidden-plugins/forbidden-plugin.py
new file mode 100644
index 0000000..bf88423
--- /dev/null
+++ b/tests/format/project/plugin-forbidden/forbidden-plugins/forbidden-plugin.py
@@ -0,0 +1,16 @@
+from buildstream import Element
+
+
+class FooElement(Element):
+    def configure(self, config):
+        pass
+
+    def preflight(self):
+        pass
+
+    def get_unique_key(self):
+        return "foo"
+
+
+def setup():
+    return FooElement
diff --git a/tests/format/project/plugin-forbidden/project.conf b/tests/format/project/plugin-forbidden/project.conf
new file mode 100644
index 0000000..39cc3d6
--- /dev/null
+++ b/tests/format/project/plugin-forbidden/project.conf
@@ -0,0 +1,2 @@
+name: test
+