Esempio n. 1
0
            public void ReturnsAccessRestrictedWhenTheCurrentVersionOfTheAppIsOutdated()
            {
                AccessRestrictionStorage.IsClientOutdated().Returns(true);

                var accessLevel = App.GetAccessLevel();

                accessLevel.Should().Be(AccessLevel.AccessRestricted);
            }
Esempio n. 2
0
            public void ReturnsAccessRestrictedWhenTheTokenWasRevokedAndTheAppIsOutdated()
            {
                AccessRestrictionStorage.IsUnauthorized(Arg.Any <string>()).Returns(true);
                AccessRestrictionStorage.IsClientOutdated().Returns(true);

                var accessLevel = App.GetAccessLevel();

                accessLevel.Should().Be(AccessLevel.AccessRestricted);
            }
Esempio n. 3
0
            public async Task ShowsTheOutdatedViewIfTheCurrentVersionOfTheAppIsOutdated()
            {
                AccessRestrictionStorage.IsClientOutdated().Returns(true);

                AppStart.Start();

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

                UserAccessManager.DidNotReceive().CheckIfLoggedIn();
            }
Esempio n. 4
0
            public async Task ShowsTheOutdatedViewIfTheCurrentVersionOfTheAppIsOutdated()
            {
                AccessRestrictionStorage.IsClientOutdated().Returns(true);

                AppStart.Start();

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

                UserAccessManager.DidNotReceive().TryInitializingAccessToUserData(out _, out _);
            }
Esempio n. 5
0
            public async Task ShowsTheOutdatedViewIfTheTokenWasRevokedAndTheAppIsOutdated()
            {
                AccessRestrictionStorage.IsUnauthorized(Arg.Any <string>()).Returns(true);
                AccessRestrictionStorage.IsClientOutdated().Returns(true);

                AppStart.Start();

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

                UserAccessManager.DidNotReceive().CheckIfLoggedIn();
            }
Esempio n. 6
0
            public async Task ShowsTheOutdatedViewIfTheCurrentVersionOfTheAppIsOutdated()
            {
                AccessRestrictionStorage.IsClientOutdated().Returns(true);

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

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

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

                LoginManager.DidNotReceive().GetDataSourceIfLoggedIn();
            }
Esempio n. 7
0
            public async Task ShowsTheOutdatedViewIfTheTokenWasRevokedAndTheAppIsOutdated()
            {
                AccessRestrictionStorage.IsUnauthorized(Arg.Any <string>()).Returns(true);
                AccessRestrictionStorage.IsClientOutdated().Returns(true);

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

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

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

                LoginManager.DidNotReceive().GetDataSourceIfLoggedIn();
            }
Esempio n. 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>();
            }
Esempio n. 9
0
            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);
            }
Esempio n. 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>();
            }