Пример #1
0
        public AuthorizationCodeSerializationTests(PersistenceTestFixture data) : base(data)
        {
            var key = "AuthorizationCodeTests";

            _expected = TestData.AuthorizationCode();

            _setup = Setup(key);
        }
Пример #2
0
        private async Task Setup(string key)
        {
            await SaveAsync(_expected.Client);

            foreach (var scope in _expected.RequestedScopes)
            {
                await SaveAsync(scope);
            }
            var store = Factory.Resolve <IAuthorizationCodeStore>();
            await store.StoreAsync(key, TestData.AuthorizationCode());

            await store.StoreAsync(key + "NoNonce", TestData.AuthorizationCodeWithoutNonce());

            _actual = await store.GetAsync(key);

            _actualNoNonce = await store.GetAsync(key + "NoNonce");
        }
        private async Task Setup(List <AuthorizationCode> subjectACodes, List <AuthorizationCode> subjectBCodes, List <AuthorizationCode> subjectCCodes)
        {
            List <Task> tasks = new List <Task>();

            tasks.Add(_authorizationStore.StoreAsync(RemoveKey, TestData.AuthorizationCode()));
            tasks.Add(_authorizationStore.StoreAsync(NotRemovedKey, TestData.AuthorizationCode()));
            foreach (var scope in TestData.Scopes())
            {
                tasks.Add(SaveAsync(scope));
            }
            for (int i = 0; i < 10; i++)
            {
                var code = TestData.AuthorizationCode(SubjectA);
                code.Client.ClientId = "notRevoked";
                code.Nonce           = "anr" + i;
                tasks.Add(_authorizationStore.StoreAsync("notRevokedA" + i, code));
                subjectACodes.Add(code);
                tasks.Add(SaveAsync(code.Client));
            }

            for (int i = 0; i < 10; i++)
            {
                var code = TestData.AuthorizationCode(SubjectB);
                code.Client.ClientId = "notRevoked";
                code.Nonce           = "anr" + i;
                tasks.Add(_authorizationStore.StoreAsync("notRevokedB" + i, code));
                subjectBCodes.Add(code);

                tasks.Add(SaveAsync(code.Client));
            }

            for (int i = 0; i < 10; i++)
            {
                var code = TestData.AuthorizationCode(SubjectB);
                code.Client.ClientId = "revoked";
                code.Nonce           = "ar" + i;
                tasks.Add(_authorizationStore.StoreAsync("revokedB" + i, code));
                subjectBCodes.Add(code);

                tasks.Add(SaveAsync(code.Client));
            }
            for (int i = 0; i < 10; i++)
            {
                var code = TestData.AuthorizationCode(SubjectC);
                code.Client.ClientId = "notRevoked";
                code.Nonce           = "anr" + i;
                tasks.Add(_authorizationStore.StoreAsync("notRevokedC" + i, code));
                subjectCCodes.Add(code);

                tasks.Add(SaveAsync(code.Client));
            }

            for (int i = 0; i < 10; i++)
            {
                var code = TestData.AuthorizationCode(SubjectC);
                code.Client.ClientId = "revoked";
                code.Nonce           = "ar" + i;
                tasks.Add(_authorizationStore.StoreAsync("revokedC" + i, code));
                subjectCCodes.Add(code);
                tasks.Add(SaveAsync(code.Client));
            }

            await Task.WhenAll(tasks);
        }