Merge ~powersj/cloud-init:test-set-password-list into cloud-init:master

Proposed by Joshua Powers
Status: Superseded
Proposed branch: ~powersj/cloud-init:test-set-password-list
Merge into: cloud-init:master
Diff against target: 111 lines (+64/-6)
4 files modified
cloudinit/config/cc_set_passwords.py (+2/-2)
tests/cloud_tests/configs/modules/set_password_list.yaml (+4/-4)
tests/cloud_tests/configs/modules/set_password_list_string.yaml (+33/-0)
tests/cloud_tests/testcases/modules/set_password_list_string.py (+25/-0)
Reviewer Review Type Date Requested Status
cloud-init Commiters Pending
Review via email: mp+319877@code.launchpad.net

This proposal has been superseded by a proposal from 2017-03-14.

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.

To post a comment you must log in.

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/config/cc_set_passwords.py b/cloudinit/config/cc_set_passwords.py
2index 1611704..8440e59 100755
3--- a/cloudinit/config/cc_set_passwords.py
4+++ b/cloudinit/config/cc_set_passwords.py
5@@ -47,7 +47,7 @@ enabled, disabled, or left to system defaults using ``ssh_pwauth``.
6 chpasswd:
7 list: |
8 user1:password1
9- user2:Random
10+ user2:RANDOM
11 user3:password3
12 user4:R
13
14@@ -57,7 +57,7 @@ enabled, disabled, or left to system defaults using ``ssh_pwauth``.
15 chpasswd:
16 list:
17 - user1:password1
18- - user2:Random
19+ - user2:RANDOM
20 - user3:password3
21 - user4:R
22 """
23diff --git a/tests/cloud_tests/configs/modules/set_password_list.yaml b/tests/cloud_tests/configs/modules/set_password_list.yaml
24index 3612904..4d29aab 100644
25--- a/tests/cloud_tests/configs/modules/set_password_list.yaml
26+++ b/tests/cloud_tests/configs/modules/set_password_list.yaml
27@@ -18,10 +18,10 @@ cloud_config: |
28 password: $1$xyz$sPMsLNmf66Ohl.ol6JvzE.
29 lock_passwd: false
30 chpasswd:
31- list: |
32- tom:mypassword123!
33- dick:R
34- harry:Random
35+ list:
36+ - tom:mypassword123!
37+ - dick:R
38+ - harry:RANDOM
39 collect_scripts:
40 shadow: |
41 #!/bin/bash
42diff --git a/tests/cloud_tests/configs/modules/set_password_list_string.yaml b/tests/cloud_tests/configs/modules/set_password_list_string.yaml
43new file mode 100644
44index 0000000..2d57e5a
45--- /dev/null
46+++ b/tests/cloud_tests/configs/modules/set_password_list_string.yaml
47@@ -0,0 +1,33 @@
48+#
49+# Set password of list of users as a string
50+#
51+cloud_config: |
52+ #cloud-config
53+ ssh_pwauth: yes
54+ users:
55+ - name: tom
56+ password: $1$xyz$sPMsLNmf66Ohl.ol6JvzE.
57+ lock_passwd: false
58+ - name: dick
59+ password: $1$xyz$sPMsLNmf66Ohl.ol6JvzE.
60+ lock_passwd: false
61+ - name: harry
62+ password: $1$xyz$sPMsLNmf66Ohl.ol6JvzE.
63+ lock_passwd: false
64+ - name: jane
65+ password: $1$xyz$sPMsLNmf66Ohl.ol6JvzE.
66+ lock_passwd: false
67+ chpasswd:
68+ list: |
69+ tom:mypassword123!
70+ dick:R
71+ harry:RANDOM
72+collect_scripts:
73+ shadow: |
74+ #!/bin/bash
75+ cat /etc/shadow
76+ sshd_config: |
77+ #!/bin/bash
78+ grep '^PasswordAuth' /etc/ssh/sshd_config
79+
80+# vi: ts=4 expandtab
81diff --git a/tests/cloud_tests/testcases/modules/set_password_list_string.py b/tests/cloud_tests/testcases/modules/set_password_list_string.py
82new file mode 100644
83index 0000000..3787af0
84--- /dev/null
85+++ b/tests/cloud_tests/testcases/modules/set_password_list_string.py
86@@ -0,0 +1,25 @@
87+# This file is part of cloud-init. See LICENSE file for license information.
88+
89+"""cloud-init Integration Test Verify Script"""
90+from tests.cloud_tests.testcases import base
91+
92+
93+class TestPasswordListString(base.CloudTestCase):
94+ """Test password module"""
95+
96+ # TODO: Verify dick and harry passwords are random
97+ # TODO: Verify tom's password was changed
98+
99+ def test_shadow(self):
100+ """Test every tom, dick, and harry user in shadow"""
101+ out = self.get_data_file('shadow')
102+ self.assertIn('tom:', out)
103+ self.assertIn('dick:', out)
104+ self.assertIn('harry:', out)
105+
106+ def test_sshd_config(self):
107+ """Test sshd config allows passwords"""
108+ out = self.get_data_file('sshd_config')
109+ self.assertIn('PasswordAuthentication yes', out)
110+
111+# vi: ts=4 expandtab

Subscribers

People subscribed via source and target branches