Skip to content

tests: improve passwd/group parsing tests#2045

Merged
imjasonh merged 1 commit intochainguard-dev:mainfrom
stevebeattie:apko-improve_passwd_group_tests
Jan 31, 2026
Merged

tests: improve passwd/group parsing tests#2045
imjasonh merged 1 commit intochainguard-dev:mainfrom
stevebeattie:apko-improve_passwd_group_tests

Conversation

@stevebeattie
Copy link
Member

The tests that are supposed to validate that existing passwd and group files are being parsed correctly didn't actually verify that any elements were successfully returned from the parse operation. This meant that an exploratory patch that converted apkofs.DirFS() to tarfs() looked like it succeeded but actually didn't.

Fix this by ensuring that the checked for entries are actually found and also expand the fields checked in the passwd and group dbs.

Doing this highlighted one particular behavior quirk that I'm not sure is intended: if the user member list in an /etc/group entry is empty, the group parsing function returns a string slice with one element containing an empty string i.e. []string{""} (length 1) and not an an empty slice []string{} (length 0). I'm not sure it matters in how the data structure is used, as the write methods generate byte-for-byte equivalents as demonstrated by the group TestWriter() test.

The tests that are supposed to validate that existing passwd and group
files are being parsed correctly didn't actually verify that any
elements were successfully returned from the parse operation. This meant
that an exploratory patch that converted apkofs.DirFS() to tarfs()
looked like it succeeded but actually didn't.

Fix this by ensuring that the checked for entries are actually found and
also expand the fields checked in the passwd and group dbs.

Signed-off-by: Steve Beattie <[email protected]>
@imjasonh imjasonh merged commit aee88fb into chainguard-dev:main Jan 31, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants