-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3db3e9
commit c33ec8a
Showing
10 changed files
with
133 additions
and
28 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
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
40 changes: 40 additions & 0 deletions
40
libraries/botframework-connector/src/auth/microsoftGovernmentAppCredentials.ts
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,40 @@ | ||
/** | ||
* @module botframework-connector | ||
*/ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
import { GovernmentConstants } from './governmentConstants'; | ||
import { MicrosoftAppCredentials } from './microsoftAppCredentials'; | ||
|
||
/** | ||
* MicrosoftGovermentAppCredentials auth implementation | ||
*/ | ||
export class MicrosoftGovernmentAppCredentials extends MicrosoftAppCredentials { | ||
|
||
/** | ||
* Initializes a new instance of the [MicrosoftGovernmentAppCredentials](xref:botframework-connector.MicrosoftGovernmentAppCredentials) class. | ||
* | ||
* @param {string} appId The Microsoft app ID. | ||
* @param {string} appPassword The Microsoft app password. | ||
* @param {string} channelAuthTenant Optional. The oauth token tenant. | ||
* @param {string} oAuthScope Optional. The scope for the token. | ||
*/ | ||
constructor(appId: string, public appPassword: string, channelAuthTenant?: string, oAuthScope?: string) { | ||
super(appId, appPassword, channelAuthTenant, oAuthScope); | ||
} | ||
|
||
protected GetToChannelFromBotOAuthScope(): string { | ||
return GovernmentConstants.ToChannelFromBotOAuthScope; | ||
} | ||
|
||
protected GetToChannelFromBotLoginUrlPrefix(): string { | ||
return GovernmentConstants.ToChannelFromBotLoginUrlPrefix; | ||
} | ||
|
||
protected GetDefaultChannelAuthTenant(): string { | ||
return GovernmentConstants.DefaultChannelAuthTenant; | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
libraries/botframework-connector/tests/auth/microsoftAppCredentials.test.js
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,17 @@ | ||
const { MicrosoftAppCredentials, AuthenticationConstants } = require('../..'); | ||
const assert = require('assert'); | ||
|
||
describe('MicrosoftAppCredentialsTestSuite', function () { | ||
describe('MicrosoftAppCredentialsTestCase', function () { | ||
it('AssertOAuthEndpointAndOAuthScope', function() { | ||
var credentials = new MicrosoftAppCredentials("appId", "password", "tenantId", "audience"); | ||
assert.strictEqual(AuthenticationConstants.ToChannelFromBotLoginUrlPrefix + "tenantId", credentials.oAuthEndpoint); | ||
assert.strictEqual("audience", credentials.oAuthScope); | ||
|
||
var credentials = new MicrosoftAppCredentials("appId", "password"); | ||
assert.strictEqual(AuthenticationConstants.ToChannelFromBotLoginUrlPrefix + AuthenticationConstants.DefaultChannelAuthTenant, credentials.oAuthEndpoint); | ||
assert.strictEqual(AuthenticationConstants.ToChannelFromBotOAuthScope, credentials.oAuthScope); | ||
}); | ||
|
||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
libraries/botframework-connector/tests/auth/microsoftGovernmentAppCredentials.test.js
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,17 @@ | ||
const { MicrosoftGovernmentAppCredentials, GovernmentConstants } = require('../..'); | ||
const assert = require('assert'); | ||
|
||
describe('MicrosoftGovernmentAppCredentialsTestSuite', function () { | ||
describe('MicrosoftGovernmentAppCredentialsTestCase', function () { | ||
it('AssertOAuthEndpointAndOAuthScope', function() { | ||
var credentials = new MicrosoftGovernmentAppCredentials("appId", "password", "tenantId", "audience"); | ||
assert.strictEqual(GovernmentConstants.ToChannelFromBotLoginUrlPrefix + "tenantId", credentials.oAuthEndpoint); | ||
assert.strictEqual("audience", credentials.oAuthScope); | ||
|
||
var credentials = new MicrosoftGovernmentAppCredentials("appId", "password"); | ||
assert.strictEqual(GovernmentConstants.ToChannelFromBotLoginUrlPrefix + GovernmentConstants.DefaultChannelAuthTenant, credentials.oAuthEndpoint); | ||
assert.strictEqual(GovernmentConstants.ToChannelFromBotOAuthScope, credentials.oAuthScope); | ||
}); | ||
|
||
}); | ||
}); |