本文整理汇总了Python中host.hypervisor.esx.vim_client.VimClient._acquire_local_credentials方法的典型用法代码示例。如果您正苦于以下问题:Python VimClient._acquire_local_credentials方法的具体用法?Python VimClient._acquire_local_credentials怎么用?Python VimClient._acquire_local_credentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类host.hypervisor.esx.vim_client.VimClient
的用法示例。
在下文中一共展示了VimClient._acquire_local_credentials方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_acquire_credentials
# 需要导入模块: from host.hypervisor.esx.vim_client import VimClient [as 别名]
# 或者: from host.hypervisor.esx.vim_client.VimClient import _acquire_local_credentials [as 别名]
def test_acquire_credentials(self, si_method_mock):
"""The mockery of acquiring local hostd credentials"""
local_ticket_mock = MagicMock(name="local_ticket")
type(local_ticket_mock).userName = PropertyMock(return_value="local-root")
pwd_fd, pwd_path = tempfile.mkstemp()
os.write(pwd_fd, "local-root-password")
os.close(pwd_fd)
type(local_ticket_mock).passwordFilePath = PropertyMock(return_value=pwd_path)
session_manager_mock = MagicMock(name="session-manager")
session_manager_mock.AcquireLocalTicket.return_value = local_ticket_mock
si = MagicMock(name="si")
session_manager_property = PropertyMock(return_value=session_manager_mock)
type(si.content).sessionManager = session_manager_property
si_method_mock.return_value = si
vim_client = VimClient(auto_sync=False)
(user, password) = vim_client._acquire_local_credentials()
os.remove(pwd_path)
assert_that(user, equal_to("local-root"))
assert_that(password, equal_to("local-root-password"))