Skip to content

Commit

Permalink
test: Update mock registry per @aduh95
Browse files Browse the repository at this point in the history
  • Loading branch information
Keysox committed Apr 24, 2024
1 parent c52f6cd commit 1dbe707
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/_registryServer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ const server = createServer((req, res) => {
const auth = req.headers.authorization;

if (
(auth?.startsWith(`Bearer `) && auth.slice(`Bearer `.length) !== TOKEN_MOCK) ||
(auth?.startsWith(`Basic `) && Buffer.from(auth.slice(`Basic `.length), `base64`).toString() !== `user:pass`)
auth == null ||
(auth.startsWith(`Bearer `) && auth.slice(`Bearer `.length) !== TOKEN_MOCK) ||
(auth.startsWith(`Basic `) && Buffer.from(auth.slice(`Basic `.length), `base64`).toString() !== `user:pass`) ||
!/^(Basic|Bearer) /.test(auth)
) {
res.writeHead(401).end(`Unauthorized`);
return;
Expand Down

0 comments on commit 1dbe707

Please sign in to comment.