Skip to content
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

[Fix] Fix issue with case sensitive group names in databricks_group resource #3597

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Joe-Koch
Copy link

@Joe-Koch Joe-Koch commented May 21, 2024

Changes

Databricks enforces uniqueness of group names with case sensitivity, so groups like "Admins" and "admins" can exist in the same workspace. When you filter for Databricks groups matching a name with the SCIM API, the name match is not case-sensitive, and it might return multiple groups. The current code just grabs the first group from the results when multiple groups are returned. With this code change, if the length of the returned group list is greater than 1, it loops through the returned groups and searches for a match on DisplayName.

Tests

Added a test in groups_test.go to check that when there's a lower-case "name" group and an upper-case "Name" group, ReadByDisplayName will return the right one.

  • make test run locally
  • relevant change in docs/ folder
  • covered with integration tests in internal/acceptance
  • relevant acceptance tests are passing
  • using Go SDK

- Updated ReadByDisplayName function to ensure exact case-sensitive matching of group display names.
- This addresses the issue where groups with similar names but different cases were not correctly distinguished.
@Joe-Koch Joe-Koch requested review from a team as code owners May 21, 2024 01:17
@Joe-Koch Joe-Koch requested review from tanmay-db and removed request for a team May 21, 2024 01:17
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 87.50000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 82.34%. Comparing base (93f131c) to head (f708760).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3597   +/-   ##
=======================================
  Coverage   82.34%   82.34%           
=======================================
  Files         190      190           
  Lines       19323    19330    +7     
=======================================
+ Hits        15911    15918    +7     
- Misses       2480     2481    +1     
+ Partials      932      931    -1     
Files Coverage Δ
scim/groups.go 91.80% <87.50%> (-2.65%) ⬇️

... and 1 file with indirect coverage changes

@Joe-Koch
Copy link
Author

@tanmay-db Is there anything else needed to get this approved? Thank you

@tanmay-db
Copy link
Contributor

Hi @Joe-Koch, thanks for the PR. I will take a look and reach back to you.

@alexott alexott changed the title Fix issue #3596, issue with case sensitive group names in databricks_group resource [Fix] Fix issue with case sensitive group names in databricks_group resource Aug 9, 2024
@@ -59,7 +59,18 @@ func (a GroupsAPI) ReadByDisplayName(displayName, attributes string) (group Grou
err = fmt.Errorf("cannot find group: %s", displayName)
return
}
group = groupList.Resources[0]
if len(groupList.Resources) == 1 {
group = groupList.Resources[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we enforce case-sensitive names here as well?

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.

4 participants