Repository navigation
Bug Fix: GitHub Usernames are Case Insensitive - #241
Conversation
| `, testCollaborator) | ||
|
|
||
| func testAccGithubMembershipConfig_caseInsensitive() string { | ||
| otherCase := []rune(testCollaborator) |
There was a problem hiding this comment.
If I get the intent right, you are modifying the collaborator username, by toggling the case of the first rune, to test case insensitivity functionality. Is that correct? If so what about changing the function signature to take in an input, and just pass the collaborator name with the expected case.
func testAccGithubMembershipConfig_caseInsensitive(memberName string) {
return fmt.Sprintf(`
resource "github_membership" "test_org_membership" {
username = "%s"
role = "member"
}
`, memberName)
}This way in the acceptance test you can run two TestSteps:
Steps: []resource.TestStep{
{
Config: testAccGithubMembershipConfig_caseInsensitive(strings.ToUpper(testCollaborator)),
Check: resource.ComposeTestCheckFunc(
testAccCheckGithubMembershipExists("github_membership.test_org_membership", &membership),
),
},
{
Config: testAccGithubMembershipConfig_caseInsensitive(strings.ToLower(testCollaborator)),
Check: resource.ComposeTestCheckFunc(
testAccCheckGithubMembershipExists("github_membership.test_org_membership", &membership),
),
},
},
nywilken
left a comment
There was a problem hiding this comment.
@megan07 I left a few comments for you, but this is otherwise good.
--- PASS: TestAccGithubMembership_basic (3.30s)
--- PASS: TestAccGithubMembership_caseInsensitive (2.84s)
--- PASS: TestAccGithubMembership_importBasic (2.79s)
--- PASS: TestAccGithubRepositoryCollaborator_basic (9.65s)
--- PASS: TestAccGithubRepositoryCollaborator_importBasic (9.17s)
paultyng
left a comment
There was a problem hiding this comment.
Some minor comments, but otherwise LGTM
|
|
||
| func TestAccGithubMembership_basic(t *testing.T) { | ||
| if testCollaborator == "" { | ||
| t.Skip("Skipping because length of `GITHUB_TEST_COLLABORATOR` is not set") |
There was a problem hiding this comment.
think this is a copy/paste typo for the message
|
|
||
| func testAccGithubMembershipTheSame(orig, other *github.Membership) resource.TestCheckFunc { | ||
| return func(s *terraform.State) error { | ||
| if *orig.URL != *other.URL { |
There was a problem hiding this comment.
should this also test to make sure at least one isn't null/empty? or should two empties be equal?
There was a problem hiding this comment.
I think, for the intent of the test, two empties would be equal. I can't think of a time when this would be empty here, but if they were to both be empty, I think it means the case change didn't have an effect.
| var otherMembership github.Membership | ||
|
|
||
| oc := []rune(testCollaborator) | ||
| if unicode.IsUpper(oc[0]) { |
There was a problem hiding this comment.
not sure if its possible, but could 0 ever be a number or symbol in a username?
|
I'm still seeing this: |
|
I'm still seeing this as well. Not sure if there is a regression. An example (a bit redacted). Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# github_team_members.drupal_fe will be updated in-place
~ resource "github_team_members" "drupal_fe" {
# (2 unchanged attributes hidden)
- members {
- role = "maintainer" -> null
- username = "username" -> null
}
+ members {
+ role = "maintainer"
+ username = "UserName"
}
# (3 unchanged blocks hidden)
}
# github_team_members.org_admin will be updated in-place
~ resource "github_team_members" "org_admin" {
# (2 unchanged attributes hidden)
- members {
- role = "maintainer" -> null
- username = "username" -> null
}
+ members {
+ role = "maintainer"
+ username = "UserName"
}
# (4 unchanged blocks hidden)
}
# github_team_members.org_devops will be updated in-place
~ resource "github_team_members" "org_devops" {
# (2 unchanged attributes hidden)
- members {
- role = "maintainer" -> null
- username = "username" -> null
}
+ members {
+ role = "maintainer"
+ username = "UserName"
}
# (1 unchanged block hidden)
}
# github_team_members.org_eng will be updated in-place
~ resource "github_team_members" "org_eng" {
# (2 unchanged attributes hidden)
- members {
- role = "maintainer" -> null
- username = "username" -> null
}
+ members {
+ role = "maintainer"
+ username = "UserName"
}
# (6 unchanged blocks hidden)
}
Plan: 0 to add, 4 to change, 0 to destroy. |
Addressing #196 where GitHub usernames were being treated as case-sensitive in the diff.
Before fix:
After fix:
I also tested that if the user DOES update the casing in the GitHub UI, a terraform refresh will pick that up.