public async Task OnResourceExecutionAsync_IntentVerificationRequest_DoesNotCallNext(string mode) { ResourceExecutingContext resourceExecutingContext = PrepareIntentVerificatioResourceExecutingContext(mode: mode); Mock <ResourceExecutionDelegate> resourceExecutionDelegateMock = new Mock <ResourceExecutionDelegate>(); WebSubWebHookIntentVerificationFilter webSubWebHookIntentVerificationFilter = PrepareWebSubWebHookIntentVerificationFilter(); await webSubWebHookIntentVerificationFilter.OnResourceExecutionAsync(resourceExecutingContext, resourceExecutionDelegateMock.Object); resourceExecutionDelegateMock.Verify(m => m(), Times.Never); }
public async Task OnResourceExecutionAsync_IntentVerificationRequestWithoutModeParameter_CallsNext() { ResourceExecutingContext resourceExecutingContext = PrepareIntentVerificatioResourceExecutingContext(mode: null); Mock <ResourceExecutionDelegate> resourceExecutionDelegateMock = new Mock <ResourceExecutionDelegate>(); WebSubWebHookIntentVerificationFilter webSubWebHookIntentVerificationFilter = PrepareWebSubWebHookIntentVerificationFilter(); await webSubWebHookIntentVerificationFilter.OnResourceExecutionAsync(resourceExecutingContext, resourceExecutionDelegateMock.Object); resourceExecutionDelegateMock.Verify(m => m(), Times.Once); }
public async Task OnResourceExecutionAsync_UnsubscribeIntentVerificationRequestForSubscriptionStateDifferentThanUnsubscribeRequested_SetsNotFoundResult(WebSubSubscriptionState webSubSubscriptionState) { ResourceExecutingContext resourceExecutingContext = PrepareIntentVerificatioResourceExecutingContext(mode: INTENT_VERIFICATION_MODE_UNSUBSCRIBE, subscription: PrepareWebSubSubscription(subscriptionState: webSubSubscriptionState)); ResourceExecutionDelegate resourceExecutionDelegate = () => Task.FromResult <ResourceExecutedContext>(null); WebSubWebHookIntentVerificationFilter webSubWebHookIntentVerificationFilter = PrepareWebSubWebHookIntentVerificationFilter(); await webSubWebHookIntentVerificationFilter.OnResourceExecutionAsync(resourceExecutingContext, resourceExecutionDelegate); Assert.IsType <NotFoundResult>(resourceExecutingContext.Result); }
public async Task OnResourceExecutionAsync_SubscribeIntentVerificationRequestForNotMatchingTopic_SetsNotFoundResult(string mode, WebSubSubscriptionState webSubSubscriptionState) { ResourceExecutingContext resourceExecutingContext = PrepareIntentVerificatioResourceExecutingContext(mode: mode, topic: OTHER_WEBSUB_ROCKS_TOPIC_URL, subscription: PrepareWebSubSubscription(subscriptionState: webSubSubscriptionState)); ResourceExecutionDelegate resourceExecutionDelegate = () => Task.FromResult <ResourceExecutedContext>(null); WebSubWebHookIntentVerificationFilter webSubWebHookIntentVerificationFilter = PrepareWebSubWebHookIntentVerificationFilter(); await webSubWebHookIntentVerificationFilter.OnResourceExecutionAsync(resourceExecutingContext, resourceExecutionDelegate); Assert.IsType <NotFoundResult>(resourceExecutingContext.Result); }
public async Task OnResourceExecutionAsync_SubscribeIntentVerificationRequestWithoutLeaseSecondsParameter_SetsBadRequestObjectResult() { ResourceExecutingContext resourceExecutingContext = PrepareIntentVerificatioResourceExecutingContext(mode: INTENT_VERIFICATION_MODE_SUBSCRIBE, leaseSeconds: null, subscription: PrepareWebSubSubscription(subscriptionState: WebSubSubscriptionState.SubscribeRequested)); ResourceExecutionDelegate resourceExecutionDelegate = () => Task.FromResult <ResourceExecutedContext>(null); WebSubWebHookIntentVerificationFilter webSubWebHookIntentVerificationFilter = PrepareWebSubWebHookIntentVerificationFilter(); await webSubWebHookIntentVerificationFilter.OnResourceExecutionAsync(resourceExecutingContext, resourceExecutionDelegate); Assert.IsType <BadRequestObjectResult>(resourceExecutingContext.Result); }
public async Task OnResourceExecutionAsync_SubscribeUnsubscribeVerificationRequestWithoutChallengeParameter_SetsBadRequestObjectResult(string mode, WebSubSubscriptionState webSubSubscriptionState) { ResourceExecutingContext resourceExecutingContext = PrepareIntentVerificatioResourceExecutingContext(mode: mode, challenge: null, subscription: PrepareWebSubSubscription(subscriptionState: webSubSubscriptionState)); ResourceExecutionDelegate resourceExecutionDelegate = () => Task.FromResult <ResourceExecutedContext>(null); WebSubWebHookIntentVerificationFilter webSubWebHookIntentVerificationFilter = PrepareWebSubWebHookIntentVerificationFilter(); await webSubWebHookIntentVerificationFilter.OnResourceExecutionAsync(resourceExecutingContext, resourceExecutionDelegate); Assert.IsType <BadRequestObjectResult>(resourceExecutingContext.Result); }
public async Task OnResourceExecutionAsync_SubscribeUnsubscribeIntentVerificationRequest_ContentResultContainsChallenge(string mode, WebSubSubscriptionState webSubSubscriptionState) { ResourceExecutingContext resourceExecutingContext = PrepareIntentVerificatioResourceExecutingContext(mode: mode, subscription: PrepareWebSubSubscription(subscriptionState: webSubSubscriptionState)); ResourceExecutionDelegate resourceExecutionDelegate = () => Task.FromResult <ResourceExecutedContext>(null); WebSubWebHookIntentVerificationFilter webSubWebHookIntentVerificationFilter = PrepareWebSubWebHookIntentVerificationFilter(); await webSubWebHookIntentVerificationFilter.OnResourceExecutionAsync(resourceExecutingContext, resourceExecutionDelegate); Assert.Equal(WEBSUB_ROCKS_CHALLENGE, (resourceExecutingContext.Result as ContentResult).Content); }
public async Task OnResourceExecutionAsync_SubscribeIntentDenyRequest_SetsNoContentResult() { ResourceExecutingContext resourceExecutingContext = PrepareIntentVerificatioResourceExecutingContext(mode: INTENT_VERIFICATION_MODE_DENIED, challenge: null, leaseSeconds: null); ResourceExecutionDelegate resourceExecutionDelegate = () => Task.FromResult <ResourceExecutedContext>(null); WebSubWebHookIntentVerificationFilter webSubWebHookIntentVerificationFilter = PrepareWebSubWebHookIntentVerificationFilter(); await webSubWebHookIntentVerificationFilter.OnResourceExecutionAsync(resourceExecutingContext, resourceExecutionDelegate); Assert.IsType <NoContentResult>(resourceExecutingContext.Result); }
public async Task OnResourceExecutionAsync_IntentVerificationRequestWithoutTopicParameter_SetsBadRequestObjectResult(string mode) { ResourceExecutingContext resourceExecutingContext = PrepareIntentVerificatioResourceExecutingContext(mode: mode, topic: null); ResourceExecutionDelegate resourceExecutionDelegate = () => Task.FromResult <ResourceExecutedContext>(null); WebSubWebHookIntentVerificationFilter webSubWebHookIntentVerificationFilter = PrepareWebSubWebHookIntentVerificationFilter(); await webSubWebHookIntentVerificationFilter.OnResourceExecutionAsync(resourceExecutingContext, resourceExecutionDelegate); Assert.IsType <BadRequestObjectResult>(resourceExecutingContext.Result); }
/// <summary> /// Instantiates a new <see cref="WebSubMetadata"/> instance. /// </summary> /// <param name="securityFilter">The <see cref="WebSubWebHookSecurityFilter"/></param> /// <param name="intentVerificationFilter">The <see cref="WebSubWebHookIntentVerificationFilter"/></param> public WebSubMetadata(WebSubWebHookSecurityFilter securityFilter, WebSubWebHookIntentVerificationFilter intentVerificationFilter) : base(WebSubConstants.ReceiverName) { _securityFilter = securityFilter; _intentVerificationFilter = intentVerificationFilter; }