cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #01702
[Merge] ~powersj/cloud-init:test-set-password-list into cloud-init:master
Joshua Powers has proposed merging ~powersj/cloud-init:test-set-password-list into cloud-init:master.
Commit message:
test: Add test for setting password as list
This adds an integration test for setting passwords when given
as a list, rather than a string. This also updates the docs and
tests so that Random is now RANDOM as is correct.
Requested reviews:
Server Team CI bot (server-team-bot): continuous-integration
cloud init development team (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~powersj/cloud-init/+git/cloud-init/+merge/319878
--
Your team cloud init development team is requested to review the proposed merge of ~powersj/cloud-init:test-set-password-list into cloud-init:master.
diff --git a/cloudinit/config/cc_set_passwords.py b/cloudinit/config/cc_set_passwords.py
index 1611704..8440e59 100755
--- a/cloudinit/config/cc_set_passwords.py
+++ b/cloudinit/config/cc_set_passwords.py
@@ -47,7 +47,7 @@ enabled, disabled, or left to system defaults using ``ssh_pwauth``.
chpasswd:
list: |
user1:password1
- user2:Random
+ user2:RANDOM
user3:password3
user4:R
@@ -57,7 +57,7 @@ enabled, disabled, or left to system defaults using ``ssh_pwauth``.
chpasswd:
list:
- user1:password1
- - user2:Random
+ - user2:RANDOM
- user3:password3
- user4:R
"""
diff --git a/tests/cloud_tests/configs/modules/set_password_list.yaml b/tests/cloud_tests/configs/modules/set_password_list.yaml
index 3612904..4d29aab 100644
--- a/tests/cloud_tests/configs/modules/set_password_list.yaml
+++ b/tests/cloud_tests/configs/modules/set_password_list.yaml
@@ -18,10 +18,10 @@ cloud_config: |
password: $1$xyz$sPMsLNmf66Ohl.ol6JvzE.
lock_passwd: false
chpasswd:
- list: |
- tom:mypassword123!
- dick:R
- harry:Random
+ list:
+ - tom:mypassword123!
+ - dick:R
+ - harry:RANDOM
collect_scripts:
shadow: |
#!/bin/bash
diff --git a/tests/cloud_tests/configs/modules/set_password_list_string.yaml b/tests/cloud_tests/configs/modules/set_password_list_string.yaml
new file mode 100644
index 0000000..2d57e5a
--- /dev/null
+++ b/tests/cloud_tests/configs/modules/set_password_list_string.yaml
@@ -0,0 +1,33 @@
+#
+# Set password of list of users as a string
+#
+cloud_config: |
+ #cloud-config
+ ssh_pwauth: yes
+ users:
+ - name: tom
+ password: $1$xyz$sPMsLNmf66Ohl.ol6JvzE.
+ lock_passwd: false
+ - name: dick
+ password: $1$xyz$sPMsLNmf66Ohl.ol6JvzE.
+ lock_passwd: false
+ - name: harry
+ password: $1$xyz$sPMsLNmf66Ohl.ol6JvzE.
+ lock_passwd: false
+ - name: jane
+ password: $1$xyz$sPMsLNmf66Ohl.ol6JvzE.
+ lock_passwd: false
+ chpasswd:
+ list: |
+ tom:mypassword123!
+ dick:R
+ harry:RANDOM
+collect_scripts:
+ shadow: |
+ #!/bin/bash
+ cat /etc/shadow
+ sshd_config: |
+ #!/bin/bash
+ grep '^PasswordAuth' /etc/ssh/sshd_config
+
+# vi: ts=4 expandtab
diff --git a/tests/cloud_tests/testcases/modules/set_password_list_string.py b/tests/cloud_tests/testcases/modules/set_password_list_string.py
new file mode 100644
index 0000000..3787af0
--- /dev/null
+++ b/tests/cloud_tests/testcases/modules/set_password_list_string.py
@@ -0,0 +1,25 @@
+# This file is part of cloud-init. See LICENSE file for license information.
+
+"""cloud-init Integration Test Verify Script"""
+from tests.cloud_tests.testcases import base
+
+
+class TestPasswordListString(base.CloudTestCase):
+ """Test password module"""
+
+ # TODO: Verify dick and harry passwords are random
+ # TODO: Verify tom's password was changed
+
+ def test_shadow(self):
+ """Test every tom, dick, and harry user in shadow"""
+ out = self.get_data_file('shadow')
+ self.assertIn('tom:', out)
+ self.assertIn('dick:', out)
+ self.assertIn('harry:', out)
+
+ def test_sshd_config(self):
+ """Test sshd config allows passwords"""
+ out = self.get_data_file('sshd_config')
+ self.assertIn('PasswordAuthentication yes', out)
+
+# vi: ts=4 expandtab