Ejemplo n.º 1
0
        public async void CheckRights_Graned_Permission()
        {
            var testContext = TestContext.MockUp();

            using (var domain0Context = new AuthenticationContext(
                       domain0ClientEnvironment: testContext.ClientScopeMock.Object,
                       externalStorage: testContext.LoginInfoStorageMock.Object))
            {
                Assert.False(domain0Context.IsLoggedIn);

                var profile = await domain0Context.LoginByPhone(123, "2");

                Assert.NotNull(profile);


                Assert.True(domain0Context.HavePermission("claimsA"));
                Assert.True(domain0Context.HavePermission("claimsB"));

                Assert.True(domain0Context.HavePermissions(new[] { "claimsA", "claimsB" }));
                Assert.True(domain0Context.HavePermissions(new[] { "claimsA" }));
            }
        }
Ejemplo n.º 2
0
        public void CheckRights_ShouldFailWhenLoggedOut()
        {
            var testContext = TestContext.MockUp();

            using (var domain0Context = new AuthenticationContext(
                       domain0ClientEnvironment: testContext.ClientScopeMock.Object,
                       externalStorage: testContext.LoginInfoStorageMock.Object))
            {
                Assert.False(domain0Context.IsLoggedIn);

                Assert.Throws <AuthenticationContextException>(
                    () => domain0Context.HavePermission("p"));
            }
        }