Skip to content

Commit

Permalink
Add support for keystoneclient 0.4.0
Browse files Browse the repository at this point in the history
Keystoneclient auth_middleware changed the way it parses the datetime
returned from the cache, breaking the Ceilometer unit tests. This patch
fixes the fake cache system that's used in unit test, so it works with
all keystoneclient versions.

This also update the sample configuration files to include the new
options provided by keystoneclient 0.4.0.

Fixes-Bug: #1238529

Change-Id: Iecfd50d9e9801aeb919f2c09a728e4ea15245a5e
(cherry picked from commit e3cef87)
  • Loading branch information
jd authored and ttx committed Oct 11, 2013
1 parent 192bdff commit c0a3f3c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
11 changes: 11 additions & 0 deletions etc/ceilometer/ceilometer.conf.sample
Expand Up @@ -742,6 +742,10 @@
# server. (boolean value)
#http_connect_timeout=<None>

# How many times are we trying to reconnect when communicating
# with Identity API Server. (integer value)
#http_request_max_retries=3

# Allows to pass in the name of a fake http_handler callback
# function used instead of httplib.HTTPConnection or
# httplib.HTTPSConnection. Useful for unit testing where
Expand Down Expand Up @@ -774,6 +778,13 @@
# (string value)
#keyfile=<None>

# A PEM encoded Certificate Authority to use when verifying
# HTTPs connections. Defaults to system CAs. (string value)
#cafile=<None>

# Verify HTTPS connections. (boolean value)
#insecure=false

# Directory used to cache files related to PKI tokens (string
# value)
#signing_dir=<None>
Expand Down
19 changes: 8 additions & 11 deletions tests/api/v2/test_acl_scenarios.py
Expand Up @@ -27,6 +27,7 @@
from ceilometer.api import acl
from ceilometer.publisher import rpc
from ceilometer.tests import db as tests_db
from ceilometer.openstack.common import timeutils

from .base import FunctionalTest

Expand All @@ -37,12 +38,8 @@


class FakeMemcache(object):
def __init__(self):
self.set_key = None
self.set_value = None
self.token_expiration = None

def get(self, key):
@staticmethod
def get(key):
if key == "tokens/%s" % VALID_TOKEN:
dt = datetime.datetime.now() + datetime.timedelta(minutes=5)
return json.dumps(({'access': {
Expand All @@ -55,7 +52,7 @@ def get(self, key):
'roles': [
{'name': 'admin'},
]},
}}, dt.strftime("%s")))
}}, timeutils.isotime(dt)))
if key == "tokens/%s" % VALID_TOKEN2:
dt = datetime.datetime.now() + datetime.timedelta(minutes=5)
return json.dumps(({'access': {
Expand All @@ -68,11 +65,11 @@ def get(self, key):
'roles': [
{'name': 'Member'},
]},
}}, dt.strftime("%s")))
}}, timeutils.isotime(dt)))

def set(self, key, value, **kwargs):
self.set_value = value
self.set_key = key
@staticmethod
def set(key, value, **kwargs):
pass


class TestAPIACL(FunctionalTest,
Expand Down

0 comments on commit c0a3f3c

Please sign in to comment.