/srv/irclogs.ubuntu.com/2024/08/27/#cloud-init.txt

=== tds1 is now known as tds
blackboxswminimal: looking through this now. Also going to write some test cases to exercise the test_distro_empty_password which will actually exercise the various subp grep logic to ensure we we see success/failure based on what distro defines as shadow match substrings.15:41
blackboxswthat kind of behavior where pre-existing tests start failing when new tests are added typically means a either mock or fixture that is too broad or not being torn down properly in the pre-existing test is being affected by additional mock values added in new unittests. I try making certain that mocks are generally scoped at as close to the module as possible to avoid potential interaction with other module tests.15:44
blackboxswFor example mocking the module-local import path 'cloudinit.config.cc_<somemodule>.util.load_binary_file' instead of 'cloudinit.util.load_binary_path'15:45
blackboxswminimal: If there is something in-flight you'd like to push to your PR I can look that while I write up a supplementary unittest that validates greps of shadow file content. 15:47
blackboxswtypo: I can look *at* that 15:48
minimalblackboxsw: the grep logic tests sound good, I've been struggling as to how to handle the _check_if_existing_password boolean return code15:49
blackboxswI'm also thinking of flipping the logic and return codes of _check_if_existing_password method to be named _check_user_has_empty_password because that method isn't really asserting that a user has a password. It's asserting that they don't have an empty locked/empty password15:51
blackboxswfor example, users not present at all in /etc/shadow would still get a True from _check_if_existing_password15:51
blackboxswso the name is a bit misleading15:52
minimaltrue15:52
minimalok, so rather than bashing my head more with failing tests I think I should do the rebase (plus your suggesting change from yesterday) and then take things from there15:54
blackboxswplease do. Or wait an hour and I can push a changeset directly to your PR that you can review/adapt if you want. 15:55
minimalwhichever suits you15:55
blackboxsw ok it may make things easier if I can dump the suggestions I have directly into your PR in the next hour. Then we can address any test coverage gaps or different suggestions necessary.15:57
minimalok then15:57
blackboxswI'll ping when I think I'm done. thank you for your patience15:57
blackboxswminimal: I also am thinking about avoiding grep in this case because we also want to assert the username is in the shadow file in the first place, and shelling out with subprocess to grep for simple pattern matching as well as grepping for the presence of a username is maybe a bit costly.   I'll have an example in 30 mins16:21
minimalok16:22
blackboxswminimal: taking a break for lunch, and pushed a work in progress commit for your review/comments and an approach I'm working towards. I can clean up the comments in an hour18:44
minimalblackboxsw: looks good, only a couple of minor points, in test_create_users.py the _existing_shadow_grep function can now be removed, also perhaps rename the test id "no_unlock_in_snappy_on_empty_locked_user_passwd_in_extrausers" to "no_unlock_in_snappy_on_locked_empty_user_passwd_in_extrausers" to fit in with the id name above it (swapping the order of "empty" and "locked" in the name)20:48
blackboxswthanks minimal just force pushed that commit again right now with a fix or two and more unittests20:49
minimalI'll have to rework some of the BSD (test_*bsd.py) testcases I have here (or just get rid of them) as they're expecting a "grep"20:49
blackboxsw+1, I have a school function to step away to but will be back checking in later. would like to wrap up what we can on this tomorrow if possible. 20:49
blackboxswideally this is one of the last things to get into 24.3.20:50
=== blackboxsw is now known as blackboxsw_away
minimalblackboxsw: I assume the patterns in openbsd.py would also need to be escaped22:02
minimalblackboxsw: re the freebsd tests, you've got 2 with same id "no_unlock_on_empty_locked_user_passwd_freebsd", I think also the 1st of those should have password field of "::" rather than ":*:" (3rd freebsd also has ":*:"), and also missing "_format3_" id.23:44
minimalalso both netbsd tests have same id (no need for 3rd test with "::"?)23:46
minimalalso shouldn't the BSD tests be referring to /etc/master.passwd rather than /etc/shadow?23:54

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!