-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Connect: Fetch correct role set when listing db users #13790
Conversation
#12281 fixed fetching db users for remote clusters for `tsh db ls`. #13617 applied the same fix to `tsh db ls --all` and extracted the `fetchRoleSet` function. This commit extracts it to `lib/client` so that we can reuse it in `lib/teleterm`. Other than accepting `log` as an argument, nothing was changed about that function.
@codingllama I moved the function to lib/services and added some tests, let me know what you think. |
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.
Thanks for the new tests, @ravicious. It looks good.
} | ||
|
||
func TestFetchAllClusterRoles_UsesDefaultRolesAndTraitsIfCurrentUserIsUnavailable(t *testing.T) { |
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.
Let's combine those 2 test cases in a single table-driven test, so we take advantage of their common setup.
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.
Is it fine if I leave them as separate tests for now? IMHO updating something that was repeated just once doesn't require that much work vs untangling the code in case we need to add a third case that's just slightly different than the other two.
Co-authored-by: Alan Parra <[email protected]>
Co-authored-by: Alan Parra <[email protected]>
Co-authored-by: Alan Parra <[email protected]>
@ravicious See the table below for backport results.
|
* Move fetchRoleSet from tsh/db to lib/services as FetchAllClusterRoles. * Connect: Fetch correct role set when listing db users * Add tests for FetchAllClusterRoles
Fixes gravitational/webapps.e#290.
#12281 fixed fetching db users for remote clusters for
tsh db ls
. #13617 applied the same fix totsh db ls --all
and extracted thefetchRoleSet
function.This PR extracts that function to
lib/client
so that we can reuse itlib/teleterm
. Other than acceptinglog
as an argument, nothing was changed about that function.In Connect we basically needed to apply the same fix that was applied in #12281 to
tool/tsh/db.go
. As mentioned above, that whole section of code was extracted intofetchRoleSet
in #13617.