コード例 #1
0
        public async Task DynamoRoleStore_Delete_DeletesRole()
        {
            var roleName = TestUtils.RandomString(10);
            var role     = new DynamoIdentityRole(roleName);

            using (var dbProvider = DynamoDbServerTestUtils.CreateDatabase())
            {
                var roleStore = new DynamoRoleStore <DynamoIdentityRole>();
                await roleStore.EnsureInitializedAsync(dbProvider.Client, dbProvider.Context);

                await roleStore.CreateAsync(role, CancellationToken.None);

                await Task.Delay(2000);

                role = await roleStore.FindByIdAsync(role.Id, CancellationToken.None);

                // ACT
                await roleStore.DeleteAsync(role, CancellationToken.None);

                // ASSERT
                var result = await roleStore.FindByIdAsync(role.Id, CancellationToken.None);

                Assert.Null(result);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: cmsd2/oidc
        public async Task RemoveRole(string roleName, CancellationToken cancellationToken = default(CancellationToken))
        {
            var role = await roleStore.FindByNameAsync(keyNormalizer.Normalize(roleName), cancellationToken);

            if (role == null)
            {
                throw new Exception($"role named {roleName} not found");
            }

            await roleStore.DeleteAsync(role, cancellationToken);
        }