Wizard: Add filtering to repositories

This commit adds filtering based on architecture and version to the
repositories table in the wizard.

Apart from filtering, this commit now shows *all* repositories,
regardless of their status. Previously, invalid repositories were not
displayed. A future PR will add a status column and edge case handling
(how to handle an invalid repo, etc...). For now, invalid repos are
displayed and can be selected.

RTK Query is now used to manage the state of the repositories.
Previously, the repositories were fetched in a useEffect hook upon
opening the wizard.

MSW is now used instead of jest mocking for the tests involving
repositories. The repositories test fixture now contains a function that
mimics the content sources API.
This commit is contained in:
lucasgarfield 2023-05-02 18:27:50 +02:00 committed by Lucas Garfield
parent ff8c275013
commit 383f2a6855
11 changed files with 682 additions and 715 deletions

View file

@ -4,9 +4,7 @@ import { screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { rest } from 'msw';
import api from '../../../api.js';
import { PROVISIONING_SOURCES_ENDPOINT } from '../../../constants.js';
import { mockRepositoryResults } from '../../fixtures/repositories';
import { server } from '../../mocks/server.js';
import { renderWithReduxRouter } from '../../testUtils';
@ -48,10 +46,6 @@ describe('Step Upload to Azure', () => {
beforeAll(() => {
// scrollTo is not defined in jsdom
window.HTMLElement.prototype.scrollTo = function () {};
jest
.spyOn(api, 'getRepositories')
.mockImplementation(() => Promise.resolve(mockRepositoryResults));
});
afterEach(() => {

View file

@ -16,7 +16,6 @@ import {
RHEL_9,
PROVISIONING_SOURCES_ENDPOINT,
} from '../../../constants.js';
import { mockRepositoryResults } from '../../fixtures/repositories';
import { server } from '../../mocks/server.js';
import { renderWithReduxRouter } from '../../testUtils';
@ -85,72 +84,6 @@ const mockPkgResultAlphaContentSources = [
},
];
const mockRepositoryResponsePartial = {
data: new Array(100).fill().map((_, i) => {
return {
uuid: '9cf1d45d-aa06-46fe-87ea-121845cc6bbb',
name: '2lmdtj',
url:
'http://mirror.stream.centos.org/SIGs/9/kmods/x86_64/packages-main/' +
i,
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:12.714873 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:12.714873 +0000 UTC',
last_update_introspection_time: '2022-11-18 08:00:10.119093 +0000 UTC',
last_introspection_error: '',
package_count: 21,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
};
}),
meta: {
limit: 100,
offset: 0,
count: 132,
},
links: {
first: '/api/content-sources/v1/repositories/?limit=100&offset=0',
last: '/api/content-sources/v1/repositories/?limit=100&offset=0',
},
};
const mockRepositoryResponseAll = {
data: new Array(132).fill().map((_, i) => {
return {
uuid: '9cf1d45d-aa06-46fe-87ea-121845cc6bbb',
name: '2lmdtj',
url:
'http://mirror.stream.centos.org/SIGs/9/kmods/x86_64/packages-main/' +
i,
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:12.714873 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:12.714873 +0000 UTC',
last_update_introspection_time: '2022-11-18 08:00:10.119093 +0000 UTC',
last_introspection_error: '',
package_count: 21,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
};
}),
meta: {
limit: 132,
offset: 0,
count: 132,
},
links: {
first: '/api/content-sources/v1/repositories/?limit=132&offset=0',
last: '/api/content-sources/v1/repositories/?limit=132&offset=0',
},
};
const searchForAvailablePackages = async (searchbox, searchTerm) => {
const user = userEvent.setup();
await user.type(searchbox, searchTerm);
@ -633,43 +566,14 @@ describe('Step Custom repositories', () => {
getNextButton().click();
};
test('show only valid (successful) repositories', async () => {
jest
.spyOn(api, 'getRepositories')
.mockImplementation(() => Promise.resolve(mockRepositoryResults));
await setUp();
// Display all repositories on one page
screen.getByRole('button', { name: /items per page/i }).click();
screen.getByRole('menuitem', { name: /100 per page/i }).click();
// gnome-shell-extensions should not be present
const table = await screen.findByTestId('repositories-table');
const { getAllByRole } = within(table);
const rows = getAllByRole('row');
// remove first row from list since it is just header labels
rows.shift();
// mockRepositoryResults has 21 repositories, gnome-shell-extensions status is
// 'Invalid' and it should not appear in table
expect(rows).toHaveLength(20);
expect(table).not.toHaveTextContent('gnome-shell-extensions');
});
test('selected packages stored in and retrieved from form state', async () => {
jest
.spyOn(api, 'getRepositories')
.mockImplementation(() => Promise.resolve(mockRepositoryResults));
test('selected repositories stored in and retrieved from form state', async () => {
await setUp();
const getFirstRepoCheckbox = () =>
screen.getByRole('checkbox', {
screen.findByRole('checkbox', {
name: /select row 0/i,
});
let firstRepoCheckbox = getFirstRepoCheckbox();
let firstRepoCheckbox = await getFirstRepoCheckbox();
expect(firstRepoCheckbox.checked).toEqual(false);
await user.click(firstRepoCheckbox);
@ -678,39 +582,29 @@ describe('Step Custom repositories', () => {
getNextButton().click();
getBackButton().click();
firstRepoCheckbox = getFirstRepoCheckbox();
firstRepoCheckbox = await getFirstRepoCheckbox();
expect(firstRepoCheckbox.checked).toEqual(true);
});
test('all repositories are fetched when number of repositories is greater than API limit', async () => {
jest.spyOn(api, 'getRepositories').mockImplementation((limit) => {
return limit
? Promise.resolve(mockRepositoryResponseAll)
: Promise.resolve(mockRepositoryResponsePartial);
});
test('correct number of repositories is fetched', async () => {
await setUp();
screen
.getByRole('button', {
name: /select/i,
})
.click();
screen.getByText(/select all \(132 items\)/i);
const selectButton = await screen.findByRole('button', {
name: /select/i,
});
await user.click(selectButton);
screen.getByText(/select all \(1011 items\)/i);
});
test('filter works', async () => {
jest
.spyOn(api, 'getRepositories')
.mockImplementation(() => Promise.resolve(mockRepositoryResults));
await setUp();
await user.type(
screen.getByRole('textbox', { name: /search repositories/i }),
'2'
await screen.findByRole('textbox', { name: /search repositories/i }),
'2zmya'
);
// gnome-shell-extensions is invalid and should not be present
const table = await screen.findByTestId('repositories-table');
const { getAllByRole } = within(table);
const getRows = () => getAllByRole('row');
@ -719,7 +613,7 @@ describe('Step Custom repositories', () => {
// remove first row from list since it is just header labels
rows.shift();
expect(rows).toHaveLength(4);
expect(rows).toHaveLength(1);
// clear filter
screen.getByRole('button', { name: /reset/i }).click();
@ -735,10 +629,6 @@ describe('Step Custom repositories', () => {
describe('Click through all steps', () => {
const user = userEvent.setup();
jest
.spyOn(api, 'getRepositories')
.mockImplementation(() => Promise.resolve(mockRepositoryResults));
const setUp = async () => {
({ router, store } = renderWithReduxRouter('imagewizard', {}));
};
@ -852,8 +742,12 @@ describe('Click through all steps', () => {
getNextButton().click();
// Custom repositories
await user.click(screen.getByRole('checkbox', { name: /select row 0/i }));
await user.click(screen.getByRole('checkbox', { name: /select row 1/i }));
await user.click(
await screen.findByRole('checkbox', { name: /select row 0/i })
);
await user.click(
await screen.findByRole('checkbox', { name: /select row 1/i })
);
getNextButton().click();
// Custom packages
@ -924,7 +818,7 @@ describe('Click through all steps', () => {
},
{
baseurl: [
'http://mirror.stream.centos.org/SIGs/9/kmods/x86_64/packages-main/',
'http://mirror.stream.centos.org/SIGs/8/kmods/x86_64/packages-main/',
],
id: '9cf1d45d-aa06-46fe-87ea-121845cc6bbb',
name: '2lmdtj',
@ -941,7 +835,7 @@ describe('Click through all steps', () => {
},
{
baseurl:
'http://mirror.stream.centos.org/SIGs/9/kmods/x86_64/packages-main/',
'http://mirror.stream.centos.org/SIGs/8/kmods/x86_64/packages-main/',
rhsm: false,
},
],
@ -1091,7 +985,7 @@ describe('Click through all steps', () => {
});
const create = screen.getByRole('button', { name: /Create/ });
create.click();
await user.click(create);
// API request sent to backend
expect(composeImage).toHaveBeenCalledTimes(6);

View file

@ -1,27 +1,424 @@
export const mockRepositoryResults = {
data: [
{
uuid: 'dbad4dfc-1547-45f8-b5af-1d7fec0476c6',
name: '13lk3',
url: 'http://yum.theforeman.org/releases/3.4/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:54:00.962352 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:54:00.962352 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:12.123607 +0000 UTC',
last_introspection_error: '',
package_count: 605,
status: 'Valid',
gpg_key:
'-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBGN9300BEAC1FLODu0cL6saMMHa7yJY1JZUc+jQUI/HdECQrrsTaPXlcc7nM\nykYMMv6amPqbnhH/R5BW2Ano+OMse+PXtUr0NXU4OcvxbnnXkrVBVUf8mXI9DzLZ\njw8KoD+4/s0BuzO78zAJF5uhuyHMAK0ll9v0r92kK45Fas9iZTfRFcqFAzvgjScf\n5jeBnbRs5U3UTz9mtDy802mk357o1A8BD0qlu3kANDpjLbORGWdAj21A6sMJDYXy\nHS9FBNV54daNcr+weky2L9gaF2yFjeu2rSEHCSfkbWfpSiVUx/bDTj7XS6XDOuJT\nJqvGS8jHqjHAIFBirhCA4cY/jLKxWyMr5N6IbXpPAYgt8/YYz2aOYVvdyB8tZ1u1\nkVsMYSGcvTBexZCn1cDkbO6I+waIlsc0uxGqUGBKF83AVYCQqOkBjF1uNnu9qefE\nkEc9obr4JZsAgnisboU25ss5ZJddKlmFMKSi66g4S5ChLEPFq7MB06PhLFioaD3L\nEXza7XitoW5VBwr0BSVKAHMC0T2xbm70zY06a6gQRlvr9a10lPmv4Tptc7xgQReg\nu1TlFPbrkGJ0d8O6vHQRAd3zdsNaVr4gX0Tg7UYiqT9ZUkP7hOc8PYXQ28hHrHTB\nA63MTq0aiPlJ/ivTuX8M6+Bi25dIV6N6IOUi/NQKIYxgovJCDSdCAAM0fQARAQAB\ntCFMdWNhcyBHYXJmaWVsZCA8bHVjYXNAcmVkaGF0LmNvbT6JAlcEEwEIAEEWIQTO\nQZeiHnXqdjmfUURc6PeuecS2PAUCY33fTQIbAwUJA8JnAAULCQgHAgIiAgYVCgkI\nCwIEFgIDAQIeBwIXgAAKCRBc6PeuecS2PCk3D/9jW7xrBB/2MQFKd5l+mNMFyKwc\nL9M/M5RFI9GaQRo55CwnPb0nnxOJR1V5GzZ/YGii53H2ose65CfBOE2L/F/RvKF0\nH9S9MInixlahzzKtV3TpDoZGk5oZIHEMuPmPS4XaHggolrzExY0ib0mQuBBE/uEV\n/HlyHEunBKPhTkAe+6Q+2dl22SUuVfWr4Uzlp65+DkdN3M37WI1a3Suhnef3rOSM\nV6puUzWRR7qcYs5C2In87AcYPn92P5ur1y/C32r8Ftg3fRWnEzI9QfRG52ojNOLK\nyGQ8ZC9PGe0q7VFcF7ridT/uzRU+NVKldbJg+rvBnszb1MjNuR7rUQHyvGmbsUVQ\nRCsgdovkee3lP4gfZHzk2SSLVSo0+NJRNaM90EmPk14Pgi/yfRSDGBVvLBbEanYI\nv1ZtdIPRyKi+/IaMOu/l7nayM/8RzghdU+0f1FAif5qf9nXuI13P8fqcqfu67gNd\nkh0UUF1XyR5UHHEZQQDqCuKEkZJ/+27jYlsG1ZiLb1odlIWoR44RP6k5OJl0raZb\nyLXbAfpITsXiJJBpCam9P9+XR5VSfgkqp5hIa7J8piN3DoMpoExg4PPQr6PbLAJy\nOUCOnuB7yYVbj0wYuMXTuyrcBHh/UymQnS8AMpQoEkCLWS/A/Hze/pD23LgiBoLY\nXIn5A2EOAf7t2IMSlA==\n=OanT\n-----END PGP PUBLIC KEY BLOCK-----',
metadata_verification: false,
},
{
export const mockRepositoryResults = (args) => {
const data = generateData(args);
const meta = generateMeta(args.limit, data.length);
const links = generateLinks(args.limit);
return {
data: data,
meta: meta,
links: links,
};
};
const generateData = (args) => {
let repos = testingRepos;
args.available_for_arch &&
(repos = repos.filter(
(repo) =>
repo.distribution_arch === 'any' ||
repo.distribution_arch === args.available_for_arch
));
args.available_for_version &&
(repos = repos.filter((repo) => {
return (
repo.distribution_versions.includes(args.available_for_version) ||
repo.distribution_versions.includes('any')
);
}));
repos = repos.slice(0, args.limit);
// Filler repos will always appear in response as they have distribution_versions
// and distribution_arch of 'any'. High count is useful for testing pagination.
const fillerRepos = generateFillerRepos(1000);
return [...repos, ...fillerRepos];
};
const testingRepos = [
{
uuid: 'dbad4dfc-1547-45f8-b5af-1d7fec0476c6',
name: '13lk3',
url: 'http://yum.theforeman.org/releases/3.4/el8/x86_64/',
distribution_versions: ['8'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:54:00.962352 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:54:00.962352 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:12.123607 +0000 UTC',
last_introspection_error: '',
package_count: 605,
status: 'Valid',
gpg_key:
'-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBGN9300BEAC1FLODu0cL6saMMHa7yJY1JZUc+jQUI/HdECQrrsTaPXlcc7nM\nykYMMv6amPqbnhH/R5BW2Ano+OMse+PXtUr0NXU4OcvxbnnXkrVBVUf8mXI9DzLZ\njw8KoD+4/s0BuzO78zAJF5uhuyHMAK0ll9v0r92kK45Fas9iZTfRFcqFAzvgjScf\n5jeBnbRs5U3UTz9mtDy802mk357o1A8BD0qlu3kANDpjLbORGWdAj21A6sMJDYXy\nHS9FBNV54daNcr+weky2L9gaF2yFjeu2rSEHCSfkbWfpSiVUx/bDTj7XS6XDOuJT\nJqvGS8jHqjHAIFBirhCA4cY/jLKxWyMr5N6IbXpPAYgt8/YYz2aOYVvdyB8tZ1u1\nkVsMYSGcvTBexZCn1cDkbO6I+waIlsc0uxGqUGBKF83AVYCQqOkBjF1uNnu9qefE\nkEc9obr4JZsAgnisboU25ss5ZJddKlmFMKSi66g4S5ChLEPFq7MB06PhLFioaD3L\nEXza7XitoW5VBwr0BSVKAHMC0T2xbm70zY06a6gQRlvr9a10lPmv4Tptc7xgQReg\nu1TlFPbrkGJ0d8O6vHQRAd3zdsNaVr4gX0Tg7UYiqT9ZUkP7hOc8PYXQ28hHrHTB\nA63MTq0aiPlJ/ivTuX8M6+Bi25dIV6N6IOUi/NQKIYxgovJCDSdCAAM0fQARAQAB\ntCFMdWNhcyBHYXJmaWVsZCA8bHVjYXNAcmVkaGF0LmNvbT6JAlcEEwEIAEEWIQTO\nQZeiHnXqdjmfUURc6PeuecS2PAUCY33fTQIbAwUJA8JnAAULCQgHAgIiAgYVCgkI\nCwIEFgIDAQIeBwIXgAAKCRBc6PeuecS2PCk3D/9jW7xrBB/2MQFKd5l+mNMFyKwc\nL9M/M5RFI9GaQRo55CwnPb0nnxOJR1V5GzZ/YGii53H2ose65CfBOE2L/F/RvKF0\nH9S9MInixlahzzKtV3TpDoZGk5oZIHEMuPmPS4XaHggolrzExY0ib0mQuBBE/uEV\n/HlyHEunBKPhTkAe+6Q+2dl22SUuVfWr4Uzlp65+DkdN3M37WI1a3Suhnef3rOSM\nV6puUzWRR7qcYs5C2In87AcYPn92P5ur1y/C32r8Ftg3fRWnEzI9QfRG52ojNOLK\nyGQ8ZC9PGe0q7VFcF7ridT/uzRU+NVKldbJg+rvBnszb1MjNuR7rUQHyvGmbsUVQ\nRCsgdovkee3lP4gfZHzk2SSLVSo0+NJRNaM90EmPk14Pgi/yfRSDGBVvLBbEanYI\nv1ZtdIPRyKi+/IaMOu/l7nayM/8RzghdU+0f1FAif5qf9nXuI13P8fqcqfu67gNd\nkh0UUF1XyR5UHHEZQQDqCuKEkZJ/+27jYlsG1ZiLb1odlIWoR44RP6k5OJl0raZb\nyLXbAfpITsXiJJBpCam9P9+XR5VSfgkqp5hIa7J8piN3DoMpoExg4PPQr6PbLAJy\nOUCOnuB7yYVbj0wYuMXTuyrcBHh/UymQnS8AMpQoEkCLWS/A/Hze/pD23LgiBoLY\nXIn5A2EOAf7t2IMSlA==\n=OanT\n-----END PGP PUBLIC KEY BLOCK-----',
metadata_verification: false,
},
{
uuid: '9cf1d45d-aa06-46fe-87ea-121845cc6bbb',
name: '2lmdtj',
url: 'http://mirror.stream.centos.org/SIGs/8/kmods/x86_64/packages-main/',
distribution_versions: ['8'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:12.714873 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:12.714873 +0000 UTC',
last_update_introspection_time: '2022-11-18 08:00:10.119093 +0000 UTC',
last_introspection_error: '',
package_count: 21,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '828e7db8-c0d4-48fc-a887-9070e0e75c45',
name: '2zmya',
url: 'https://download-i2.fedoraproject.org/pub/epel/9/Everything/x86_64/',
distribution_versions: ['9'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:18.111405 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:18.111405 +0000 UTC',
last_update_introspection_time: '2022-11-23 08:00:18.111405 +0000 UTC',
last_introspection_error: '',
package_count: 11526,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'ffe90892-6e6c-43c0-a284-df78977d8e37',
name: '4tnt6f',
url: 'https://mirror.linux.duke.edu/pub/centos/8-stream/BaseOS/x86_64/os/',
distribution_versions: ['9'],
distribution_arch: 'aarch64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-22 16:00:06.455684 +0000 UTC',
last_success_introspection_time: '2022-11-22 16:00:06.455684 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:06:03.021973 +0000 UTC',
last_introspection_error: '',
package_count: 11908,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '744000a5-fde5-481d-a1ae-07f27e7f4db9',
name: '76nlti',
url: 'https://download-i2.fedoraproject.org/pub/epel/7/x86_64/',
distribution_versions: ['8', '9'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:01:28.74002 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:01:28.74002 +0000 UTC',
last_update_introspection_time: '2022-11-23 08:01:28.74002 +0000 UTC',
last_introspection_error: '',
package_count: 13739,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '45068247-67b9-4f6d-8f19-1718ab56586e',
name: '938l0k',
url: 'http://yum.theforeman.org/client/3.4/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:20.911292 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:20.911292 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:10.148583 +0000 UTC',
last_introspection_error: '',
package_count: 17,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '60887c35-ce7a-4abc-8c57-1cb8a596f63d',
name: 'a6vac',
url: 'http://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:21.719974 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:21.719974 +0000 UTC',
last_update_introspection_time: '2022-09-20 00:21:01.891526 +0000 UTC',
last_introspection_error: '',
package_count: 0,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'f033a5af-ae00-4c26-8bb9-7329d4f17180',
name: 'abi7n',
url: 'http://yum.theforeman.org/katello/4.6/katello/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:01:31.52995 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:01:31.52995 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:11:04.043452 +0000 UTC',
last_introspection_error: '',
package_count: 102,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'be0fd64b-b7d0-48f1-b671-4c74b93a42d2',
name: 'g2ikq',
url: 'http://yum.theforeman.org/client/3.4/el9/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:21.465594 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:21.465594 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:10.830524 +0000 UTC',
last_introspection_error: '',
package_count: 11,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'bf5270e6-0559-469b-a4bd-9c881f603813',
name: 'gnome-shell-extensions',
url: 'https://gitlab.gnome.org/GNOME/gnome-shell-extensions/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:01:33.91888 +0000 UTC',
last_success_introspection_time: '',
last_update_introspection_time: '',
last_introspection_error:
'error parsing repomd.xml: xml.Unmarshal failure: expected element type <repomd> but have <html>',
package_count: 0,
status: 'Invalid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '31ae1b1c-0a14-46df-a6d4-4170f88abeee',
name: 'i9arb',
url: 'http://yum.theforeman.org/pulpcore/3.18/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:12.263236 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:12.263236 +0000 UTC',
last_update_introspection_time: '2022-11-12 00:00:18.375292 +0000 UTC',
last_introspection_error: '',
package_count: 340,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'ea375230-32f7-490d-82b6-501f0a8c2932',
name: 'ixgwo',
url: 'http://yum.theforeman.org/client/3.3/el7/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:37.091305 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:37.091305 +0000 UTC',
last_update_introspection_time: '2022-10-10 16:11:35.690955 +0000 UTC',
last_introspection_error: '',
package_count: 14,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'aa9506b1-e5dd-42be-b5b0-a674f4db915f',
name: 'k64ic',
url: 'http://yum.theforeman.org/pulpcore/3.18/el9/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:18.671713 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:18.671713 +0000 UTC',
last_update_introspection_time: '2022-11-12 00:00:08.970966 +0000 UTC',
last_introspection_error: '',
package_count: 338,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '3cce24d2-41e2-481d-8f01-2b043c72fd6f',
name: 'lrqm',
url: 'http://yum.theforeman.org/client/3.3/el8/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:11.11247 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:11.11247 +0000 UTC',
last_update_introspection_time: '2022-10-10 16:01:36.465549 +0000 UTC',
last_introspection_error: '',
package_count: 16,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'c988934a-87e2-482f-b887-d9ba677a037a',
name: 'mo1qy',
url: 'https://download-i2.fedoraproject.org/pub/epel/8/Everything/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:09.394253 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:09.394253 +0000 UTC',
last_update_introspection_time: '2022-11-23 08:00:09.394253 +0000 UTC',
last_introspection_error: '',
package_count: 9452,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'bbc2bba5-9d7d-4726-b96f-a48408e130b5',
name: 's2h9z',
url: 'http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-22 16:00:06.224391 +0000 UTC',
last_success_introspection_time: '2022-11-22 16:00:06.224391 +0000 UTC',
last_update_introspection_time: '2022-09-20 00:27:02.197045 +0000 UTC',
last_introspection_error: '',
package_count: 0,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '593a973b-715f-4867-ae9c-fa791b59b92d',
name: 'v9h0m',
url: 'http://yum.theforeman.org/pulpcore/3.18/el7/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:19.586273 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:19.586273 +0000 UTC',
last_update_introspection_time: '2022-11-13 00:00:25.156398 +0000 UTC',
last_introspection_error: '',
package_count: 259,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'd08a74ef-589b-486f-aae0-60c6abe25768',
name: 'vbazm',
url: 'http://yum.theforeman.org/client/3.4/el7/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:37.944592 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:37.944592 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:09.561151 +0000 UTC',
last_introspection_error: '',
package_count: 15,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '0a12a77d-c3fa-4cd7-958b-ecbec1fd1494',
name: 'vv5jk',
url: 'http://yum.theforeman.org/client/3.2/el7/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:20.495629 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:20.495629 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:20:17.587417 +0000 UTC',
last_introspection_error: '',
package_count: 14,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '5288c386-274c-4598-8f09-0e2f65346e0d',
name: 'ycxvp',
url: 'https://dl.google.com/linux/chrome/rpm/stable/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:09.595446 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:09.595446 +0000 UTC',
last_update_introspection_time: '2022-11-18 08:00:13.259506 +0000 UTC',
last_introspection_error: '',
package_count: 3,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'f087f9ad-dfe6-4627-9d53-336c09886cd4',
name: 'yzfsx',
url: 'http://yum.theforeman.org/client/3.3/el9/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:22.137451 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:22.137451 +0000 UTC',
last_update_introspection_time: '2022-10-10 16:00:18.041568 +0000 UTC',
last_introspection_error: '',
package_count: 11,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
];
const generateMeta = (limit, count) => {
return {
limit: limit,
offset: 0,
count: count,
};
};
const generateLinks = (limit) => {
return {
first: `/api/content-sources/v1/repositories/?limit=${limit}&offset=0`,
last: `/api/content-sources/v1/repositories/?limit=${limit}&offset=0`,
};
};
const generateFillerRepos = (num) => {
const repos = new Array(num).fill().map((_, i) => {
return {
uuid: '9cf1d45d-aa06-46fe-87ea-121845cc6bbb',
name: '2lmdtj',
url: 'http://mirror.stream.centos.org/SIGs/9/kmods/x86_64/packages-main/',
name: `filler repo ${i}`,
url: `http://fillerRepos.org/9/x86_64/packages/${i}`,
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
@ -34,339 +431,7 @@ export const mockRepositoryResults = {
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '828e7db8-c0d4-48fc-a887-9070e0e75c45',
name: '2zmya',
url: 'https://download-i2.fedoraproject.org/pub/epel/9/Everything/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:18.111405 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:18.111405 +0000 UTC',
last_update_introspection_time: '2022-11-23 08:00:18.111405 +0000 UTC',
last_introspection_error: '',
package_count: 11526,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'ffe90892-6e6c-43c0-a284-df78977d8e37',
name: '4tnt6f',
url: 'https://mirror.linux.duke.edu/pub/centos/8-stream/BaseOS/x86_64/os/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-22 16:00:06.455684 +0000 UTC',
last_success_introspection_time: '2022-11-22 16:00:06.455684 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:06:03.021973 +0000 UTC',
last_introspection_error: '',
package_count: 11908,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '744000a5-fde5-481d-a1ae-07f27e7f4db9',
name: '76nlti',
url: 'https://download-i2.fedoraproject.org/pub/epel/7/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:01:28.74002 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:01:28.74002 +0000 UTC',
last_update_introspection_time: '2022-11-23 08:01:28.74002 +0000 UTC',
last_introspection_error: '',
package_count: 13739,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '45068247-67b9-4f6d-8f19-1718ab56586e',
name: '938l0k',
url: 'http://yum.theforeman.org/client/3.4/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:20.911292 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:20.911292 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:10.148583 +0000 UTC',
last_introspection_error: '',
package_count: 17,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '60887c35-ce7a-4abc-8c57-1cb8a596f63d',
name: 'a6vac',
url: 'http://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:21.719974 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:21.719974 +0000 UTC',
last_update_introspection_time: '2022-09-20 00:21:01.891526 +0000 UTC',
last_introspection_error: '',
package_count: 0,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'f033a5af-ae00-4c26-8bb9-7329d4f17180',
name: 'abi7n',
url: 'http://yum.theforeman.org/katello/4.6/katello/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:01:31.52995 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:01:31.52995 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:11:04.043452 +0000 UTC',
last_introspection_error: '',
package_count: 102,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'be0fd64b-b7d0-48f1-b671-4c74b93a42d2',
name: 'g2ikq',
url: 'http://yum.theforeman.org/client/3.4/el9/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:21.465594 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:21.465594 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:10.830524 +0000 UTC',
last_introspection_error: '',
package_count: 11,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'bf5270e6-0559-469b-a4bd-9c881f603813',
name: 'gnome-shell-extensions',
url: 'https://gitlab.gnome.org/GNOME/gnome-shell-extensions/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:01:33.91888 +0000 UTC',
last_success_introspection_time: '',
last_update_introspection_time: '',
last_introspection_error:
'error parsing repomd.xml: xml.Unmarshal failure: expected element type <repomd> but have <html>',
package_count: 0,
status: 'Invalid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '31ae1b1c-0a14-46df-a6d4-4170f88abeee',
name: 'i9arb',
url: 'http://yum.theforeman.org/pulpcore/3.18/el8/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:12.263236 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:12.263236 +0000 UTC',
last_update_introspection_time: '2022-11-12 00:00:18.375292 +0000 UTC',
last_introspection_error: '',
package_count: 340,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'ea375230-32f7-490d-82b6-501f0a8c2932',
name: 'ixgwo',
url: 'http://yum.theforeman.org/client/3.3/el7/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:37.091305 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:37.091305 +0000 UTC',
last_update_introspection_time: '2022-10-10 16:11:35.690955 +0000 UTC',
last_introspection_error: '',
package_count: 14,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'aa9506b1-e5dd-42be-b5b0-a674f4db915f',
name: 'k64ic',
url: 'http://yum.theforeman.org/pulpcore/3.18/el9/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:18.671713 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:18.671713 +0000 UTC',
last_update_introspection_time: '2022-11-12 00:00:08.970966 +0000 UTC',
last_introspection_error: '',
package_count: 338,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '3cce24d2-41e2-481d-8f01-2b043c72fd6f',
name: 'lrqm',
url: 'http://yum.theforeman.org/client/3.3/el8/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:11.11247 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:11.11247 +0000 UTC',
last_update_introspection_time: '2022-10-10 16:01:36.465549 +0000 UTC',
last_introspection_error: '',
package_count: 16,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'c988934a-87e2-482f-b887-d9ba677a037a',
name: 'mo1qy',
url: 'https://download-i2.fedoraproject.org/pub/epel/8/Everything/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:09.394253 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:09.394253 +0000 UTC',
last_update_introspection_time: '2022-11-23 08:00:09.394253 +0000 UTC',
last_introspection_error: '',
package_count: 9452,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'bbc2bba5-9d7d-4726-b96f-a48408e130b5',
name: 's2h9z',
url: 'http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-22 16:00:06.224391 +0000 UTC',
last_success_introspection_time: '2022-11-22 16:00:06.224391 +0000 UTC',
last_update_introspection_time: '2022-09-20 00:27:02.197045 +0000 UTC',
last_introspection_error: '',
package_count: 0,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '593a973b-715f-4867-ae9c-fa791b59b92d',
name: 'v9h0m',
url: 'http://yum.theforeman.org/pulpcore/3.18/el7/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:19.586273 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:19.586273 +0000 UTC',
last_update_introspection_time: '2022-11-13 00:00:25.156398 +0000 UTC',
last_introspection_error: '',
package_count: 259,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'd08a74ef-589b-486f-aae0-60c6abe25768',
name: 'vbazm',
url: 'http://yum.theforeman.org/client/3.4/el7/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:37.944592 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:37.944592 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:18:09.561151 +0000 UTC',
last_introspection_error: '',
package_count: 15,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '0a12a77d-c3fa-4cd7-958b-ecbec1fd1494',
name: 'vv5jk',
url: 'http://yum.theforeman.org/client/3.2/el7/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'any',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 00:00:20.495629 +0000 UTC',
last_success_introspection_time: '2022-11-23 00:00:20.495629 +0000 UTC',
last_update_introspection_time: '2022-10-04 00:20:17.587417 +0000 UTC',
last_introspection_error: '',
package_count: 14,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: '5288c386-274c-4598-8f09-0e2f65346e0d',
name: 'ycxvp',
url: 'https://dl.google.com/linux/chrome/rpm/stable/x86_64/',
distribution_versions: ['any'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:09.595446 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:09.595446 +0000 UTC',
last_update_introspection_time: '2022-11-18 08:00:13.259506 +0000 UTC',
last_introspection_error: '',
package_count: 3,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
{
uuid: 'f087f9ad-dfe6-4627-9d53-336c09886cd4',
name: 'yzfsx',
url: 'http://yum.theforeman.org/client/3.3/el9/x86_64/',
distribution_versions: ['7'],
distribution_arch: 'x86_64',
account_id: '6416440',
org_id: '13476545',
last_introspection_time: '2022-11-23 08:00:22.137451 +0000 UTC',
last_success_introspection_time: '2022-11-23 08:00:22.137451 +0000 UTC',
last_update_introspection_time: '2022-10-10 16:00:18.041568 +0000 UTC',
last_introspection_error: '',
package_count: 11,
status: 'Valid',
gpg_key: '',
metadata_verification: false,
},
],
meta: {
limit: 100,
offset: 0,
count: 21,
},
links: {
first: '/api/content-sources/v1/repositories/?limit=100&offset=0',
last: '/api/content-sources/v1/repositories/?limit=100&offset=0',
},
};
});
return repos;
};

View file

@ -1,6 +1,11 @@
import { rest } from 'msw';
import { PROVISIONING_SOURCES_ENDPOINT, RHSM_API } from '../../constants';
import {
CONTENT_SOURCES,
PROVISIONING_SOURCES_ENDPOINT,
RHSM_API,
} from '../../constants';
import { mockRepositoryResults } from '../fixtures/repositories';
const baseURL = 'http://localhost';
@ -319,4 +324,16 @@ export const handlers = [
}
}
),
rest.get(
baseURL.concat(`${CONTENT_SOURCES}/repositories/`),
(req, res, ctx) => {
const available_for_arch = req.url.searchParams.get('available_for_arch');
const available_for_version = req.url.searchParams.get(
'available_for_version'
);
const limit = req.url.searchParams.get('limit');
const args = { available_for_arch, available_for_version, limit };
return res(ctx.status(200), ctx.json(mockRepositoryResults(args)));
}
),
];