python-tripleoclient/tripleoclient/tests/v1/test_overcloud_admin.py
Kevin Carter af749d1a6a
Use correct default key file and normalize the usage
The provision command was defaulting to id_rsa.pub, however the deploy
command uses id_rsa_tripleo for initial setup.

When using the deploy command for provision as well, use the public
key, not the private id_rsa_tripleo.

This option was being processed in several different ways, this change
normalize it by creating a single function in the Command class, which
all inheriting methods will consume. Tests have been updated to
accomodate this change.

Related-Bug: #1863920
Change-Id: I221480f3cfc77545a8fcbef777829239c3bad0a0
Signed-off-by: Kevin Carter <kecarter@redhat.com>
2020-02-20 08:52:09 -06:00

43 lines
1.6 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# 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 mock
from tripleoclient.tests.v1 import test_plugin
from tripleoclient import utils
from tripleoclient.v1 import overcloud_admin
from tripleoclient.workflows import deployment
@mock.patch.object(utils, 'get_stack', autospec=True)
@mock.patch.object(deployment, 'get_hosts_and_enable_ssh_admin', autospec=True)
class TestAdminAuthorize(test_plugin.TestPluginV1):
def setUp(self):
super(TestAdminAuthorize, self).setUp()
self.cmd = overcloud_admin.Authorize(self.app, None)
self.app.client_manager = mock.Mock()
def test_ok(self, mock_get_host_and_enable_ssh_admin, mock_get_stack):
arglist = []
parsed_args = self.check_parser(self.cmd, arglist, [])
mock_stack = mock.Mock()
mock_get_stack.return_value = mock_stack
self.cmd.take_action(parsed_args)
mock_get_host_and_enable_ssh_admin.assert_called_once_with(
mock_stack,
parsed_args.overcloud_ssh_network,
parsed_args.overcloud_ssh_user,
mock.ANY,
parsed_args.overcloud_ssh_port_timeout
)