adding test utils

This commit is contained in:
kevgliss 2015-07-07 15:32:55 -07:00
parent 3f49bb95ff
commit 6d384f342f
3 changed files with 27 additions and 21 deletions

View File

@ -1,11 +1,11 @@
Writing a Plugin Writing a Plugin
================ ================
**The plugin interface is a work in progress.**
Several interfaces exist for extending Lemur: 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 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:: Inside of ``plugin.py``, you'll declare your Plugin class::
import lemur_pluginname 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' title = 'Plugin Name'
slug = 'pluginname' slug = 'pluginname'
description = 'My awesome plugin!' 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 <package name>`` and configure it That's it! Users will be able to install your plugin via ``pip install <package name>``.
via the web interface based on the hooks you enabled.
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 The `IssuerPlugin` interface only required that you implement one function::
on everything.
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 Testing

View File

@ -17,10 +17,7 @@ class IssuerPlugin(Plugin):
raise NotImplementedError raise NotImplementedError
def create_authority(self): def create_authority(self):
raise NotImplementedError raise NotImplemented
def get_authorities(self):
raise NotImplementedError
def get_csr_config(self): def get_csr_config(self):
raise NotImplementedError raise NotImplementedError

0
lemur/pytest.py Normal file
View File