Skip to content
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
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-13524-fixed-1774351558003.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Destination Form: omit the tls_hostname field from the request if it is empty or contains only whitespace ([#13524](https://github.com/linode/manager/pull/13524))
50 changes: 50 additions & 0 deletions packages/manager/src/features/Delivery/deliveryUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,56 @@ describe('delivery utils functions', () => {
expect(result.content_type).toBeUndefined();
expect(result.client_certificate_details).toBeUndefined();
});

it('should omit tls_hostname from client_certificate_details when it is an empty string', () => {
const details: CustomHTTPSDetailsExtended = {
...baseCustomHTTPSDetails,
client_certificate_details: {
client_ca_certificate: 'ca-cert',
client_certificate: 'cert',
client_private_key: 'key',
tls_hostname: '',
},
};

const result = getDestinationPayloadDetails(
details,
destinationType.CustomHttps
) as CustomHTTPSDetailsExtended;

expect(result.client_certificate_details).toBeDefined();
expect(result.client_certificate_details?.tls_hostname).toBeUndefined();
expect(result.client_certificate_details).toEqual({
client_ca_certificate: 'ca-cert',
client_certificate: 'cert',
client_private_key: 'key',
});
});

it('should omit tls_hostname from client_certificate_details when it is whitespace', () => {
const details: CustomHTTPSDetailsExtended = {
...baseCustomHTTPSDetails,
client_certificate_details: {
client_ca_certificate: 'ca-cert',
client_certificate: 'cert',
client_private_key: 'key',
tls_hostname: ' ',
},
};

const result = getDestinationPayloadDetails(
details,
destinationType.CustomHttps
) as CustomHTTPSDetailsExtended;

expect(result.client_certificate_details).toBeDefined();
expect(result.client_certificate_details?.tls_hostname).toBeUndefined();
expect(result.client_certificate_details).toEqual({
client_ca_certificate: 'ca-cert',
client_certificate: 'cert',
client_private_key: 'key',
});
});
});
});
});
10 changes: 9 additions & 1 deletion packages/manager/src/features/Delivery/deliveryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const getDestinationPayloadDetails = (
if (type === destinationType.CustomHttps) {
const propsToRemove: any[] = [];
const customHTTPSDetails = details as CustomHTTPSDetailsExtended;
let finalCustomHTTPSDetails = customHTTPSDetails;

if (!customHTTPSDetails.content_type) {
propsToRemove.push('content_type');
Expand All @@ -125,15 +126,22 @@ export const getDestinationPayloadDetails = (

if (shouldRemoveCertDetails) {
propsToRemove.push('client_certificate_details');
} else if (!certDetails.tls_hostname?.trim()) {
finalCustomHTTPSDetails = {
...customHTTPSDetails,
client_certificate_details: omitProps(certDetails, ['tls_hostname']),
};
}
}

if (propsToRemove.length > 0) {
return omitProps(
customHTTPSDetails,
finalCustomHTTPSDetails,
propsToRemove
) as CustomHTTPSDetailsExtended;
}

return finalCustomHTTPSDetails;
} else if ('path' in details && details.path === '') {
return omitProps(details, ['path']);
}
Expand Down
Loading