Exemplo n.º 1
0
        public async Task RemoteAuthenticationService_SignIn_DoesNotUpdateUserOnOtherResult(RemoteAuthenticationStatus value)
        {
            // Arrange
            var testJsRuntime = new TestJsRuntime();
            var options       = CreateOptions();
            var runtime       = new RemoteAuthenticationService <RemoteAuthenticationState, RemoteUserAccount, OidcProviderOptions>(
                testJsRuntime,
                options,
                new TestNavigationManager(),
                new AccountClaimsPrincipalFactory <RemoteUserAccount>(Mock.Of <IAccessTokenProviderAccessor>()));

            var state = new RemoteAuthenticationState();

            testJsRuntime.SignInResult = new InternalRemoteAuthenticationResult <RemoteAuthenticationState>
            {
                Status = value.ToString()
            };

            // Act
            await runtime.SignInAsync(new RemoteAuthenticationContext <RemoteAuthenticationState> {
                State = state
            });

            // Assert
            Assert.Equal(
                new[] { "AuthenticationService.init", "AuthenticationService.signIn" },
                testJsRuntime.PastInvocations.Select(i => i.identifier).ToArray());
        }
Exemplo n.º 2
0
    public async Task RemoteAuthenticationService_CompleteSignOutAsync_DoesNotUpdateUserOnOtherResult(RemoteAuthenticationStatus value)
    {
        // Arrange
        var testJsRuntime = new TestJsRuntime();
        var options       = CreateOptions();
        var runtime       = new RemoteAuthenticationService <RemoteAuthenticationState, RemoteUserAccount, OidcProviderOptions>(
            testJsRuntime,
            options,
            new TestNavigationManager(),
            new AccountClaimsPrincipalFactory <RemoteUserAccount>(Mock.Of <IAccessTokenProviderAccessor>()),
            null);

        var state = new RemoteAuthenticationState();

        testJsRuntime.CompleteSignOutResult = new RemoteAuthenticationResult <RemoteAuthenticationState>
        {
            Status = value
        };

        // Act
        await runtime.CompleteSignOutAsync(new RemoteAuthenticationContext <RemoteAuthenticationState> {
            Url = "https://www.example.com/base/login-callback"
        });

        // Assert
        Assert.Equal(
            new[] { "AuthenticationService.init", "AuthenticationService.completeSignOut" },
            testJsRuntime.PastInvocations.Select(i => i.identifier).ToArray());
    }