test_configuration_change.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:infrasim-compute 作者: InfraSIM 项目源码 文件源码
def test_set_credential(self):
        self.conf["racadm"] = {}
        self.conf["racadm"]["username"] = "admin"
        self.conf["racadm"]["password"] = "fake"

        # Start service
        node = model.CNode(self.conf)
        node.init()
        node.precheck()
        node.start()

        # Check process
        str_result = run_command(PS_RACADM, True,
                                 subprocess.PIPE, subprocess.PIPE)[1]
        assert "racadmsim test 0.0.0.0 10022 admin fake" in str_result

        # Connect with wrong credential
        self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        try:
            self.ssh.connect('127.0.0.1',
                             username='admin',
                             password='admin',
                             port=10022)
        except paramiko.AuthenticationException:
            assert True
        else:
            assert False

        # Connect with correct credential
        self.ssh.connect('127.0.0.1',
                         username='admin',
                         password='fake',
                         port=10022)
        self.channel = self.ssh.invoke_shell()

        # Test racadmsim is working
        self.channel.send("racadm help"+chr(13))
        time.sleep(1)
        str_output = read_buffer(self.channel)
        assert "hwinventory" in str_output
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号