public void Should_be_able_to_create_permissions() { var user = managementClient.GetUsers().SingleOrDefault(x => x.Name == testUser); if (user == null) { throw new ApplicationException(string.Format("user '{0}' hasn't been created", testUser)); } var vhost = managementClient.GetVHosts().SingleOrDefault(x => x.Name == testVHost); if (vhost == null) { throw new ApplicationException(string.Format("Test vhost: '{0}' has not been created", testVHost)); } var permissionInfo = new PermissionInfo(user, vhost); managementClient.CreatePermission(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}'"); }