public void ReturnsAccessRestrictedWhenTheVersionOfTheCurrentlyUsedApiIsOutdated()
            {
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                var accessLevel = App.GetAccessLevel();

                accessLevel.Should().Be(AccessLevel.AccessRestricted);
            }
            public void ReturnsAccessRestrictedWhenTheTokenWasRevokedAndTheApiIsOutdated()
            {
                AccessRestrictionStorage.IsUnauthorized(Arg.Any <string>()).Returns(true);
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                var accessLevel = App.GetAccessLevel();

                accessLevel.Should().Be(AccessLevel.AccessRestricted);
            }
Example #3
0
            public async Task ShowsTheOutdatedViewIfTheVersionOfTheCurrentlyUsedApiIsOutdated()
            {
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                AppStart.Start();

                await NavigationService.Received().Navigate <OutdatedAppViewModel>();

                UserAccessManager.DidNotReceive().CheckIfLoggedIn();
            }
Example #4
0
            public async Task ShowsTheOutdatedViewIfTheVersionOfTheCurrentlyUsedApiIsOutdated()
            {
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                AppStart.Start();

                await NavigationService.Received().Navigate <OutdatedAppViewModel>();

                UserAccessManager.DidNotReceive().TryInitializingAccessToUserData(out _, out _);
            }
Example #5
0
            public async Task ShowsTheOutdatedViewIfTheVersionOfTheCurrentlyUsedApiIsOutdated()
            {
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                await Task.Run(() => AppStart.Start());

                await NavigationService.Received().Navigate <OnboardingViewModel>();

                await NavigationService.Received().Navigate <OutdatedAppViewModel>();

                LoginManager.DidNotReceive().GetDataSourceIfLoggedIn();
            }
Example #6
0
            public async Task ShowsTheOutdatedViewIfTheTokenWasRevokedAndTheApiIsOutdated()
            {
                AccessRestrictionStorage.IsUnauthorized(Arg.Any <string>()).Returns(true);
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                AppStart.Start();

                await NavigationService.Received().Navigate <OutdatedAppViewModel>();

                await NavigationService.DidNotReceive().Navigate <TokenResetViewModel>();

                UserAccessManager.DidNotReceive().CheckIfLoggedIn();
            }
Example #7
0
            public async Task ShowsTheOutdatedViewIfTheTokenWasRevokedAndTheApiIsOutdated()
            {
                AccessRestrictionStorage.IsUnauthorized(Arg.Any <string>()).Returns(true);
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                await Task.Run(() => AppStart.Start());

                await NavigationService.Received().Navigate <OnboardingViewModel>();

                await NavigationService.Received().Navigate <OutdatedAppViewModel>();

                await NavigationService.DidNotReceive().Navigate <TokenResetViewModel>();

                LoginManager.DidNotReceive().GetDataSourceIfLoggedIn();
            }
Example #8
0
            public async Task DoesNotShowTheUnauthorizedAccessViewIfUsersApiTokenChanged()
            {
                var oldApiToken       = Guid.NewGuid().ToString();
                var newApiToken       = Guid.NewGuid().ToString();
                var user              = Substitute.For <IThreadSafeUser>();
                var interactorFactory = Substitute.For <IInteractorFactory>();

                user.ApiToken.Returns(newApiToken);
                interactorFactory.GetCurrentUser().Execute().Returns(Observable.Return(user));
                AccessRestrictionStorage.IsUnauthorized(Arg.Is(oldApiToken)).Returns(true);
                AccessRestrictionStorage.IsApiOutdated().Returns(false);
                AccessRestrictionStorage.IsClientOutdated().Returns(false);

                AppStart.Start();

                await NavigationService.Received().Navigate <MainTabBarViewModel>();
            }
            public void ReturnsLoggedInWhenUsersApiTokenChanged()
            {
                var oldApiToken       = Guid.NewGuid().ToString();
                var newApiToken       = Guid.NewGuid().ToString();
                var user              = Substitute.For <IThreadSafeUser>();
                var interactorFactory = Substitute.For <IInteractorFactory>();

                user.ApiToken.Returns(newApiToken);
                interactorFactory.GetCurrentUser().Execute().Returns(Observable.Return(user));
                AccessRestrictionStorage.IsUnauthorized(Arg.Is(oldApiToken)).Returns(true);
                AccessRestrictionStorage.IsApiOutdated().Returns(false);
                AccessRestrictionStorage.IsClientOutdated().Returns(false);

                var accessLevel = App.GetAccessLevel();

                accessLevel.Should().Be(AccessLevel.LoggedIn);
            }
Example #10
0
            public async Task DoesNotShowTheUnauthorizedAccessViewIfUsersApiTokenChanged()
            {
                var oldApiToken = Guid.NewGuid().ToString();
                var newApiToken = Guid.NewGuid().ToString();
                var user        = Substitute.For <IThreadSafeUser>();
                var dataSource  = Substitute.For <ITogglDataSource>();
                var userSource  = Substitute.For <IUserSource>();

                user.ApiToken.Returns(newApiToken);
                userSource.Current.Returns(Observable.Return(user));
                dataSource.User.Returns(userSource);
                LoginManager.GetDataSourceIfLoggedIn().Returns(dataSource);
                AccessRestrictionStorage.IsUnauthorized(Arg.Is(oldApiToken)).Returns(true);
                AccessRestrictionStorage.IsApiOutdated().Returns(false);
                AccessRestrictionStorage.IsClientOutdated().Returns(false);

                await Task.Run(() => AppStart.Start());

                await NavigationService.Received().Navigate <MainTabBarViewModel>();
            }