Skip to content

fix(check-update): remove auth for check-update

Jay McCure requested to merge jmc-no-auth-update into main

Description

Checking for glab updates involves a /releases request to gitlab.com to a public project and does not require authentication. Currently glab sends the access token anyway, so when the access token is invalid the request will fail.

This is not good for our self-managed users which may have GITLAB_TOKEN set to a token for their self-managed instance, which yields a 401 if sent along with the request to check for the latest glab release.

With this MR we always send an empty token to check for glab releases which will always succeed.

Even though the change and additional assertion is small, I also had to refactor the test file to use stretchr/testify/assert & cli/pkg/httpmock as I needed to check the outgoing auth header in the test. See !1334 (comment 1552286543).

The bug fix and the test refactor are in seperate commits to make it easier to review.

Related Issues

Resolves #3703 (closed)

How has this been tested?

Added additional assertion to ensure no token is passed.

Manually checked that the following commands successfully check for a glab update:

glab check-update #with valid token in config
glab check-update #with no token in config
GITLAB_TOKEN=foo glab check-update #with invalid gitlab.com token
glab mr list # when check_update=true in ~/.config/glab-cli/config.yml

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation
  • Chore (Related to CI or Packaging to platforms)
  • Test gap
Edited by Jay McCure

Merge request reports