mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-01 10:09:50 +00:00
4f55ef29cf
`hostRules.find()` only lets a rule through when the rule has no `hostType` or its `hostType` equals the one being searched for. A search that passes only a `url` therefore silently ignores every `hostType`-scoped rule, even one whose `matchHost` matches exactly. Behaviour changes - `hostType`-scoped host rules now apply at these sites: - `mix`: a `hostType: 'hex'` rule for an organization repo URL is now used to authenticate against that organization. - `pre-commit`: the pre-check that returned `unknown-registry` before the `hostType`-scoped loop is dropped, so a `hostType`-only forgejo, github or gitlab rule now resolves the datasource instead of being skipped. - `util/http/github.ts`: the rate-limit warning now sees the rule `GITHUB_COM_TOKEN` registers (`hostType: 'github'`), so it reports "even though we are authenticated" rather than asking for that token. - `util/http` rate limits: `concurrentRequestLimit` and `maxRequestsPerSecond` are read with the `hostType` of the `Http` instance making the request. The queue and throttle maps stay keyed by host alone, because concurrency is a property of the remote server. The unscoped find in `pip-compile` is replaced separately, together with the other Python index credential lookups.
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import * as hostRules from '../host-rules.ts';
|
|
import { clear, getQueue } from './queue.ts';
|
|
|
|
describe('util/http/queue', () => {
|
|
beforeEach(() => {
|
|
clear();
|
|
hostRules.clear();
|
|
hostRules.add({
|
|
matchHost: 'example.com',
|
|
concurrentRequestLimit: 143,
|
|
});
|
|
});
|
|
|
|
it('returns null for invalid URL', () => {
|
|
expect(getQueue('$#@!')).toBeNull();
|
|
});
|
|
|
|
it('returns queue for valid url', () => {
|
|
const q1a = getQueue('https://example.com');
|
|
const q1b = getQueue('https://example.com');
|
|
|
|
const q2a = getQueue('https://example.com:8080');
|
|
const q2b = getQueue('https://example.com:8080');
|
|
|
|
expect(q1a).not.toBeNull();
|
|
expect(q1a).toBe(q1b);
|
|
|
|
expect(q2a).not.toBeNull();
|
|
expect(q2a).toBe(q2b);
|
|
|
|
expect(q1a).not.toBe(q2a);
|
|
expect(q1a).not.toBe(q2b);
|
|
expect(q1b).not.toBe(q2a);
|
|
expect(q1b).not.toBe(q2b);
|
|
});
|
|
|
|
it('reads the limit from a hostType-scoped rule', () => {
|
|
hostRules.clear();
|
|
hostRules.add({
|
|
hostType: 'npm',
|
|
matchHost: 'example.com',
|
|
concurrentRequestLimit: 143,
|
|
});
|
|
|
|
expect(getQueue('https://example.com')).toBeNull();
|
|
|
|
clear();
|
|
expect(getQueue('https://example.com', 'npm')).not.toBeNull();
|
|
});
|
|
});
|