argo-cd icon indicating copy to clipboard operation
argo-cd copied to clipboard

fix: allow to use an entreprise GIthub instance and an authentication token in the same time again

Open foyerunix opened this issue 9 months ago • 5 comments

Hello,

This PR fix a regression introduced in https://github.com/argoproj/argo-cd/pull/21292. Before that, we were able to use both an URL and also an authentication token.

Best Regards.

foyerunix avatar May 23 '25 12:05 foyerunix

:x: Preview Environment undeployed from Bunnyshell

Available commands (reply to this comment):

  • :rocket: /bns:deploy to deploy the environment

bunnyshell[bot] avatar May 23 '25 12:05 bunnyshell[bot]

Should this be unit tested?

crenshaw-dev avatar May 23 '25 13:05 crenshaw-dev

Codecov Report

Attention: Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@0484f9f). Learn more about missing BASE report. Report is 27 commits behind head on master.

Files with missing lines Patch % Lines
applicationset/services/pull_request/github.go 72.72% 2 Missing and 1 partial :warning:
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #23129   +/-   ##
=========================================
  Coverage          ?   60.05%           
=========================================
  Files             ?      343           
  Lines             ?    57887           
  Branches          ?        0           
=========================================
  Hits              ?    34766           
  Misses            ?    20339           
  Partials          ?     2782           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 23 '25 13:05 codecov[bot]

Hello @crenshaw-dev,

I tried hard to implement an unit test without changing the definition of the NewGithubService function.

First I tried to check if the URL and the token were correctly set by inspecting the internals of the http.Client, but I couldn't correctly test for the token and it was brittle. Then I tried with a test HTTP server, but I couldn't make it work this way also.

Therefore I ended adding an optional http.Client argument to the NewGithubService function, this let me mock the Transport so I can inspect both the URL and the token.

Best Regards.

foyerunix avatar May 26 '25 07:05 foyerunix

I confirm this fixes the bug. The code looks good to me as well...

olivergondza avatar May 28 '25 07:05 olivergondza