Skip to content

Commit

Permalink
Merge branch 'main' into AzureDevopsDataSource
Browse files Browse the repository at this point in the history
  • Loading branch information
RDalziel authored Mar 3, 2025
2 parents d835726 + bc9fc2e commit 3f520f1
Show file tree
Hide file tree
Showing 84 changed files with 1,797 additions and 1,209 deletions.
4 changes: 2 additions & 2 deletions .github/actions/calculate-prefetch-matrix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ runs:
- name: Check cache miss for MacOS
id: macos-cache
uses: actions/cache/restore@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: node_modules
key: ${{ env.MACOS_KEY }}
Expand All @@ -43,7 +43,7 @@ runs:

- name: Check cache miss for Windows
id: windows-cache
uses: actions/cache/restore@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: node_modules
key: ${{ env.WINDOWS_KEY }}
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ runs:
- name: Restore `node_modules`
id: node-modules-restore
uses: actions/cache/restore@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: node_modules
key: ${{ env.CACHE_KEY }}
Expand Down Expand Up @@ -64,7 +64,7 @@ runs:
- name: Cache and restore `pnpm store`
if: env.CACHE_HIT != 'true'
uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ${{ env.PNPM_STORE }}
key: |
Expand All @@ -87,7 +87,7 @@ runs:

- name: Write `node_modules` cache
if: inputs.save-cache == 'true' && env.CACHE_HIT != 'true'
uses: actions/cache/save@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: node_modules
key: ${{ env.CACHE_KEY }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ jobs:
os: ${{ runner.os }}

- name: Restore eslint cache
uses: actions/cache/restore@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: .cache/eslint
key: eslint-main-cache
Expand All @@ -231,7 +231,7 @@ jobs:
- name: Save eslint cache
if: github.event_name == 'push'
uses: actions/cache/save@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: .cache/eslint
key: eslint-main-cache
Expand All @@ -258,7 +258,7 @@ jobs:
os: ${{ runner.os }}

- name: Restore prettier cache
uses: actions/cache/restore@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: .cache/prettier
key: prettier-main-cache
Expand All @@ -283,7 +283,7 @@ jobs:
- name: Save prettier cache
if: github.event_name == 'push'
uses: actions/cache/save@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: .cache/prettier
key: prettier-main-cache
Expand Down Expand Up @@ -379,7 +379,7 @@ jobs:
os: ${{ runner.os }}

- name: Cache vitest
uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: .cache/vitest
key: |
Expand Down Expand Up @@ -698,7 +698,7 @@ jobs:
show-progress: false

- name: docker-config
uses: containerbase/internal-tools@edd29e0d936f70cad03ec46ac65c35790d9866f2 # v3.10.5
uses: containerbase/internal-tools@e70c7ffc3ef2c42b9688277179d892c5173da6dd # v3.10.6
with:
command: docker-config

Expand Down
228 changes: 227 additions & 1 deletion lib/config/decrypt.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { logger } from '../../test/util';
import { decryptConfig } from './decrypt';
import {
decryptConfig,
getAzureCollection,
validateDecryptedValue,
} from './decrypt';
import { GlobalConfig } from './global';
import type { RenovateConfig } from './types';

Expand Down Expand Up @@ -53,4 +57,226 @@ describe('config/decrypt', () => {
);
});
});

