mod/modregistry: treat "forbidden" as "not found"
When considering what repositories might contain a module, the module
resolution logic is careful to distinguish between a simple "not found"
error (discarded silently) and any other kind of error (triggers an
error in the whole module resolution process).
When a user has authenticated but does not have access to a given
module, the HTTP standard allows the server to return a 403 (Forbidden)
error to indicate that the user doesn't have permission to access a
page.
When considering possible candidates for modules, we don't want to fail
if there are some modules that exist that we can't access, so this CL
changes the logic to treat any 403 error the same as "not found" in this
respect.
We also make the error message when there is a permanent error
more specific so it actually mentions the module that it's trying to
resolve.
We also add tests for this and for token-server-based authentication,
verifying that with the OCI dependency updated as it is in this CL,
issue #2955 is actually fixed. The `registrytest` package API is changed
to allow this, because the previous `AuthHandler` function was not
sufficient to allow an independent token handler server listening on a
different port.
Fixes #2955.
Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I665b1aa28be255bb2e4a00bfc606b0899575fec1
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1191618
Reviewed-by: Rustam Abdullaev <rustam@cue.works>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>