-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Adds.a new `map.emsUrl` setting. User can configure this to the location of a local on-prem installation of EMS. For this setting to take effect, the cluster must be configured with an enterprise license.
- Loading branch information
1 parent
6051264
commit 20860c7
Showing
21 changed files
with
532 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
// Default config for the elastic hosted EMS endpoints | ||
export const DEFAULT_EMS_FILE_API_URL = 'https://vector.maps.elastic.co'; | ||
export const DEFAULT_EMS_TILE_API_URL = 'https://tiles.maps.elastic.co'; | ||
export const DEFAULT_EMS_LANDING_PAGE_URL = 'https://maps.elastic.co/v7.10'; | ||
export const DEFAULT_EMS_FONT_LIBRARY_URL = | ||
'https://tiles.maps.elastic.co/fonts/{fontstack}/{range}.pbf'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export * from './ems_defaults'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { EMSSettings, IEMSConfig } from './ems_settings'; | ||
import { | ||
DEFAULT_EMS_FILE_API_URL, | ||
DEFAULT_EMS_FONT_LIBRARY_URL, | ||
DEFAULT_EMS_LANDING_PAGE_URL, | ||
DEFAULT_EMS_TILE_API_URL, | ||
} from '../../../../src/plugins/maps_legacy/common'; | ||
|
||
const IS_ENTERPRISE_PLUS = () => true; | ||
|
||
describe('EMSSettings', () => { | ||
const mockConfig: IEMSConfig = { | ||
includeElasticMapsService: true, | ||
proxyElasticMapsServiceInMaps: false, | ||
emsUrl: '', | ||
emsFileApiUrl: DEFAULT_EMS_FILE_API_URL, | ||
emsTileApiUrl: DEFAULT_EMS_TILE_API_URL, | ||
emsLandingPageUrl: DEFAULT_EMS_LANDING_PAGE_URL, | ||
emsFontLibraryUrl: DEFAULT_EMS_FONT_LIBRARY_URL, | ||
isEMSEnabled: true, | ||
}; | ||
|
||
describe('isEMSEnabled/isOnPrem', () => { | ||
test('should validate defaults', () => { | ||
const emsSettings = new EMSSettings(mockConfig, IS_ENTERPRISE_PLUS); | ||
expect(emsSettings.isEMSEnabled()).toBe(true); | ||
expect(emsSettings.isOnPrem()).toBe(false); | ||
}); | ||
|
||
test('should validate if on-prem is turned on', () => { | ||
const emsSettings = new EMSSettings( | ||
{ | ||
...mockConfig, | ||
...{ | ||
emsUrl: 'https://localhost:8080', | ||
}, | ||
}, | ||
IS_ENTERPRISE_PLUS | ||
); | ||
expect(emsSettings.isEMSEnabled()).toBe(true); | ||
expect(emsSettings.isOnPrem()).toBe(true); | ||
}); | ||
|
||
test('should not validate if ems turned off', () => { | ||
const emsSettings = new EMSSettings( | ||
{ | ||
...mockConfig, | ||
...{ | ||
includeElasticMapsService: false, | ||
}, | ||
}, | ||
IS_ENTERPRISE_PLUS | ||
); | ||
expect(emsSettings.isEMSEnabled()).toBe(false); | ||
expect(emsSettings.isOnPrem()).toBe(false); | ||
}); | ||
|
||
test('should work if ems is turned off, but on-prem is turned on', () => { | ||
const emsSettings = new EMSSettings( | ||
{ | ||
...mockConfig, | ||
...{ | ||
emsUrl: 'https://localhost:8080', | ||
includeElasticMapsService: false, | ||
}, | ||
}, | ||
IS_ENTERPRISE_PLUS | ||
); | ||
expect(emsSettings.isEMSEnabled()).toBe(true); | ||
expect(emsSettings.isOnPrem()).toBe(true); | ||
}); | ||
|
||
describe('when license is turned off', () => { | ||
test('should not be enabled', () => { | ||
const emsSettings = new EMSSettings( | ||
{ | ||
...mockConfig, | ||
...{ | ||
emsUrl: 'https://localhost:8080', | ||
}, | ||
}, | ||
() => false | ||
); | ||
expect(emsSettings.isEMSEnabled()).toBe(false); | ||
expect(emsSettings.isOnPrem()).toBe(true); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('emsUrl setting', () => { | ||
describe('when emsUrl is not set', () => { | ||
test('should respect defaults', () => { | ||
const emsSettings = new EMSSettings(mockConfig, IS_ENTERPRISE_PLUS); | ||
expect(emsSettings.getEMSFileApiUrl()).toBe(DEFAULT_EMS_FILE_API_URL); | ||
expect(emsSettings.getEMSTileApiUrl()).toBe(DEFAULT_EMS_TILE_API_URL); | ||
expect(emsSettings.getEMSFontLibraryUrl()).toBe(DEFAULT_EMS_FONT_LIBRARY_URL); | ||
expect(emsSettings.getEMSLandingPageUrl()).toBe(DEFAULT_EMS_LANDING_PAGE_URL); | ||
}); | ||
test('should apply overrides', () => { | ||
const emsSettings = new EMSSettings( | ||
{ | ||
...mockConfig, | ||
...{ | ||
emsFileApiUrl: 'https://file.foobar', | ||
emsTileApiUrl: 'https://tile.foobar', | ||
emsFontLibraryUrl: 'https://tile.foobar/font', | ||
emsLandingPageUrl: 'https://maps.foobar/v7.666', | ||
}, | ||
}, | ||
IS_ENTERPRISE_PLUS | ||
); | ||
expect(emsSettings.getEMSFileApiUrl()).toBe('https://file.foobar'); | ||
expect(emsSettings.getEMSTileApiUrl()).toBe('https://tile.foobar'); | ||
expect(emsSettings.getEMSFontLibraryUrl()).toBe('https://tile.foobar/font'); | ||
expect(emsSettings.getEMSLandingPageUrl()).toBe('https://maps.foobar/v7.666'); | ||
}); | ||
}); | ||
|
||
describe('when emsUrl is set', () => { | ||
test('should override defaults', () => { | ||
const emsSettings = new EMSSettings( | ||
{ | ||
...mockConfig, | ||
...{ | ||
emsUrl: 'https://localhost:8080', | ||
}, | ||
}, | ||
IS_ENTERPRISE_PLUS | ||
); | ||
expect(emsSettings.getEMSFileApiUrl()).toBe('https://localhost:8080/file'); | ||
expect(emsSettings.getEMSTileApiUrl()).toBe('https://localhost:8080/tile'); | ||
expect(emsSettings.getEMSFontLibraryUrl()).toBe( | ||
'https://localhost:8080/tile/fonts/{fontstack}/{range}.pbf' | ||
); | ||
expect(emsSettings.getEMSLandingPageUrl()).toBe('https://localhost:8080/maps'); | ||
}); | ||
|
||
describe('internal settings overrides (the below behavior is not publically supported, but aids internal debugging use-cases)', () => { | ||
test(`should override internal emsFileApiUrl`, () => { | ||
const emsSettings = new EMSSettings( | ||
{ | ||
...mockConfig, | ||
...{ | ||
emsUrl: 'https://localhost:8080', | ||
emsFileApiUrl: 'https://file.foobar', | ||
}, | ||
}, | ||
IS_ENTERPRISE_PLUS | ||
); | ||
expect(emsSettings.getEMSFileApiUrl()).toBe('https://file.foobar'); | ||
expect(emsSettings.getEMSTileApiUrl()).toBe('https://localhost:8080/tile'); | ||
expect(emsSettings.getEMSFontLibraryUrl()).toBe( | ||
'https://localhost:8080/tile/fonts/{fontstack}/{range}.pbf' | ||
); | ||
expect(emsSettings.getEMSLandingPageUrl()).toBe('https://localhost:8080/maps'); | ||
}); | ||
|
||
test(`should override internal emsTileApiUrl`, () => { | ||
const emsSettings = new EMSSettings( | ||
{ | ||
...mockConfig, | ||
...{ | ||
emsUrl: 'https://localhost:8080', | ||
emsTileApiUrl: 'https://tile.foobar', | ||
}, | ||
}, | ||
IS_ENTERPRISE_PLUS | ||
); | ||
expect(emsSettings.getEMSFileApiUrl()).toBe('https://localhost:8080/file'); | ||
expect(emsSettings.getEMSTileApiUrl()).toBe('https://tile.foobar'); | ||
expect(emsSettings.getEMSFontLibraryUrl()).toBe( | ||
'https://localhost:8080/tile/fonts/{fontstack}/{range}.pbf' | ||
); | ||
expect(emsSettings.getEMSLandingPageUrl()).toBe('https://localhost:8080/maps'); | ||
}); | ||
|
||
test('should override internal emsFontLibraryUrl', () => { | ||
const emsSettings = new EMSSettings( | ||
{ | ||
...mockConfig, | ||
...{ | ||
emsUrl: 'https://localhost:8080', | ||
emsFontLibraryUrl: 'https://maps.foobar/fonts', | ||
}, | ||
}, | ||
IS_ENTERPRISE_PLUS | ||
); | ||
expect(emsSettings.getEMSFileApiUrl()).toBe('https://localhost:8080/file'); | ||
expect(emsSettings.getEMSTileApiUrl()).toBe('https://localhost:8080/tile'); | ||
expect(emsSettings.getEMSFontLibraryUrl()).toBe('https://maps.foobar/fonts'); | ||
expect(emsSettings.getEMSLandingPageUrl()).toBe('https://localhost:8080/maps'); | ||
}); | ||
|
||
test('should override internal emsLandingPageUrl', () => { | ||
const emsSettings = new EMSSettings( | ||
{ | ||
...mockConfig, | ||
...{ | ||
emsUrl: 'https://localhost:8080', | ||
emsLandingPageUrl: 'https://maps.foobar', | ||
}, | ||
}, | ||
IS_ENTERPRISE_PLUS | ||
); | ||
expect(emsSettings.getEMSFileApiUrl()).toBe('https://localhost:8080/file'); | ||
expect(emsSettings.getEMSTileApiUrl()).toBe('https://localhost:8080/tile'); | ||
expect(emsSettings.getEMSFontLibraryUrl()).toBe( | ||
'https://localhost:8080/tile/fonts/{fontstack}/{range}.pbf' | ||
); | ||
expect(emsSettings.getEMSLandingPageUrl()).toBe('https://maps.foobar'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.