describe('validateDecryptedValue()', () => {
beforeEach(() => {
GlobalConfig.reset();
});

describe('platforms non azure', () => {
it.each`
str | repo | expected
${'{"o":"abcd", "r":"", "v":"123#'} | ${'abcd/edf'} | ${null}
${'{"o":"abcd", "r":"", "v":""}'} | ${'abcd/edf'} | ${null}
${'{"o":"", "r":"", "v":"val"}'} | ${'abcd/edf'} | ${null}
${'{"o":"abcd", "r":"edf", "v":"val-1"}'} | ${'abcd/edf'} | ${'val-1'}
${'{"o":"abcd", "r":"", "v":"val-2"}'} | ${'abcd/edf'} | ${'val-2'}
${'{"o":"abcd/fgh", "r":"ef", "v":"val-3"}'} | ${'abcd/fgh/ef'} | ${'val-3'}
${'{"o":"abcd/fgh", "r":"", "v":"val-4"}'} | ${'abcd/fgh/ef'} | ${'val-4'}
${'{"o":"a/b/c/d", "r":"ef", "v":"val-5"}'} | ${'a/b/c/d/ef'} | ${'val-5'}
${'{"o":"abcd/fgh", "r":"any", "v":"val-6"}'} | ${'abcd/fgh/ef'} | ${null}
${'{"o":"abcd/xy", "r":"", "v":"val-7"}'} | ${'abcd/fgh/ef'} | ${null}
${'{"o":"xy", "r":"", "v":"val-8"}'} | ${'abcd/fgh/ef'} | ${null}
${'{"o":"xy, abcd/fgh", "r":"ef", "v":"val-9"}'} | ${'abcd/fgh/ef'} | ${'val-9'}
${'{"o":"xy ,abcd", "r":"ef", "v":"val-10"}'} | ${'abcd/ef'} | ${'val-10'}
${'{"o":"abcd, xy", "r":"", "v":"val-11"}'} | ${'abcd/fgh/ef'} | ${'val-11'}
${'{"o":"abcd,xy ", "r":"", "v":"val-12"}'} | ${'abcd/ef'} | ${'val-12'}
${'{"o":" xy,abc", "r":"", "v":"val-13"}'} | ${'abcd/fgh/ef'} | ${null}
`('equals("$str", "$repo") === $expected', ({ str, repo, expected }) => {
expect(validateDecryptedValue(str, repo)).toBe(expected);
});
});

describe('azure only platform', () => {
describe('general tests', () => {
it.each`
str | repo | expected
${'{"o":"any", "r":"", "v":"wrong-123#'} | ${'fgh/rp1'} | ${null}
${'{"o":"any", "r":"", "v":""}'} | ${'fgh/rp1'} | ${null}
${'{"o":"", "r":"", "v":"any"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"fgh", "r":"rp1", "v":"zv-1"}'} | ${'fgh/rp1'} | ${'zv-1'}
${'{"o":"fgh", "r":"", "v":"zv-2"}'} | ${'fgh/rp1'} | ${'zv-2'}
${'{"o":"az123/fgh", "r":"rp1", "v":"zv-3"}'} | ${'fgh/rp1'} | ${'zv-3'}
${'{"o":"az123/fgh", "r":"", "v":"zv-4"}'} | ${'fgh/rp1'} | ${'zv-4'}
${'{"o":"az123/*", "r":"", "v":"zv-5"}'} | ${'fgh/rp1'} | ${'zv-5'}
${'{"o":"az123/", "r":"", "v":"zv-6"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"az123", "r":"", "v":"zv-7"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"az1", "r":"", "v":"zv-8"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"az123/any", "r":"rp1", "v":"zv-9"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"az123/any", "r":"", "v":"zv-10"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"any/*", "r":"", "v":"zv-11"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"az123/*,any/*", "r":"", "v":"zv-12"}'} | ${'fgh/rp1'} | ${'zv-12'}
${'{"o":"fgh,any/*", "r":"", "v":"zv-13"}'} | ${'fgh/rp1'} | ${'zv-13'}
${'{"o":"az123/,any/*", "r":"", "v":"zv-14"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"any/*,fgh/", "r":"", "v":"zv-15"}'} | ${'fgh/rp1'} | ${'zv-15'}
${'{"o":"any/*,az123", "r":"", "v":"zv-16"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"any/*,az12", "r":"", "v":"zv-17"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"az12,any/*", "r":"", "v":"zv-18"}'} | ${'fgh/rp1'} | ${null}
`(
'equals("$str", "$repo") === $expected',
({ str, repo, expected }) => {
GlobalConfig.set({
platform: 'azure',
endpoint: 'https://dev.azure.com/az123',
});
expect(validateDecryptedValue(str, repo)).toBe(expected);
},
);
});

describe('tests self hosted - ignore "tfs/" before collection name', () => {
it.each`
str | repo | expected
${'{"o":"any", "r":"", "v":"wrong-123#'} | ${'fgh/rp1'} | ${null}
${'{"o":"any", "r":"", "v":""}'} | ${'fgh/rp1'} | ${null}
${'{"o":"", "r":"", "v":"any"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"fgh", "r":"rp1", "v":"zv-1"}'} | ${'fgh/rp1'} | ${'zv-1'}
${'{"o":"fgh", "r":"", "v":"zv-2"}'} | ${'fgh/rp1'} | ${'zv-2'}
${'{"o":"az123/fgh", "r":"rp1", "v":"zv-3"}'} | ${'fgh/rp1'} | ${'zv-3'}
${'{"o":"az123/fgh", "r":"", "v":"zv-4"}'} | ${'fgh/rp1'} | ${'zv-4'}
${'{"o":"az123/*", "r":"", "v":"zv-5"}'} | ${'fgh/rp1'} | ${'zv-5'}
${'{"o":"az123/", "r":"", "v":"zv-6"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"az123", "r":"", "v":"zv-7"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"az1", "r":"", "v":"zv-8"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"az123/any", "r":"rp1", "v":"zv-9"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"az123/any", "r":"", "v":"zv-10"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"any/*", "r":"", "v":"zv-11"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"az123/*,any/*", "r":"", "v":"zv-12"}'} | ${'fgh/rp1'} | ${'zv-12'}
${'{"o":"fgh,any/*", "r":"", "v":"zv-13"}'} | ${'fgh/rp1'} | ${'zv-13'}
${'{"o":"az123/,any/*", "r":"", "v":"zv-14"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"any/*,fgh/", "r":"", "v":"zv-15"}'} | ${'fgh/rp1'} | ${'zv-15'}
${'{"o":"any/*,az123", "r":"", "v":"zv-16"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"any/*,az12", "r":"", "v":"zv-17"}'} | ${'fgh/rp1'} | ${null}
${'{"o":"az12,any/*", "r":"", "v":"zv-18"}'} | ${'fgh/rp1'} | ${null}
`(
'equals("$str", "$repo") === $expected',
({ str, repo, expected }) => {
GlobalConfig.set({
platform: 'azure',
endpoint: 'http://your-server-name:8080/tfs/az123',
});
expect(validateDecryptedValue(str, repo)).toBe(expected);
},
);
});

it('endpoint URL invalid', () => {
GlobalConfig.set({
platform: 'azure',
endpoint: 'ht tps://dev.az ure.com/az123',
});
expect(
validateDecryptedValue(
'{"o":"proj", "r":"repo", "v":"any-1"}',
'proj/repo',
),
).toBe('any-1');
expect(
validateDecryptedValue(
'{"o":"proj", "r":"", "v":"any-2"}',
'proj/repo',
),
).toBe('any-2');

expect(
validateDecryptedValue(
'{"o":"col/proj", "r":"", "v":"any"}',
'proj/repo',
),
).toBeNull();
expect(
validateDecryptedValue(
'{"o":"col/*", "r":"", "v":"any"}',
'proj/repo',
),
).toBeNull();
});

it('endpoint URL without collection', () => {
GlobalConfig.set({
platform: 'azure',
endpoint: 'https://dev.azure.com/',
});
expect(
validateDecryptedValue(
'{"o":"proj", "r":"repo", "v":"any-3"}',
'proj/repo',
),
).toBe('any-3');
expect(
validateDecryptedValue(
'{"o":"proj", "r":"", "v":"any-4"}',
'proj/repo',
),
).toBe('any-4');

expect(
validateDecryptedValue(
'{"o":"col/proj", "r":"", "v":"any"}',
'proj/repo',
),
).toBeNull();
expect(
validateDecryptedValue(
'{"o":"col/*", "r":"", "v":"any"}',
'proj/repo',
),
).toBeNull();
});
});
});

