fluxcd / go-git-providers

Git provider client for Go
https://fluxcd.io
Apache License 2.0
72 stars 34 forks source link

Make GitHub username comparisons case-insensitive. #293

Open TonyLovesDevOps opened 1 month ago

TonyLovesDevOps commented 1 month ago

This fixes the issue where setting GITHUB_USER to the same characters in a different case, causes the spurious error: the specified owner <username> doesn't match the identity associated with the given token.

Description

Does what it says on the tin.

Test results

I'm seeing a test failure for [Fail] GitHub Provider [It] should list the available organizations the user has access to, possibly because I am not a member of any organizations that I did not create. This same test fails on the tip of the main branch.

$ make test-e2e-github
go mod tidy -compat=1.22
go fmt ./...
go vet ./...
go test  -race -coverprofile=coverage.txt -covermode=atomic -tags=e2e ./github/...
Running Suite: GitHub Provider Suite
====================================
Random Seed: 1727210907
Will run 12 of 12 specs

•
------------------------------
• Failure [0.469 seconds]
GitHub Provider
/Users/tony/git/go-git-providers/github/integration_test.go:131
  should list the available organizations the user has access to [It]
  /Users/tony/git/go-git-providers/github/integration_test.go:212

  Expected
      <*string | 0x0>: nil
  not to be nil

  /Users/tony/git/go-git-providers/github/integration_test.go:240
------------------------------
•••••••
------------------------------
• [SLOW TEST:12.342 seconds]
GitHub Provider
/Users/tony/git/go-git-providers/github/integration_test.go:131
  should be possible to create and edit a pr for a user repository
  /Users/tony/git/go-git-providers/github/integration_test.go:450
------------------------------
••

Summarizing 1 Failure:

[Fail] GitHub Provider [It] should list the available organizations the user has access to
/Users/tony/git/go-git-providers/github/integration_test.go:240

Ran 12 of 12 Specs in 24.767 seconds
FAIL! -- 11 Passed | 1 Failed | 0 Pending | 0 Skipped
--- FAIL: TestProvider (24.78s)
FAIL
coverage: 55.0% of statements
FAIL    github.com/fluxcd/go-git-providers/github       26.497s
FAIL
make: *** [test-e2e-github] Error 1