public virtual async Task Should_Handle_By_Cookie_AuthenticationScheme_For_AbpAuthorizationException()
    {
        var result = await GetResponseAsync("/api/exception-test/AbpAuthorizationException", HttpStatusCode.Redirect);

        result.Headers.Location.ToString().ShouldContain("http://localhost/Account/Login");

#pragma warning disable 4014
        FakeExceptionSubscriber
        .Received()
        .HandleAsync(Arg.Any <ExceptionNotificationContext>());
#pragma warning restore 4014


        FakeRequiredService.Claims.AddRange(new[]
        {
            new Claim(AbpClaimTypes.UserId, Guid.NewGuid().ToString())
        });

        result = await GetResponseAsync("/api/exception-test/AbpAuthorizationException", HttpStatusCode.Redirect);

        result.Headers.Location.ToString().ShouldContain("http://localhost/Account/AccessDenied");

#pragma warning disable 4014
        FakeExceptionSubscriber
        .Received()
        .HandleAsync(Arg.Any <ExceptionNotificationContext>());
#pragma warning restore 4014
    }
예제 #2
0
    public async Task Should_Return_RemoteServiceErrorResponse_For_UserFriendlyException_For_Void_Return_Value()
    {
        var result = await GetResponseAsObjectAsync <RemoteServiceErrorResponse>("/api/exception-test/UserFriendlyException1", HttpStatusCode.Forbidden);

        result.Error.ShouldNotBeNull();
        result.Error.Message.ShouldBe("This is a sample exception!");

#pragma warning disable 4014
        _fakeExceptionSubscriber
        .Received()
        .HandleAsync(Arg.Any <ExceptionNotificationContext>());
#pragma warning restore 4014
    }