describe('getAzureCollection()', () => {
beforeEach(() => {
GlobalConfig.reset();
});

it('no pathname and url ends with slash', () => {
GlobalConfig.set({
platform: 'azure',
endpoint: 'https://dev.azure.com/',
});
expect(getAzureCollection()).toBeUndefined();
});

it('no pathname and no slash at end of URL', () => {
GlobalConfig.set({
platform: 'azure',
endpoint: 'https://dev.azure.com',
});
expect(getAzureCollection()).toBeUndefined();
});

it('pathname no slash at end', () => {
GlobalConfig.set({
platform: 'azure',
endpoint: 'https://dev.azure.com/aaa',
});
expect(getAzureCollection()).toBe('aaa');
});

it('pathname with slash at end', () => {
GlobalConfig.set({
platform: 'azure',
endpoint: 'https://dev.azure.com/aaa/',
});
expect(getAzureCollection()).toBe('aaa');
});

it('pathname 2 levels no slash at end', () => {
GlobalConfig.set({
platform: 'azure',
endpoint: 'https://dev.azure.com/aaa/bbb',
});
expect(getAzureCollection()).toBe('aaa/bbb');
});

it('pathname 2 levels with slash at end', () => {
GlobalConfig.set({
platform: 'azure',
endpoint: 'https://dev.azure.com/aaa/bbb/',
});
expect(getAzureCollection()).toBe('aaa/bbb');
});
});
});
Loading

0 comments on commit 3f520f1

Please sign in to comment.