CR feedback
This commit is contained in:
Родитель
d92a398386
Коммит
c97b4ffb58
|
@ -349,7 +349,6 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
|
||||
if (turnContext.TurnState.Get<ClaimsIdentity>("BotIdentity") is ClaimsIdentity botIdentity && SkillValidation.IsSkillClaim(botIdentity.Claims))
|
||||
{
|
||||
// Force magic code for Skills (to be addressed in R8)
|
||||
cardActionType = ActionTypes.OpenUrl;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -829,11 +829,6 @@ namespace Microsoft.Bot.Builder
|
|||
|
||||
var activity = turnContext.Activity;
|
||||
|
||||
if (!userId.Equals(activity.From?.Id))
|
||||
{
|
||||
throw new ArgumentException("cannot retrieve OAuth signin link for a user that's different from the conversation");
|
||||
}
|
||||
|
||||
var appId = GetBotAppId(turnContext);
|
||||
var tokenExchangeState = new TokenExchangeState()
|
||||
{
|
||||
|
@ -1039,11 +1034,6 @@ namespace Microsoft.Bot.Builder
|
|||
|
||||
var activity = turnContext.Activity;
|
||||
|
||||
if (!userId.Equals(activity.From?.Id))
|
||||
{
|
||||
throw new ArgumentException("Cannot get signin resource for a user that's different from the conversation.");
|
||||
}
|
||||
|
||||
var appId = GetBotAppId(turnContext);
|
||||
var tokenExchangeState = new TokenExchangeState()
|
||||
{
|
||||
|
@ -1121,11 +1111,6 @@ namespace Microsoft.Bot.Builder
|
|||
|
||||
var activity = turnContext.Activity;
|
||||
|
||||
if (!userId.Equals(activity.From?.Id))
|
||||
{
|
||||
throw new ArgumentException("Cannot exchange token for a user that's different from the conversation.");
|
||||
}
|
||||
|
||||
var client = await CreateOAuthApiClientAsync(turnContext, oAuthAppCredentials).ConfigureAwait(false);
|
||||
var result = await client.ExchangeAsyncAsync(userId, connectionName, turnContext.Activity.ChannelId, exchangeRequest, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
|
|
|
@ -125,7 +125,6 @@ namespace Microsoft.Bot.Builder
|
|||
/// <remarks>If the task completes successfully, the result contains the raw signin link.</remarks>
|
||||
Task<SignInResource> GetSignInResourceAsync(ITurnContext turnContext, AppCredentials oAuthAppCredentials, string connectionName, string userId, string finalRedirect = null, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Performs a token exchange operation such as for single sign-on.
|
||||
/// </summary>
|
||||
|
@ -150,6 +149,5 @@ namespace Microsoft.Bot.Builder
|
|||
/// or threads to receive notice of cancellation.</param>
|
||||
/// <returns>If the task completes, the exchanged token is returned.</returns>
|
||||
Task<TokenResponse> ExchangeTokenAsync(ITurnContext turnContext, AppCredentials oAuthAppCredentials, string connectionName, string userId, TokenExchangeRequest exchangeRequest, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Tests
|
|||
[TestClass]
|
||||
public class OAuthPromptTests
|
||||
{
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void OAuthPromptWithEmptySettingsShouldFail()
|
||||
{
|
||||
var confirmPrompt = new OAuthPrompt("abc", null);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void OAuthPromptWithEmptyIdShouldFail()
|
||||
|
@ -29,6 +36,36 @@ namespace Microsoft.Bot.Builder.Dialogs.Tests
|
|||
await OAuthPrompt(new MemoryStorage());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public async Task OAuthPromptBeginDialogWithNoDialogContext()
|
||||
{
|
||||
var prompt = new OAuthPrompt("abc", new OAuthPromptSettings());
|
||||
await prompt.BeginDialogAsync(null);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public async Task OAuthPromptBeginDialogWithWrongOptions()
|
||||
{
|
||||
var prompt = new OAuthPrompt("abc", new OAuthPromptSettings());
|
||||
var convoState = new ConversationState(new MemoryStorage());
|
||||
var dialogState = convoState.CreateProperty<DialogState>("dialogState");
|
||||
|
||||
var adapter = new TestAdapter()
|
||||
.Use(new AutoSaveStateMiddleware(convoState));
|
||||
|
||||
// Create new DialogSet.
|
||||
var dialogs = new DialogSet(dialogState);
|
||||
dialogs.Add(prompt);
|
||||
|
||||
var tc = new TurnContext(adapter, new Activity() { Type = ActivityTypes.Message, Conversation = new ConversationAccount() { Id = "123" }, ChannelId = "test" });
|
||||
|
||||
var dc = await dialogs.CreateContextAsync(tc);
|
||||
|
||||
await prompt.BeginDialogAsync(dc, CancellationToken.None);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
public async Task OAuthPromptWithNoneTypeHandlingForStorage()
|
||||
|
|
|
@ -326,6 +326,48 @@ namespace Microsoft.Bot.Builder.Tests
|
|||
Assert.AreEqual("OnEventAsync", bot.Record[1]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TestInvokeAsync()
|
||||
{
|
||||
// Arrange
|
||||
var activity = new Activity
|
||||
{
|
||||
Type = ActivityTypes.Invoke,
|
||||
Name = "some.random.invoke",
|
||||
};
|
||||
var turnContext = new TurnContext(new NotImplementedAdapter(), activity);
|
||||
|
||||
// Act
|
||||
var bot = new TestActivityHandler();
|
||||
await ((IBot)bot).OnTurnAsync(turnContext);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(2, bot.Record.Count);
|
||||
Assert.AreEqual("OnInvokeActivityAsync", bot.Record[0]);
|
||||
Assert.AreEqual("OnInvokeAsync", bot.Record[1]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TestSignInInvokeAsync()
|
||||
{
|
||||
// Arrange
|
||||
var activity = new Activity
|
||||
{
|
||||
Type = ActivityTypes.Invoke,
|
||||
Name = SignInConstants.VerifyStateOperationName,
|
||||
};
|
||||
var turnContext = new TurnContext(new NotImplementedAdapter(), activity);
|
||||
|
||||
// Act
|
||||
var bot = new TestActivityHandler();
|
||||
await ((IBot)bot).OnTurnAsync(turnContext);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(2, bot.Record.Count);
|
||||
Assert.AreEqual("OnInvokeActivityAsync", bot.Record[0]);
|
||||
Assert.AreEqual("OnSignInInvokeAsync", bot.Record[1]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TestEventNullNameAsync()
|
||||
{
|
||||
|
@ -504,6 +546,24 @@ namespace Microsoft.Bot.Builder.Tests
|
|||
Record.Add(MethodBase.GetCurrentMethod().Name);
|
||||
return base.OnUnrecognizedActivityTypeAsync(turnContext, cancellationToken);
|
||||
}
|
||||
|
||||
protected override Task OnInvokeAsync(ITurnContext<IInvokeActivity> turnContext, CancellationToken cancellationToken)
|
||||
{
|
||||
Record.Add(MethodBase.GetCurrentMethod().Name);
|
||||
return base.OnInvokeAsync(turnContext, cancellationToken);
|
||||
}
|
||||
|
||||
protected override Task OnInvokeActivityAsync(ITurnContext<IInvokeActivity> turnContext, CancellationToken cancellationToken)
|
||||
{
|
||||
Record.Add(MethodBase.GetCurrentMethod().Name);
|
||||
return base.OnInvokeActivityAsync(turnContext, cancellationToken);
|
||||
}
|
||||
|
||||
protected override Task OnSignInInvokeAsync(ITurnContext<IInvokeActivity> turnContext, CancellationToken cancellationToken)
|
||||
{
|
||||
Record.Add(MethodBase.GetCurrentMethod().Name);
|
||||
return base.OnSignInInvokeAsync(turnContext, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
private class TestDelegatingTurnContextActivityHandler : ActivityHandler
|
||||
|
|
Загрузка…
Ссылка в новой задаче