File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ RUN echo "user:foo" | chpasswd
64
64
RUN echo "*nat\n :PREROUTING ACCEPT [0:0]\n :INPUT ACCEPT [0:0]\n :OUTPUT ACCEPT [0:0]\n :POSTROUTING ACCEPT [0:0]\n -A PREROUTING -d 192.168.0.1/32 -j REDIRECT\n COMMIT\n *filter\n :INPUT ACCEPT [0:0]\n :FORWARD ACCEPT [0:0]\n :OUTPUT ACCEPT [0:0]\n -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT\n COMMIT" > /etc/iptables/rules.v4
65
65
66
66
# Expiration date for user "user"
67
- RUN chage -E 20000 user
67
+ RUN chage -E 20000 -m 7 -M 90 user
68
68
69
69
# Some python3 virtualenv
70
70
RUN virtualenv /v
Original file line number Diff line number Diff line change @@ -271,6 +271,13 @@ def test_user(host):
271
271
assert user .password == "*"
272
272
273
273
274
+ def test_user_password_days (host ):
275
+ assert host .user ("root" ).password_max_days is 99999
276
+ assert host .user ("root" ).password_min_days is 0
277
+ assert host .user ("user" ).password_max_days == 90
278
+ assert host .user ("user" ).password_min_days == 7
279
+
280
+
274
281
def test_user_user (host ):
275
282
user = host .user ("user" )
276
283
assert user .exists
Original file line number Diff line number Diff line change @@ -91,6 +91,24 @@ def password(self):
91
91
"""Return the crypted user password"""
92
92
return self .check_output ("getent shadow %s" , self .name ).split (":" )[1 ]
93
93
94
+ @property
95
+ def password_max_days (self ):
96
+ """Return the maximum number of days between password changes"""
97
+ days = self .check_output ("getent shadow %s" , self .name ).split (":" )[4 ]
98
+ try :
99
+ return int (days )
100
+ except ValueError :
101
+ return None
102
+
103
+ @property
104
+ def password_min_days (self ):
105
+ """Return the minimum number of days between password changes"""
106
+ days = self .check_output ("getent shadow %s" , self .name ).split (":" )[3 ]
107
+ try :
108
+ return int (days )
109
+ except ValueError :
110
+ return None
111
+
94
112
@property
95
113
def gecos (self ):
96
114
"""Return the user comment/gecos field"""
You can’t perform that action at this time.
0 commit comments