Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Reporting/Legacy] Remove reporting legacy job params compatibility shim #52539

Merged
merged 16 commits into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test(`fails if no URL is passed`, async () => {
server: mockServer,
} as FullUrlsOpts);
expect(fn).toThrowErrorMatchingInlineSnapshot(
`"No valid URL fields found in Job Params! Expected \`job.relativeUrl\` or \`job.objects[{ relativeUrl }]\`"`
`"No valid URL fields found in Job Params! Expected \`job.relativeUrl: string\` or \`job.relativeUrls: string[]\`"`
);
});

Expand Down Expand Up @@ -64,7 +64,10 @@ test(`fails if URLs are file-protocols for PDF`, async () => {
const relativeUrl = 'file://etc/passwd/#/something';
const fn = () =>
getFullUrls({
job: { objects: [{ relativeUrl }], forceNow },
job: {
relativeUrls: [relativeUrl],
forceNow,
},
server: mockServer,
} as FullUrlsOpts);
expect(fn).toThrowErrorMatchingInlineSnapshot(
Expand All @@ -79,11 +82,7 @@ test(`fails if URLs are absolute for PDF`, async () => {
const fn = () =>
getFullUrls({
job: {
objects: [
{
relativeUrl,
},
],
relativeUrls: [relativeUrl],
forceNow,
},
server: mockServer,
Expand All @@ -95,18 +94,15 @@ test(`fails if URLs are absolute for PDF`, async () => {

test(`fails if any URLs are absolute or file's for PDF`, async () => {
const forceNow = '2000-01-01T00:00:00.000Z';
const objects = [
{ relativeUrl: '/app/kibana#/something_aaa' },
{
relativeUrl:
'http://169.254.169.254/latest/meta-data/iam/security-credentials/profileName/#/something',
},
{ relativeUrl: 'file://etc/passwd/#/something' },
const relativeUrls = [
'/app/kibana#/something_aaa',
'http://169.254.169.254/latest/meta-data/iam/security-credentials/profileName/#/something',
'file://etc/passwd/#/something',
];

const fn = () =>
getFullUrls({
job: { objects, forceNow },
job: { relativeUrls, forceNow },
server: mockServer,
} as FullUrlsOpts);
expect(fn).toThrowErrorMatchingInlineSnapshot(
Expand Down Expand Up @@ -163,11 +159,11 @@ test(`adds forceNow to each of multiple urls`, async () => {
const forceNow = '2000-01-01T00:00:00.000Z';
const urls = await getFullUrls({
job: {
objects: [
{ relativeUrl: '/app/kibana#/something_aaa' },
{ relativeUrl: '/app/kibana#/something_bbb' },
{ relativeUrl: '/app/kibana#/something_ccc' },
{ relativeUrl: '/app/kibana#/something_ddd' },
relativeUrls: [
'/app/kibana#/something_aaa',
'/app/kibana#/something_bbb',
'/app/kibana#/something_ccc',
'/app/kibana#/something_ddd',
],
forceNow,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function isPngJob(job: JobDocPayloadPNG | JobDocPayloadPDF): job is JobDocPayloa
return (job as JobDocPayloadPNG).relativeUrl !== undefined;
}
function isPdfJob(job: JobDocPayloadPNG | JobDocPayloadPDF): job is JobDocPayloadPDF {
return (job as JobDocPayloadPDF).objects !== undefined;
return (job as JobDocPayloadPDF).relativeUrls !== undefined;
}

export function getFullUrls<JobDocPayloadType>({
Expand All @@ -45,10 +45,10 @@ export function getFullUrls<JobDocPayloadType>({
if (isPngJob(job)) {
relativeUrls = [job.relativeUrl];
} else if (isPdfJob(job)) {
relativeUrls = job.objects.map(obj => obj.relativeUrl);
relativeUrls = job.relativeUrls;
} else {
throw new Error(
`No valid URL fields found in Job Params! Expected \`job.relativeUrl\` or \`job.objects[{ relativeUrl }]\``
`No valid URL fields found in Job Params! Expected \`job.relativeUrl: string\` or \`job.relativeUrls: string[]\``
);
}

Expand Down

This file was deleted.

Loading