summaryrefslogtreecommitdiff
path: root/ceilometermiddleware/tests/test_swift.py
diff options
context:
space:
mode:
authorMehdi Abaakouk <sileht@sileht.net>2017-05-13 13:37:33 +0200
committerMehdi Abaakouk <sileht@sileht.net>2017-05-19 07:30:52 +0200
commite2bf485044d8f3743da9298a9e461c5808be31f3 (patch)
treeba505f0a83670b398a7288d28a03e58bb085ec23 /ceilometermiddleware/tests/test_swift.py
parent0cea730b10000f9e16af33d1cbbe9ca2004a3880 (diff)
downloadceilometermiddleware-e2bf485044d8f3743da9298a9e461c5808be31f3.tar.gz
retrieve project id to ignore from keystone
We currently allows only project uuid, but this is a pain for deployer. Also the default is a project name which doesn't work... This change queries keystone to retrieve project ids when the ignore_projects list are names. By default, if auth_type is not set, we keep the previous behavior to not query keystone. Change-Id: I270d080d3e65eb6b0cd823498a4dd37389c49221
Diffstat (limited to 'ceilometermiddleware/tests/test_swift.py')
-rw-r--r--ceilometermiddleware/tests/test_swift.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/ceilometermiddleware/tests/test_swift.py b/ceilometermiddleware/tests/test_swift.py
index 59daed6..9b788b4 100644
--- a/ceilometermiddleware/tests/test_swift.py
+++ b/ceilometermiddleware/tests/test_swift.py
@@ -12,13 +12,15 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
+import threading
+
import mock
from oslo_config import cfg
import six
from ceilometermiddleware import swift
from ceilometermiddleware.tests import base as tests_base
-import threading
+from keystoneauth1.fixture import keystoneauth_betamax as betamax
class FakeApp(object):
@@ -429,3 +431,31 @@ class TestSwift(tests_base.TestCase):
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertFalse(notify.called)
+
+ def test_ignore_projects_without_keystone(self):
+ app = swift.Swift(FakeApp(), {
+ 'ignore_projects': 'cf0356aaac7c42bba5a744339a6169fa,'
+ '18157dd635bb413c9e27686fee93c583',
+ })
+ self.assertEqual(["cf0356aaac7c42bba5a744339a6169fa",
+ "18157dd635bb413c9e27686fee93c583"],
+ app.ignore_projects)
+
+ @mock.patch.object(swift.LOG, 'warning')
+ def test_ignore_projects_with_keystone(self, warning):
+ self.useFixture(betamax.BetamaxFixture(
+ cassette_name='list_projects',
+ cassette_library_dir='ceilometermiddleware/tests/data',
+ ))
+ app = swift.Swift(FakeApp(), {
+ 'auth_type': 'v2password',
+ 'auth_url': 'https://[::1]:5000/v2.0',
+ 'username': 'admin',
+ 'tenant_name': 'admin',
+ 'password': 'secret',
+ 'ignore_projects': 'services,gnocchi',
+ })
+ self.assertEqual(["147cc0a9263c4964926f3ee7b6ba3685"],
+ app.ignore_projects)
+ warning.assert_called_once_with(
+ "fail to find project '%s' in keystone", "gnocchi")