/// <summary> /// Delete a permission /// </summary> /// <param name="source"></param> /// <param name="permission">The permission to delete</param> /// <param name="cancellationToken"></param> public static void DeletePermission( [NotNull] this IManagementClient source, [NotNull] Permission permission, CancellationToken cancellationToken = default ) { if (source == null) { throw new ArgumentNullException(nameof(source)); } source.DeletePermissionAsync(permission, cancellationToken) .GetAwaiter() .GetResult(); }
public async Task Should_be_able_to_delete_permissions() { var userInfo = new UserInfo(testUser, "topSecret").AddTag("monitoring").AddTag("management"); var user = await managementClient.CreateUserAsync(userInfo).ConfigureAwait(false); var vhost = await managementClient.CreateVhostAsync(testVHost).ConfigureAwait(false); var permissionInfo = new PermissionInfo(user, vhost); await managementClient.CreatePermissionAsync(permissionInfo).ConfigureAwait(false); var permission = (await managementClient.GetPermissionsAsync().ConfigureAwait(false)) .SingleOrDefault(x => x.User == testUser && x.Vhost == testVHost); if (permission == null) { throw new EasyNetQTestException(string.Format("No permission for vhost: {0} and user: {1}", testVHost, testUser)); } await managementClient.DeletePermissionAsync(permission).ConfigureAwait(false); }