public void Should_be_able_to_set_arbitrary_permissions() { var permissions = permissionInfo.SetConfigure("abc").SetRead("def").SetWrite("xyz"); permissions.Configure.ShouldEqual("abc"); permissions.Write.ShouldEqual("xyz"); permissions.Read.ShouldEqual("def"); }
/// <summary> /// Создание <see cref="PermissionInfo"/> для разрешения в RabbitMQ. /// </summary> /// <param name="user">Пользователь RabbitMQ.</param> /// <param name="write">Разрешение на отправку сообщений.</param> /// <param name="read">Разрешение на чтение сообщений.</param> /// <param name="configure">Разрешение возможности конфигурирования.</param> /// <returns>Информацию о разрешении.</returns> private PermissionInfo CreatePermissionInfo(User user, string write = "^$", string read = "^$", string configure = "^$") { PermissionInfo permissionInfo = new PermissionInfo(user, Vhost); permissionInfo.SetWrite(write); permissionInfo.SetRead(read); permissionInfo.SetConfigure(configure); return(permissionInfo); }
protected internal override void Apply(IManagementClient managementClient) { _log.Info($"Declaring permission for user '{User}' on vhost '{VirtualHost}'"); _log.Info($" Read Regex = {ReadRegex}"); _log.Info($" WriteRegex = {WriteRegex}"); _log.Info($" ConfigureRegex = {ConfigureRegex} "); var user = managementClient.GetUser(User); var virtualHost = managementClient.GetVhost(VirtualHost); var permissionInfo = new PermissionInfo(user, virtualHost); permissionInfo.SetConfigure(ConfigureRegex); permissionInfo.SetRead(ReadRegex); permissionInfo.SetWrite(WriteRegex); managementClient.CreatePermission(permissionInfo); _log.Info($"Finished declaring permission for user '{User}' on vhost '{VirtualHost}'"); }