From 942b3b23475f7fbb84b96d4a57582e1c87b2c4bc Mon Sep 17 00:00:00 2001 From: Jeff Derstadt Date: Tue, 13 Nov 2018 13:07:58 -0800 Subject: [PATCH] Add channelService to endpoint service of bot configuration file --- .../src/models/endpointService.ts | 7 +++++ .../botframework-config/tests/govTest.bot | 17 ++++++++++++ .../tests/loadAndSave.test.js | 27 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 libraries/botframework-config/tests/govTest.bot diff --git a/libraries/botframework-config/src/models/endpointService.ts b/libraries/botframework-config/src/models/endpointService.ts index b97d320bb8..8b0fb4c30a 100644 --- a/libraries/botframework-config/src/models/endpointService.ts +++ b/libraries/botframework-config/src/models/endpointService.ts @@ -27,6 +27,13 @@ export class EndpointService extends ConnectedService implements IEndpointServic */ public endpoint: string; + /** + * The channel service (Azure or US Government Azure) for the bot. + * A value of 'https://botframework.azure.us' means the bot will be talking to a US Government Azure data center. + * An undefined or null value means the bot will be talking to public Azure + */ + public channelService: string; + /** * Creates a new EndpointService instance. * @param source JSON based service definition. diff --git a/libraries/botframework-config/tests/govTest.bot b/libraries/botframework-config/tests/govTest.bot new file mode 100644 index 0000000000..c47e4a8f7b --- /dev/null +++ b/libraries/botframework-config/tests/govTest.bot @@ -0,0 +1,17 @@ +{ + "name": "govTest", + "description": "gov test description", + "version": "2.0", + "secretKey": "", + "services": [ + { + "type": "endpoint", + "name": "testEndpoint", + "id": "5", + "appId": "00000003-0000-0000-0000-000000000000", + "appPassword": "testpassword", + "endpoint": "https://test.azurewebsites.net/api/messages", + "channelService": "https://botframework.azure.us" + } + ] +} \ No newline at end of file diff --git a/libraries/botframework-config/tests/loadAndSave.test.js b/libraries/botframework-config/tests/loadAndSave.test.js index 538b8dd50f..2228cbf732 100644 --- a/libraries/botframework-config/tests/loadAndSave.test.js +++ b/libraries/botframework-config/tests/loadAndSave.test.js @@ -5,6 +5,7 @@ let path = require('path'); // do not save over testbot const testBotPath = require.resolve("./test.bot"); +const govTestBotPath = require.resolve("./govTest.bot"); const legacyBotPath = require.resolve("./legacy.bot"); const saveBotPath = testBotPath.replace("test.bot", "save.bot"); @@ -118,6 +119,32 @@ describe("LoadAndSaveTests", () => { await config2.saveAs(saveBotPath, secret); }); + it("LoadAndVerifyChannelServiceSync", async () => { + var config = bf.BotConfiguration.loadSync(testBotPath); + for (let i = 0; i < config.services.length; i++) { + switch (config.services[i].type) { + case bf.ServiceTypes.Endpoint: + { + var endpoint = config.services[i]; + assert.equal(undefined, endpoint.channelService); + } + break; + } + } + + var govConfig = bf.BotConfiguration.loadSync(govTestBotPath); + for (let i = 0; i < govConfig.services.length; i++) { + switch (govConfig.services[i].type) { + case bf.ServiceTypes.Endpoint: + { + var endpoint = govConfig.services[i]; + assert.equal('https://botframework.azure.us', endpoint.channelService); + } + break; + } + } + }); + it("LoadAndSaveEncrypted", async () => { let secret = bf.BotConfiguration.generateKey(); var config = await bf.BotConfiguration.load(testBotPath);