Skip to content

Commit

Permalink
fix js lint
Browse files Browse the repository at this point in the history
  • Loading branch information
fangyangci committed Dec 19, 2023
1 parent c33ec8a commit 1bf5c80
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 35 deletions.
20 changes: 14 additions & 6 deletions libraries/botbuilder/src/botFrameworkAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ export class BotFrameworkAdapter
this.settings.appPassword || '',
this.settings.channelAuthTenant
);
}
else{
} else {
this.credentials = new MicrosoftAppCredentials(
this.settings.appId,
this.settings.appPassword || '',
Expand Down Expand Up @@ -1634,10 +1633,19 @@ export class BotFrameworkAdapter
);
} else {
if (JwtTokenValidation.isGovernment(this.settings.channelService)) {
credentials = new MicrosoftGovernmentAppCredentials(appId, appPassword, this.settings.channelAuthTenant, oAuthScope);
}
else{
credentials = new MicrosoftAppCredentials(appId, appPassword, this.settings.channelAuthTenant, oAuthScope);
credentials = new MicrosoftGovernmentAppCredentials(
appId,
appPassword,
this.settings.channelAuthTenant,
oAuthScope
);
} else {
credentials = new MicrosoftAppCredentials(
appId,
appPassword,
this.settings.channelAuthTenant,
oAuthScope
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/botbuilder/src/botFrameworkHttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ICredentialProvider,
JwtTokenValidation,
MicrosoftAppCredentials,
MicrosoftGovernmentAppCredentials
MicrosoftGovernmentAppCredentials,
} from 'botframework-connector';

import { USER_AGENT } from './botFrameworkAdapter';
Expand Down
10 changes: 2 additions & 8 deletions libraries/botframework-connector/src/auth/appCredentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,11 @@ export abstract class AppCredentials implements ServiceClientCredentials {
* @param channelAuthTenant Optional. The oauth token tenant.
* @param oAuthScope The scope for the token.
*/
constructor(
appId: string,
channelAuthTenant?: string,
oAuthScope: string = null
) {
constructor(appId: string, channelAuthTenant?: string, oAuthScope: string = null) {
this.appId = appId;
this.tenant = channelAuthTenant;
this.oAuthEndpoint = this.GetToChannelFromBotLoginUrlPrefix() + this.tenant;
this.oAuthScope = (oAuthScope && oAuthScope.length > 0)
? oAuthScope
: this.GetToChannelFromBotOAuthScope();
this.oAuthScope = oAuthScope && oAuthScope.length > 0 ? oAuthScope : this.GetToChannelFromBotOAuthScope();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ 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);
});
it('AssertOAuthEndpointAndOAuthScope', function () {
const credentials1 = new MicrosoftAppCredentials('appId', 'password', 'tenantId', 'audience');
assert.strictEqual(
AuthenticationConstants.ToChannelFromBotLoginUrlPrefix + 'tenantId',
credentials1.oAuthEndpoint
);
assert.strictEqual('audience', credentials1.oAuthScope);

const credentials2 = new MicrosoftAppCredentials('appId', 'password');
assert.strictEqual(
AuthenticationConstants.ToChannelFromBotLoginUrlPrefix +
AuthenticationConstants.DefaultChannelAuthTenant,
credentials2.oAuthEndpoint
);
assert.strictEqual(AuthenticationConstants.ToChannelFromBotOAuthScope, credentials2.oAuthScope);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ 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);
});
it('AssertOAuthEndpointAndOAuthScope', function () {
const credentials1 = new MicrosoftGovernmentAppCredentials('appId', 'password', 'tenantId', 'audience');
assert.strictEqual(
GovernmentConstants.ToChannelFromBotLoginUrlPrefix + 'tenantId',
credentials1.oAuthEndpoint
);
assert.strictEqual('audience', credentials1.oAuthScope);

const credentials2 = new MicrosoftGovernmentAppCredentials('appId', 'password');
assert.strictEqual(
GovernmentConstants.ToChannelFromBotLoginUrlPrefix + GovernmentConstants.DefaultChannelAuthTenant,
credentials2.oAuthEndpoint
);
assert.strictEqual(GovernmentConstants.ToChannelFromBotOAuthScope, credentials2.oAuthScope);
});
});
});

0 comments on commit 1bf5c80

Please sign in to comment.