|
| 1 | +# Copyright (c) 2025 NVIDIA |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 12 | +# implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +import os |
| 17 | +import subprocess |
| 18 | +import unittest |
| 19 | + |
| 20 | +from . import TEST_CONFIG |
| 21 | + |
| 22 | + |
| 23 | +class TestOpenStackClient(unittest.TestCase): |
| 24 | + @classmethod |
| 25 | + def setUpClass(cls): |
| 26 | + # NB: Only runs for v1 auth, to exercise our keystoneauth plugin |
| 27 | + cls.skip_tests = (TEST_CONFIG is None or |
| 28 | + TEST_CONFIG['auth_version'] != '1') |
| 29 | + cls.env = { |
| 30 | + 'OS_AUTH_TYPE': 'v1password', |
| 31 | + 'OS_AUTH_URL': TEST_CONFIG['auth_url'] or '', |
| 32 | + 'OS_USERNAME': TEST_CONFIG['account_username'] or '', |
| 33 | + 'OS_PASSWORD': TEST_CONFIG['password'] or '', |
| 34 | + 'OS_CACERT': TEST_CONFIG['cacert'] or '', |
| 35 | + } |
| 36 | + if 'PATH' in os.environ: |
| 37 | + cls.env['PATH'] = os.environ['PATH'] |
| 38 | + |
| 39 | + def setUp(self): |
| 40 | + if self.skip_tests: |
| 41 | + raise unittest.SkipTest('SKIPPING V1-AUTH TESTS') |
| 42 | + |
| 43 | + def _run(self, *args): |
| 44 | + subprocess.run(args, env=self.env, check=True) |
| 45 | + |
| 46 | + def test_token_issue(self): |
| 47 | + self._run('openstack', 'token', 'issue') |
| 48 | + |
| 49 | + def test_catalog_list(self): |
| 50 | + self._run('openstack', 'catalog', 'list') |
| 51 | + |
| 52 | + def test_catalog_show(self): |
| 53 | + self._run('openstack', 'catalog', 'show', 'swift') |
| 54 | + self._run('openstack', 'catalog', 'show', 'object-store') |
| 55 | + self._run('openstack', 'catalog', 'show', 'auth') |
| 56 | + |
| 57 | + def test_account_show(self): |
| 58 | + self._run('openstack', 'object', 'store', 'account', 'show') |
| 59 | + # If account show works and the openstacksdk tests work, presumably |
| 60 | + # container/object commands work, too |
| 61 | + |
| 62 | + # service list? endpoint list? |
0 commit comments