Esempio n. 1
0
        public async Task Test_Create_Add_Delete_IdentityProviderRestrictions_ByClientIdAsync()
        {
            var adminStore = new IdentityServer3AdminStore();
            var insert     = await CassandraTestHelper.InsertTestData_Clients(1);

            var result = await adminStore.FindClientByIdAsync(insert[0].ClientId);

            Assert.IsNotNull(result);
            var originalIdentityProviderRestrictions = result.IdentityProviderRestrictions;

            Assert.AreEqual(insert[0].ClientName, result.ClientName);

            List <string> newIdentityProviderRestrictions = new List <string>()
            {
                Guid.NewGuid().ToString()
            };

            await adminStore.AddIdentityProviderRestrictionsToClientAsync(insert[0].ClientId, newIdentityProviderRestrictions);

            var finalList = new List <string>();

            finalList.AddRange(newIdentityProviderRestrictions);
            finalList.AddRange(originalIdentityProviderRestrictions);

            result = await adminStore.FindClientByIdAsync(insert[0].ClientId);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.IdentityProviderRestrictions.Count(), finalList.Count);


            var ff = result.IdentityProviderRestrictions.Except(finalList);

            Assert.IsFalse(ff.Any());


            await adminStore.DeleteIdentityProviderRestrictionsFromClientAsync(insert[0].ClientId, result.IdentityProviderRestrictions);

            result = await adminStore.FindClientByIdAsync(insert[0].ClientId);

            Assert.IsNotNull(result);

            Assert.IsFalse(result.IdentityProviderRestrictions.Any());
        }