support/testing: test_dropbear.py: use a constant for the password
PATCH 1/3 support/testing: test_dropbear.py: use a constant for the password
The password is used in multiple places, so add a constant for it instead of hardcoding it multiple times.
--- support/testing/tests/package/test_dropbear.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
support/testing/tests/package/test_dropbear.py +4 -3
@@ -4,14 +4,15 @@ import infra.basetest class TestDropbear(infra.basetest.BRTest): + passwd = "testpwd" config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ """ - BR2_TARGET_GENERIC_ROOT_PASSWD="testpwd" + BR2_TARGET_GENERIC_ROOT_PASSWD="{}" BR2_SYSTEM_DHCP="eth0" BR2_PACKAGE_DROPBEAR=y BR2_TARGET_ROOTFS_CPIO=y # BR2_TARGET_ROOTFS_TAR is not set - """ + """.format(passwd) def test_run(self): img = os.path.join(self.builddir, "images", "rootfs.cpio")
@@ -20,7 +21,7 @@ class TestDropbear(infra.basetest.BRTest): options=["-initrd", img, "-net", "nic", "-net", "user,hostfwd=tcp::2222-:22"]) - self.emulator.login("testpwd") + self.emulator.login(self.passwd) cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:22" _, exit_code = self.emulator.run(cmd) self.assertEqual(exit_code, 0)
Signature · 1 line
2.11.0
PATCH 1/3 support/testing: test_dropbear.py: use a constant for the password
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Peter" == Peter Korsgaard <[email protected]> writes:
The password is used in multiple places, so add a constant for it instead of hardcoding it multiple times.
Signed-off-by Peter Korsgaard <[email protected]>
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 2/3 support/testing: test_dropbear.py: add test for ssh connection to localhost
In reply to Peter KorsgaardUse sshpass to pass the password on the command line.
--- support/testing/tests/package/test_dropbear.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
support/testing/tests/package/test_dropbear.py +5 -3
@@ -10,6 +10,7 @@ class TestDropbear(infra.basetest.BRTest): BR2_TARGET_GENERIC_ROOT_PASSWD="{}" BR2_SYSTEM_DHCP="eth0" BR2_PACKAGE_DROPBEAR=y + BR2_PACKAGE_SSHPASS=y BR2_TARGET_ROOTFS_CPIO=y # BR2_TARGET_ROOTFS_TAR is not set """.format(passwd)
@@ -25,6 +26,7 @@ class TestDropbear(infra.basetest.BRTest): cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:22" _, exit_code = self.emulator.run(cmd) self.assertEqual(exit_code, 0) - # Would be useful to try to login through SSH here, through - # localhost:2222, though it is not easy to pass the ssh - # password on the command line. + + cmd = "sshpass -p {} ssh -y localhost /bin/true".format(self.passwd) + _, exit_code = self.emulator.run(cmd) + self.assertEqual(exit_code, 0)
Signature · 1 line
2.11.0
PATCH 2/3 support/testing: test_dropbear.py: add test for ssh connection to localhost
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Peter" == Peter Korsgaard <[email protected]> writes:
Use sshpass to pass the password on the command line.
Signed-off-by Peter Korsgaard <[email protected]>
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 3/3 support/testing: test_dropbear.py: drop ssh port forward to the host
In reply to Peter KorsgaardIt is not used and may conflict with other services running on port 2222 on the host machine.
--- support/testing/tests/package/test_dropbear.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
support/testing/tests/package/test_dropbear.py +1 -1
@@ -21,7 +21,7 @@ class TestDropbear(infra.basetest.BRTest): kernel="builtin", options=["-initrd", img, "-net", "nic", - "-net", "user,hostfwd=tcp::2222-:22"]) + "-net", "user"]) self.emulator.login(self.passwd) cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:22" _, exit_code = self.emulator.run(cmd)
Signature · 1 line
2.11.0
PATCH 3/3 support/testing: test_dropbear.py: drop ssh port forward to the host
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Peter" == Peter Korsgaard <[email protected]> writes:
It is not used and may conflict with other services running on port 2222 on the host machine.
Signed-off-by Peter Korsgaard <[email protected]>
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard