Exemplo n.º 1
0
        public async Task TestRevokeAsync()
        {
            var store         = new ConsentStore();
            var insertClients = await CassandraTestHelper.InsertTestData_Clients(2);

            // we are going to associate a bunch of tokens to this one client
            var subject = Guid.NewGuid().ToString();

            foreach (var client in insertClients)
            {
                await CassandraTestHelper.InsertTestData_Consents(client.ClientId, subject, 1);
            }

            var result = await store.LoadAllAsync(subject);

            Assert.AreEqual(2, result.Count());

            foreach (var client in insertClients)
            {
                await store.RevokeAsync(subject, client.ClientId);
            }
            result = await store.LoadAllAsync(subject);

            Assert.AreEqual(0, result.Count());
        }
        public async Task RevokeAsync()
        {
            //Arrange
            var sut             = new ConsentStore(NhibernateSession);
            var testConsent1    = ObjectCreator.GetConsent();
            var testConsent2    = ObjectCreator.GetConsent();
            var testConsent3    = ObjectCreator.GetConsent();
            var consentToRevoke = ObjectCreator.GetConsent();

            ExecuteInTransaction(session =>
            {
                session.Save(testConsent1);
                session.Save(testConsent2);
                session.Save(testConsent3);
                session.Save(consentToRevoke);
            });

            //Act
            await sut.RevokeAsync(consentToRevoke.Subject, consentToRevoke.ClientId);

            //Assert
            var revokedConsent = await sut.LoadAsync(consentToRevoke.Subject, consentToRevoke.ClientId);

            Assert.Null(revokedConsent);

            //CleanUp
            ExecuteInTransaction(session =>
            {
                session.Delete(testConsent1);
                session.Delete(testConsent2);
                session.Delete(testConsent3);
            });
        }
        public void TestRevokeAsync()
        {
            var result = _consentStore.LoadAllAsync("SUBJECT:0");

            Assert.AreEqual(result.Result.Count(), 10);
            foreach (var item in result.Result)
            {
                Assert.AreEqual(item.Subject, "SUBJECT:0");
            }
            _consentStore.RevokeAsync("SUBJECT:0", "CLIENTID:0");

            result = _consentStore.LoadAllAsync("SUBJECT:0");
            Assert.AreEqual(result.Result.Count(), 9);
            foreach (var item in result.Result)
            {
                Assert.AreEqual(item.Subject, "SUBJECT:0");
            }
        }