Skip to content

Commit

Permalink
Merge pull request #27 from chrisgavin/case-sensitivity
Browse files Browse the repository at this point in the history
Fix an issue where upper-case letters in desired maintainers always cause a diff to be generated.
  • Loading branch information
chrisgavin authored Dec 5, 2023
2 parents d39f418 + 8deb564 commit 62f8827
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/entitlements/backend/github_team/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def diff_existing_updated_metadata(existing_group, group, base_diff)
end
end

existing_maintainers = existing_group.metadata_fetch_if_exists("team_maintainers")
changed_maintainers = group.metadata_fetch_if_exists("team_maintainers")
existing_maintainers = existing_group.metadata_fetch_if_exists("team_maintainers")&.downcase
changed_maintainers = group.metadata_fetch_if_exists("team_maintainers")&.downcase
if existing_maintainers != changed_maintainers
base_diff[:metadata] ||= {}
if existing_maintainers.nil? && !changed_maintainers.nil?
Expand Down
22 changes: 22 additions & 0 deletions spec/unit/entitlements/backend/github_team/provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,28 @@
metadata: { team_maintainers: "remove" }
)
end

it "diffs team maintainers no change" do
entitlements_group = Entitlements::Models::Group.new(
dn: "cn=diff-cats,ou=Github,dc=github,dc=fake",
members: Set.new(%w[cuddles fluffy morris WHISKERS].map { |u| "uid=#{u},ou=People,dc=kittens,dc=net" }),
metadata: { "team_maintainers" => "cuddles,Fluffy" }
)

github_team = Entitlements::Backend::GitHubTeam::Models::Team.new(
team_id: 2222,
team_name: "diff-cats",
members: Set.new(%w[cuddles fluffy morris WHISKERS].map { |u| "uid=#{u},ou=People,dc=kittens,dc=net" }),
ou: "ou=kittensinc,ou=GitHub,dc=github,dc=fake",
metadata: { "team_maintainers" => "cuddles,fluffy" }
)

result = subject.diff_existing_updated(entitlements_group, github_team)
expect(result).to eq(
added: Set.new,
removed: Set.new,
)
end
end

describe "#create_github_team_group" do
Expand Down

0 comments on commit 62f8827

Please sign in to comment.