From 6d384f342f51292fd0f6169f83219bdb04c6d484 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Tue, 7 Jul 2015 15:32:55 -0700 Subject: [PATCH] adding test utils --- docs/developer/plugins/index.rst | 43 +++++++++++++++++++------------- lemur/plugins/bases/issuer.py | 5 +--- lemur/pytest.py | 0 3 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 lemur/pytest.py diff --git a/docs/developer/plugins/index.rst b/docs/developer/plugins/index.rst index b7cdcd2a..6bfbd205 100644 --- a/docs/developer/plugins/index.rst +++ b/docs/developer/plugins/index.rst @@ -1,11 +1,11 @@ Writing a Plugin ================ -**The plugin interface is a work in progress.** - Several interfaces exist for extending Lemur: -* Issuers (lemur.issuers) +* Issuer (lemur.plugins.base.issuer) +* Destination (lemur.plugins.base.destination) +* Source (lemur.plugins.base.source) Structure --------- @@ -29,9 +29,9 @@ if you want to pull the version using pkg_resources (which is what we recommend) Inside of ``plugin.py``, you'll declare your Plugin class:: import lemur_pluginname - from lemur.common.services.issuers.plugins import Issuer + from lemur.plugins.base.issuer import IssuerPlugin - class PluginName(Plugin): + class PluginName(IssuerPlugin): title = 'Plugin Name' slug = 'pluginname' description = 'My awesome plugin!' @@ -55,27 +55,36 @@ And you'll register it via ``entry_points`` in your ``setup.py``:: ) -That's it! Users will be able to install your plugin via ``pip install `` and configure it -via the web interface based on the hooks you enabled. +That's it! Users will be able to install your plugin via ``pip install ``. + +Interfaces +========== + +Lemur has several different plugin interfaces that are used to extend Lemur, each of them require +that you subclass and override their functions in order for your plugin to function. -Permissions -=========== +Issuer +------ -As described in the plugin interface, Lemur provides a suite of permissions. +Issuer plugins are to be used when you want to allow Lemur to use external services to create certificates. +In the simple case this means that you have one Certificate Authority and you ask it for certificates given a +few parameters. In a more advanced case this could mean that this third party not only allows you to create certifcates +but also allows you to create Certificate Authorities and Sub Certificate Authorities. -In most cases, a admin (that is, if User.is_admin is ``True``), will be granted implicit permissions -on everything. +The `IssuerPlugin` interface only required that you implement one function:: -This page attempts to describe those permissions, and the contextual objects along with them. + def create_certificate(self, options): + # requests.get('a third party') -.. data:: add_project +Lemur will pass a dictionary of all possible options for certificate creation. - Controls whether a user can create a new project. +Optionally the `IssuerPlugin` exposes another function for authority create:: - :: + def create_authority(self, options): + # request.get('a third party') - >>> has_perm('add_project', user) +If implemented this function will be used to allow users to create external Certificate Authorities. Testing diff --git a/lemur/plugins/bases/issuer.py b/lemur/plugins/bases/issuer.py index d3ac9989..b7cb14a4 100644 --- a/lemur/plugins/bases/issuer.py +++ b/lemur/plugins/bases/issuer.py @@ -17,10 +17,7 @@ class IssuerPlugin(Plugin): raise NotImplementedError def create_authority(self): - raise NotImplementedError - - def get_authorities(self): - raise NotImplementedError + raise NotImplemented def get_csr_config(self): raise NotImplementedError diff --git a/lemur/pytest.py b/lemur/pytest.py new file mode 100644 index 00000000..e69de29b