2017-03-20 21:36:53 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
import infra.basetest
|
|
|
|
|
2017-10-05 23:42:09 +02:00
|
|
|
|
2017-03-20 21:36:53 +01:00
|
|
|
class TestDropbear(infra.basetest.BRTest):
|
2019-02-05 10:45:40 +01:00
|
|
|
passwd = "testpwd"
|
2017-03-20 21:36:53 +01:00
|
|
|
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
|
2017-10-05 23:42:08 +02:00
|
|
|
"""
|
2019-02-05 10:45:40 +01:00
|
|
|
BR2_TARGET_GENERIC_ROOT_PASSWD="{}"
|
2017-10-05 23:42:08 +02:00
|
|
|
BR2_SYSTEM_DHCP="eth0"
|
|
|
|
BR2_PACKAGE_DROPBEAR=y
|
2019-02-05 10:45:41 +01:00
|
|
|
BR2_PACKAGE_SSHPASS=y
|
2017-10-05 23:42:08 +02:00
|
|
|
BR2_TARGET_ROOTFS_CPIO=y
|
|
|
|
# BR2_TARGET_ROOTFS_TAR is not set
|
2019-02-05 10:45:40 +01:00
|
|
|
""".format(passwd)
|
2017-03-20 21:36:53 +01:00
|
|
|
|
|
|
|
def test_run(self):
|
|
|
|
img = os.path.join(self.builddir, "images", "rootfs.cpio")
|
|
|
|
self.emulator.boot(arch="armv5",
|
|
|
|
kernel="builtin",
|
|
|
|
options=["-initrd", img,
|
|
|
|
"-net", "nic",
|
2019-02-05 10:45:42 +01:00
|
|
|
"-net", "user"])
|
2019-02-05 10:45:40 +01:00
|
|
|
self.emulator.login(self.passwd)
|
2017-03-20 21:36:53 +01:00
|
|
|
cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:22"
|
|
|
|
_, exit_code = self.emulator.run(cmd)
|
|
|
|
self.assertEqual(exit_code, 0)
|
2019-02-05 10:45:41 +01:00
|
|
|
|
|
|
|
cmd = "sshpass -p {} ssh -y localhost /bin/true".format(self.passwd)
|
|
|
|
_, exit_code = self.emulator.run(cmd)
|
|
|
|
self.assertEqual(exit_code, 0)
|