Fix regressions in connecting to GitLab.

Review Request #11646 — Created June 3, 2021 and submitted

Information

Review Board
release-4.0.x

Reviewers

The GitLab implementation had a couple places where we made wrong
assumptions about header types. This wasn't an issue on Review Board 3,
but on 4 we're more strict about types, and this resulted in some errors
when trying to determine the API version.

The API token was being turned into a byte string before being put into
a header. This was the correct type on Python 2, but not on Python 3.
The type checking caught this, but we didn't have unit tests that ran
through this code.

The logic being used here was redundant anyway.

We now set the header using a Unicode string (which is what our HTTP
requests now expect), and we use _get_private_token() to decrypt the
token instead of duplicating logic. On top of this, our processing of
the Link header for pagination now looks up and converts native
strings instead of assuming Unicode strings.

Reproduced the issue in bug #4928 in tests and verified the fix on
Python 2 and 3.

Summary ID
Fix regressions in connecting to GitLab.
The GitLab implementation had a couple places where we made wrong assumptions about header types. This wasn't an issue on Review Board 3, but on 4 we're more strict about types, and this resulted in some errors when trying to determine the API version. The API token was being turned into a byte string before being put into a header. This was the correct type on Python 2, but not on Python 3. The type checking caught this, but we didn't have unit tests that ran through this code. The logic being used here was redundant anyway. We now set the header using a Unicode string (which is what our HTTP requests now expect), and we use `_get_private_token()` to decrypt the token instead of duplicating logic. On top of this, our processing of the `Link` header for pagination now looks up and converts native strings instead of assuming Unicode strings.
5a8fd23257a3385b4486b8c5ab98f7e6ab9ba81c
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-4.0.x (726de36)