Adding a new test case covering the url we are looking for when we register a new entry to the catalog using the action. Removing the gerrit stuff

Signed-off-by: cmoulliard <cmoulliard@redhat.com>
This commit is contained in:
cmoulliard
2024-01-04 19:03:31 +01:00
parent 82ae17b19c
commit a72521bae8
+19 -17
View File
@@ -30,6 +30,22 @@ describe('gitea core', () => {
const worker = setupServer();
setupRequestMockHandlers(worker);
describe('getGiteaFileCatalogInfoCntentsUrl', () => {
it('can create an url from arguments', () => {
const config: GiteaIntegrationConfig = {
host: 'gitea.com',
};
expect(
getGiteaFileContentsUrl(
config,
'https://gitea.com/org1/repo1/src/branch/main/catalog-info.yaml',
),
).toEqual(
'https://gitea.com/api/v1/repos/org1/repo1/contents/catalog-info.yaml?ref=main',
);
});
});
describe('getGiteaFileContentsUrl', () => {
it('can create an url from arguments', () => {
const config: GiteaIntegrationConfig = {
@@ -94,29 +110,15 @@ describe('gitea core', () => {
});
});
describe('getGerritRequestOptions', () => {
it('adds token header when only a password is specified', () => {
const authRequest: GiteaIntegrationConfig = {
host: 'gerrit.com',
password: 'P',
};
const anonymousRequest: GiteaIntegrationConfig = {
host: 'gerrit.com',
};
expect(
(getGiteaRequestOptions(authRequest).headers as any).Authorization,
).toEqual('token P');
expect(getGiteaRequestOptions(anonymousRequest).headers).toBeUndefined();
});
describe('getGiteaRequestOptions', () => {
it('adds basic auth when username and password are specified', () => {
const authRequest: GiteaIntegrationConfig = {
host: 'gerrit.com',
host: 'gitea.com',
username: 'username',
password: 'P',
};
const basicAuthentication = `basic ${Buffer.from(
const basicAuthentication = `Basic ${Buffer.from(
`${authRequest.username}:${authRequest.password}`,
).toString('base64')}`;