Use abstract base class for oauth driver
Use the abc module for managing abstract base classes in the driver layer. bp abstract-base-class-drivers Change-Id: I8c9b095ee012a4faca90ed026cea846b7d178dc2
This commit is contained in:
parent
9d5ca8e5b6
commit
5afab56307
|
@ -18,7 +18,10 @@
|
|||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import abc
|
||||
|
||||
import oauth2 as oauth
|
||||
import six
|
||||
|
||||
from keystone.common import dependency
|
||||
from keystone.common import extension
|
||||
|
@ -135,9 +138,11 @@ class Manager(manager.Manager):
|
|||
super(Manager, self).__init__(CONF.oauth1.driver)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class Driver(object):
|
||||
"""Interface description for an OAuth1 driver."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def create_consumer(self, consumer_ref):
|
||||
"""Create consumer.
|
||||
|
||||
|
@ -148,6 +153,7 @@ class Driver(object):
|
|||
"""
|
||||
raise exception.NotImplemented()
|
||||
|
||||
@abc.abstractmethod
|
||||
def update_consumer(self, consumer_id, consumer_ref):
|
||||
"""Update consumer.
|
||||
|
||||
|
@ -160,6 +166,7 @@ class Driver(object):
|
|||
"""
|
||||
raise exception.NotImplemented()
|
||||
|
||||
@abc.abstractmethod
|
||||
def list_consumers(self):
|
||||
"""List consumers.
|
||||
|
||||
|
@ -168,6 +175,7 @@ class Driver(object):
|
|||
"""
|
||||
raise exception.NotImplemented()
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_consumer(self, consumer_id):
|
||||
"""Get consumer, returns the consumer id (key)
|
||||
and description.
|
||||
|
@ -179,6 +187,7 @@ class Driver(object):
|
|||
"""
|
||||
raise exception.NotImplemented()
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_consumer_with_secret(self, consumer_id):
|
||||
"""Like get_consumer() but returned consumer_ref includes
|
||||
the consumer secret.
|
||||
|
@ -193,6 +202,7 @@ class Driver(object):
|
|||
"""
|
||||
raise exception.NotImplemented()
|
||||
|
||||
@abc.abstractmethod
|
||||
def delete_consumer(self, consumer_id):
|
||||
"""Delete consumer.
|
||||
|
||||
|
@ -203,6 +213,7 @@ class Driver(object):
|
|||
"""
|
||||
raise exception.NotImplemented()
|
||||
|
||||
@abc.abstractmethod
|
||||
def list_access_tokens(self, user_id):
|
||||
"""List access tokens.
|
||||
|
||||
|
@ -213,6 +224,7 @@ class Driver(object):
|
|||
"""
|
||||
raise exception.NotImplemented()
|
||||
|
||||
@abc.abstractmethod
|
||||
def delete_access_token(self, user_id, access_token_id):
|
||||
"""Delete access token.
|
||||
|
||||
|
@ -225,6 +237,7 @@ class Driver(object):
|
|||
"""
|
||||
raise exception.NotImplemented()
|
||||
|
||||
@abc.abstractmethod
|
||||
def create_request_token(self, consumer_id, requested_project,
|
||||
request_token_duration):
|
||||
"""Create request token.
|
||||
|
@ -240,6 +253,7 @@ class Driver(object):
|
|||
"""
|
||||
raise exception.NotImplemented()
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_request_token(self, request_token_id):
|
||||
"""Get request token.
|
||||
|
||||
|
@ -250,6 +264,7 @@ class Driver(object):
|
|||
"""
|
||||
raise exception.NotImplemented()
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_access_token(self, access_token_id):
|
||||
"""Get access token.
|
||||
|
||||
|
@ -260,6 +275,7 @@ class Driver(object):
|
|||
"""
|
||||
raise exception.NotImplemented()
|
||||
|
||||
@abc.abstractmethod
|
||||
def authorize_request_token(self, request_id, user_id, role_ids):
|
||||
"""Authorize request token.
|
||||
|
||||
|
@ -274,6 +290,7 @@ class Driver(object):
|
|||
"""
|
||||
raise exception.NotImplemented()
|
||||
|
||||
@abc.abstractmethod
|
||||
def create_access_token(self, request_id, access_token_duration):
|
||||
"""Create access token.
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import inspect
|
|||
import testtools
|
||||
|
||||
from keystone.contrib import endpoint_filter
|
||||
from keystone.contrib import oauth1
|
||||
from keystone import exception
|
||||
|
||||
|
||||
|
@ -48,10 +47,6 @@ class TestDrivers(testtools.TestCase):
|
|||
if name[0] != '_' and callable(method):
|
||||
self.assertMethodNotImplemented(method)
|
||||
|
||||
def test_oauth1_driver_unimplemented(self):
|
||||
interface = oauth1.Driver()
|
||||
self.assertInterfaceNotImplemented(interface)
|
||||
|
||||
def test_endpoint_filter_driver_unimplemented(self):
|
||||
interface = endpoint_filter.Driver()
|
||||
self.assertInterfaceNotImplemented(interface)
|
||||
|
|
Loading…
Reference in New Issue