New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command line to get passwd, group and shadow entries from local cache. #56
Conversation
This functions will be useful for the nss getent results and, this way, the privacy of the struct fields can be preserved.
There might some details missing, but the core is here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you missed some of the things we discussed yesterday, like tests needed for the next export API in shadow/group/passwd, some comments needed on the error handling in the function, having --help printing the usage, filtering invalid inputs, copy all test cases from our existing integration tests and add the "empty db" test case…). This was for all those reasons we discussed for you to take more time before submitting for review :)
I think the general approach is correct, but here are some suggestions for a more consistent API too and testing story. Let me know what you think!
Added tests for the new exported function String(), along with their golden files.
Still thinking about the some of the func names. Open for suggestions. Pls help!
Adding some more testcases and helpers in mock_test to increase our options when trying to test the formatter (might be overkill, but isn't hurting anyone).
Added a LOT of new test cases for TestGetEnt along with some refactoring.
Might still be missing a few test cases, but it's going well so far. A little unsure about the naming of some of them, specially about the "try" ones.
Codecov Report
@@ Coverage Diff @@
## main #56 +/- ##
==========================================
+ Coverage 75.04% 75.97% +0.93%
==========================================
Files 36 39 +3
Lines 2224 2435 +211
==========================================
+ Hits 1669 1850 +181
- Misses 492 524 +32
+ Partials 63 61 -2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still in draft, but you told me on MM that it’s ready now, so rereviewing.
Some small comments, but this is going in the right direction! I like it :)
The more annoying part is the wrong statuses returned on the "empty cache" and "no cache" tests. Do you mind having a look there? (I think you can start printing by what we return from the API).
nss/aad_auth/testdata/golden/TestGetEnt/try_to_list_group_with_empty_cache
Show resolved
Hide resolved
nss/aad_auth/testdata/golden/TestGetEnt/try_to_list_group_without_any_cache
Outdated
Show resolved
Hide resolved
nss/aad_auth/testdata/golden/TestGetEnt/try_to_list_passwd_without_permission_on_cache
Show resolved
Hide resolved
Also including the updated golden files with their status:errno updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still some fixes to do.
Btw, the QA linting tests is failing from the start, you should have a look there ;)
nss/aad_auth/testdata/golden/TestGetEnt/try_to_list_group_without_any_cache
Outdated
Show resolved
Hide resolved
nss/aad_auth/testdata/golden/TestGetEnt/try_to_list_group_with_empty_cache
Show resolved
Hide resolved
5a4375e
to
d6b7d48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All tests passes, no more comments. Excellent work!
Feel free to merge now :)
Interface
aad_auth <command> [args]
Command
getent <database> [key]
- key can be a name or id;
- If key is found the record corresponding to the key is returned;
- If key is not found no record is returned and the exit status is 0;
- If key is not specified then the entire database is listed;
Exit status
If everything goes right (no input parsing issues), the command always returns 0. We don't reflect the nss return status in the returned code.
Debug
Logs verbosity are controlled in getent by NSS_AAD_DEBUG.
Output
Output is printed on stdout, and has multiple lines. The first line is the nss_status_code and errno values. Following line is the elements printed by the request, separated by ':'
{nssStatus}:{errno}
<return value 1>
<return value 2>