Exemplo n.º 1
0
        private async Task Setup()
        {
            var store = Factory.Resolve <ITokenHandleStore>();

            await SaveAsync(TestData.ClientAllProperties());

            var key = GetType().Name;
            await store.StoreAsync(key, TestData.Token());

            _actual = await store.GetAsync(key);
        }
Exemplo n.º 2
0
        private Task Setup(List <Token> subjectATokens, List <Token> subjectBTokens, List <Token> subjectCTokens)
        {
            List <Task> tasks   = new List <Task>();
            var         removed = TestData.Token(SubjectA);

            removed.Client.ClientId = removed.ClientId + 0;
            tasks.Add(SaveAsync(removed.Client));

            tasks.Add(_store.StoreAsync(RemovedKey, removed));
            var notRemoved = TestData.Token(SubjectA);

            notRemoved.Client.ClientId = notRemoved.ClientId + 1;
            tasks.Add(SaveAsync(notRemoved.Client));
            tasks.Add(_store.StoreAsync(NotRemovedKey, notRemoved));

            subjectATokens.Add(removed);
            subjectATokens.Add(notRemoved);

            foreach (var subjectConfig in new[]
            {
                new { subject = SubjectB, tokens = subjectBTokens },
                new { subject = SubjectC, tokens = subjectCTokens }
            })
            {
                for (int i = 0; i < 10; i++)
                {
                    var token = TestData.Token(subjectConfig.subject);
                    token.CreationTime = token.CreationTime.AddDays(i);
                    if (i % 2 == 0)
                    {
                        token.Client.ClientId = RevokedClient;
                    }
                    else
                    {
                        token.Client.ClientId = NotRevokedClient;
                    }
                    tasks.Add(SaveAsync(token.Client));
                    tasks.Add(_store.StoreAsync(subjectConfig.subject + i, token));
                    subjectConfig.tokens.Add(token);
                }
            }

            return(Task.WhenAll(tasks));
        }
Exemplo n.º 3
0
 public TokenHandlePersistenceTests(PersistenceTestFixture data)
     : base(data)
 {
     _expected = TestData.Token();
     _setup    = Setup();
 }