[Fleet] Use default port for fleet server cloud url (#98492)

This commit is contained in:
Nicolas Chaulet 2021-04-27 13:04:08 -04:00 committed by GitHub
parent aa281ffad7
commit 52a90e3dc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View file

@ -17,7 +17,7 @@ describe('getCloudFleetServersHosts', () => {
expect(getCloudFleetServersHosts()).toBeUndefined();
});
it('should return fleet server hosts if cloud is correctly setup', () => {
it('should return fleet server hosts if cloud is correctly setup with default port == 443', () => {
mockedAppContextService.getCloud.mockReturnValue({
cloudId:
'dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyRjZWM2ZjI2MWE3NGJmMjRjZTMzYmI4ODExYjg0Mjk0ZiRjNmMyY2E2ZDA0MjI0OWFmMGNjN2Q3YTllOTYyNTc0Mw==',
@ -32,4 +32,20 @@ describe('getCloudFleetServersHosts', () => {
]
`);
});
it('should return fleet server hosts if cloud is correctly setup with a default port', () => {
mockedAppContextService.getCloud.mockReturnValue({
cloudId:
'test:dGVzdC5mcjo5MjQzJGRhM2I2YjNkYWY5ZDRjODE4ZjI4ZmEzNDdjMzgzODViJDgxMmY4NWMxZjNjZTQ2YTliYjgxZjFjMWIxMzRjNmRl',
isCloudEnabled: true,
deploymentId: 'deployment-id-1',
apm: {},
});
expect(getCloudFleetServersHosts()).toMatchInlineSnapshot(`
Array [
"https://deployment-id-1.fleet.test.fr:9243",
]
`);
});
});

View file

@ -84,6 +84,10 @@ export function getCloudFleetServersHosts() {
}
// Fleet Server url are formed like this `https://<deploymentId>.fleet.<host>
return [`https://${cloudSetup.deploymentId}.fleet.${res.host}`];
return [
`https://${cloudSetup.deploymentId}.fleet.${res.host}${
res.defaultPort !== '443' ? `:${res.defaultPort}` : ''
}`,
];
}
}