Skip to content

Commit

Permalink
rubocop obvious cops
Browse files Browse the repository at this point in the history
- Bundler/OrderedGems
- Layout/ArrayAlignment
- Layout/ClosingHeredocIndentation
- Layout/CommentIndentation
- Layout/EmptyComment
- Layout/EmptyLineAfterGuardClause
- Layout/EmptyLineAfterMagicComment
- Layout/EmptyLineBetweenDefs
- Layout/EmptyLines
- Layout/EmptyLinesAroundAttributeAccessor
- Layout/EmptyLinesAroundBeginBody
- Layout/EmptyLinesAroundBlockBody
- Layout/EmptyLinesAroundClassBody
- Layout/EmptyLinesAroundExceptionHandlingKeywords
- Layout/EmptyLinesAroundMethodBody
- Layout/EmptyLinesAroundModuleBody
- Layout/HeredocIndentation
- Layout/IndentationStyle
- Layout/LeadingCommentSpace
- Layout/LineContinuationSpacing
- Layout/SpaceAfterComma
- Layout/SpaceAroundMethodCallOperator
- Layout/SpaceAroundOperators
- Layout/SpaceBeforeBlockBraces
- Layout/SpaceBeforeBrackets
- Layout/SpaceBeforeComma
- Layout/SpaceInsideArrayLiteralBrackets
- Layout/SpaceInsideBlockBraces
- Layout/SpaceInsideHashLiteralBraces
- Layout/SpaceInsidePercentLiteralDelimiters
- Layout/SpaceInsideStringInterpolation
- Layout/TrailingEmptyLines
- Layout/TrailingWhitespace
- Lint/AmbiguousBlockAssociation
- Lint/AmbiguousOperator
- Lint/ParenthesesAsGroupedExpression
- Lint/RedundantSplatExpansion
- Lint/RedundantStringCoercion
- Lint/SendWithMixinArgument
- Lint/SymbolConversion
- Lint/UnusedBlockArgument
- Lint/UnusedMethodArgument
- Lint/UriRegexp
- Lint/UselessAccessModifier
- Naming/BinaryOperatorParameterName
- Performance/BindCall
- Performance/BlockGivenWithExplicitBlock
- Performance/Caller
- Performance/CompareWithBlock
- Performance/ConstantRegexp
- Performance/RedundantBlockCall
- Performance/RedundantMatch
- Performance/RegexpMatch
- Performance/StringIdentifierArgument
- Performance/StringReplacement
- Rails/DurationArithmetic
- Rails/FilePath
- Rails/FindBy
- Rails/IndexBy
- Rails/PluralizationGrammar
- Rails/Presence
- Rails/Present
- Rails/RootPublicPath
- Rails/SafeNavigation
- Rails/StripHeredoc
- Rails/TopLevelHashWithIndifferentAccess
- Rails/WhereNot
- Style/Alias
- Style/ArgumentsForwarding
- Style/BarePercentLiterals
- Style/BlockComments
- Style/BlockDelimiters
- Style/CaseEquality
- Style/ClassEqualityComparison
- Style/ColonMethodCall
- Style/EachForSimpleLoop
- Style/EachWithObject
- Style/EmptyLiteral
- Style/ExpandPathArguments
- Style/ExplicitBlockArgument
- Style/FetchEnvVar
- Style/FileWrite
- Style/HashAsLastArrayItem
- Style/Lambda
- Style/MultilineMemoization
- Style/MultilineWhenThen
- Style/MultipleComparison
- Style/NestedParenthesizedCalls
- Style/NumericLiteralPrefix
- Style/OperatorMethodCall
- Style/OrAssignment
- Style/ParenthesesAroundCondition
- Style/RaiseArgs
- Style/RandomWithOffset
- Style/RedundantArrayConstructor
- Style/RedundantAssignment
- Style/RedundantCondition
- Style/RedundantConstantBase
- Style/RedundantCurrentDirectoryInPath
- Style/RedundantFileExtensionInRequire
- Style/RedundantFilterChain
- Style/RedundantFreeze
- Style/RedundantLineContinuation
- Style/RedundantParentheses
- Style/RedundantRegexpArgument
- Style/RedundantRegexpEscape
- Style/RedundantReturn
- Style/RedundantSelf
- Style/RedundantSelfAssignmentBranch
- Style/RedundantStringEscape
- Style/TrailingCommaInArguments
- Style/UnpackFirst
  • Loading branch information
Fryguy committed Feb 29, 2024
1 parent f2de531 commit 4ca12f0
Show file tree
Hide file tree
Showing 801 changed files with 3,431 additions and 2,719 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ gem "bootsnap", ">= 1.8.1", :require => false #
gem "bundler", "~> 2.1", ">= 2.1.4", "!= 2.2.10", :require => false
gem "byebug", :require => false
gem "color", "~>1.8"
gem "connection_pool", :require => false # For Dalli
gem "config", "~>2.2", ">=2.2.3", :require => false
gem "connection_pool", :require => false # For Dalli
gem "dalli", "~>3.2.3", :require => false
gem "default_value_for", "~>3.3"
gem "docker-api", "~>1.33.6", :require => false
Expand Down Expand Up @@ -61,9 +61,9 @@ gem "net-ldap", "~>0.16.1", :require => false
gem "net-ping", "~>1.7.4", :require => false
gem "openscap", "~>0.4.8", :require => false
gem "optimist", "~>3.0", :require => false
gem "psych", ">=3.1", :require => false # 3.1 safe_load changed positional to kwargs like aliases: true: https://github.com/ruby/psych/commit/4d4439d6d0adfcbd211ea295779315f1baa7dadd
gem "pg", ">=1.4.1", :require => false
gem "pg-dsn_parser", "~>0.1.1", :require => false
gem "psych", ">=3.1", :require => false # 3.1 safe_load changed positional to kwargs like aliases: true: https://github.com/ruby/psych/commit/4d4439d6d0adfcbd211ea295779315f1baa7dadd
gem "query_relation", "~>0.1.0", :require => false
gem "rack", ">=2.2.6.4", :require => false
gem "rack-attack", "~>6.5.0", :require => false
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require File.expand_path('../lib/tasks/evm_rake_helper', __FILE__)
require File.expand_path('config/application', __dir__)
require File.expand_path('lib/tasks/evm_rake_helper', __dir__)

include Rake::DSL
Vmdb::Application.load_tasks
Expand Down
1 change: 1 addition & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def connect

def find_verified_user
return reject_unauthorized_connection unless cookies[:ws_token]

userid = TokenManager.new('ws').token_get_info(cookies[:ws_token], :userid)
User.find_by(:userid => userid.presence) || reject_unauthorized_connection
end
Expand Down
9 changes: 5 additions & 4 deletions app/mailers/generic_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.deliver(method, options = {})
rcpts.each do |rcpt|
rcpt.split(',').each do |to|
options[:to] = to
individual = send(method, options)
individual = send(method, options)
begin
individual.deliver_now
rescue Net::SMTPError
Expand All @@ -41,21 +41,21 @@ def self.deliver(method, options = {})
rescue => e
_log.error("method: #{method} options: #{options} delivery-error #{e}")
end

end

msg
end

def self.deliver_queue(method, options = {})
return unless MiqRegion.my_region.role_assigned?('notifier')

_log.info("starting: method: #{method} args: #{options} ")
options[:attachment] &&= attachment_to_blob(options[:attachment])
MiqQueue.submit_job(
:service => "notifier",
:class_name => name,
:method_name => 'deliver',
:args => [method, options],
:args => [method, options]
)
end

Expand Down Expand Up @@ -162,6 +162,7 @@ def prepare_generic_email(options)
options[:attachment].each do |a|
name = a[:filename]
next if name.nil?

attachments[name] = {:mime_type => a[:content_type], :content => a[:body]}
end
mail(:subject => options[:subject], :to => options[:to], :from => options[:from], :cc => options[:cc], :bcc => options[:bcc], :date => options[:sent_on])
Expand All @@ -172,7 +173,7 @@ def prepare_generic_email(options)
OPTIONAL_SMTP_KEYS = [:enable_starttls_auto, :openssl_verify_mode]
def set_mailer_smtp(evm_settings = nil)
evm_settings ||= ::Settings.smtp
am_settings = {}
am_settings = {}

DESTINATION_SMTP_KEYS.each { |key| am_settings[key] = evm_settings[key] }
am_settings[:address] ||= evm_settings[:host] # vmdb.yml has key :host, ActionMailer expects :address
Expand Down
12 changes: 6 additions & 6 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def self.xml_to_hashes(xmlNode, findPath, typeName)
nh[:acctid] = nh.delete("#{typeName}id".to_sym)
nh[:acctid] = nil unless nh[:acctid].respond_to?(:to_int) || nh[:acctid].to_s =~ /^-?[0-9]+$/
# Convert to signed integer values for acctid
nh[:acctid] = [nh[:acctid].to_i].pack("I").unpack("i")[0] unless nh[:acctid].nil?
nh[:acctid] = [nh[:acctid].to_i].pack("I").unpack1("i") unless nh[:acctid].nil?

# Find the users for this group / groups for this user
nh[:members] = []
Expand All @@ -93,7 +93,7 @@ def with_valid_account_type(valid_account_type)
if accttype == valid_account_type
yield
else
raise _("Cannot call method '%{caller}' on an Account of type '%{type}'") % {:caller => caller[0][/`.*'/][1..-2],
raise _("Cannot call method '%{caller}' on an Account of type '%{type}'") % {:caller => caller(1..1).first[/`.*'/][1..-2],
:type => accttype}
end
end
Expand Down Expand Up @@ -136,18 +136,18 @@ def remove_all_groups
# FIXME: Why not use .pluralize?
#
def members
send("#{accttype_opposite}s")
send(:"#{accttype_opposite}s")
end

def add_member(member)
send("add_#{accttype_opposite}", member)
send(:"add_#{accttype_opposite}", member)
end

def remove_member(member)
send("remove_#{accttype_opposite}", member)
send(:"remove_#{accttype_opposite}", member)
end

def remove_all_members
send("remove_all_#{accttype_opposite}s")
send(:"remove_all_#{accttype_opposite}s")
end
end
1 change: 1 addition & 0 deletions app/models/advanced_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def self.xml_to_hashes(xml_node, find_path)

el.each_element { |e| result << e.attributes.to_h }
end

result
end
end
2 changes: 1 addition & 1 deletion app/models/aliases/automation_manager_configured_system.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::AutomationManagerConfiguredSystem = ::ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem
AutomationManagerConfiguredSystem = ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem
2 changes: 1 addition & 1 deletion app/models/aliases/ems_automation.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsAutomation = ::ManageIQ::Providers::ExternalAutomationManager
EmsAutomation = ManageIQ::Providers::ExternalAutomationManager
2 changes: 1 addition & 1 deletion app/models/aliases/ems_cloud.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsCloud = ::ManageIQ::Providers::CloudManager
EmsCloud = ManageIQ::Providers::CloudManager
2 changes: 1 addition & 1 deletion app/models/aliases/ems_configuration.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsConfiguration = ::ManageIQ::Providers::ConfigurationManager
EmsConfiguration = ManageIQ::Providers::ConfigurationManager
2 changes: 1 addition & 1 deletion app/models/aliases/ems_infra.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsInfra = ::ManageIQ::Providers::InfraManager
EmsInfra = ManageIQ::Providers::InfraManager
2 changes: 1 addition & 1 deletion app/models/aliases/ems_network.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsNetwork = ::ManageIQ::Providers::NetworkManager
EmsNetwork = ManageIQ::Providers::NetworkManager
2 changes: 1 addition & 1 deletion app/models/aliases/ems_physical_infra.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsPhysicalInfra = ::ManageIQ::Providers::PhysicalInfraManager
EmsPhysicalInfra = ManageIQ::Providers::PhysicalInfraManager
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsRefresh::Refreshers::BaseRefresher = ManageIQ::Providers::BaseManager::Refresher
EmsRefresh::Refreshers::BaseRefresher = ManageIQ::Providers::BaseManager::Refresher
2 changes: 1 addition & 1 deletion app/models/aliases/ems_storage.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsStorage = ::ManageIQ::Providers::StorageManager
EmsStorage = ManageIQ::Providers::StorageManager
2 changes: 1 addition & 1 deletion app/models/aliases/miq_ems_metrics_collector_worker.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqEmsMetricsCollectorWorker = ManageIQ::Providers::BaseManager::MetricsCollectorWorker
MiqEmsMetricsCollectorWorker = ManageIQ::Providers::BaseManager::MetricsCollectorWorker
2 changes: 1 addition & 1 deletion app/models/aliases/miq_ems_operations_worker.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqEmsOperationsWorker = ManageIQ::Providers::BaseManager::OperationsWorker
MiqEmsOperationsWorker = ManageIQ::Providers::BaseManager::OperationsWorker
2 changes: 1 addition & 1 deletion app/models/aliases/miq_ems_refresh_worker.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqEmsRefreshWorker = ManageIQ::Providers::BaseManager::RefreshWorker
MiqEmsRefreshWorker = ManageIQ::Providers::BaseManager::RefreshWorker
2 changes: 1 addition & 1 deletion app/models/aliases/miq_event_catcher.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqEventCatcher = ManageIQ::Providers::BaseManager::EventCatcher
MiqEventCatcher = ManageIQ::Providers::BaseManager::EventCatcher
2 changes: 1 addition & 1 deletion app/models/aliases/miq_provision_cloud.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqProvisionCloud = ::ManageIQ::Providers::CloudManager::Provision
MiqProvisionCloud = ManageIQ::Providers::CloudManager::Provision
2 changes: 1 addition & 1 deletion app/models/aliases/miq_provision_cloud_workflow.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqProvisionCloudWorkflow = ::ManageIQ::Providers::CloudManager::ProvisionWorkflow
MiqProvisionCloudWorkflow = ManageIQ::Providers::CloudManager::ProvisionWorkflow
2 changes: 1 addition & 1 deletion app/models/aliases/miq_provision_infra_workflow.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqProvisionInfraWorkflow = ::ManageIQ::Providers::InfraManager::ProvisionWorkflow
MiqProvisionInfraWorkflow = ManageIQ::Providers::InfraManager::ProvisionWorkflow
2 changes: 1 addition & 1 deletion app/models/aliases/template_cloud.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::TemplateCloud = ManageIQ::Providers::CloudManager::Template
TemplateCloud = ManageIQ::Providers::CloudManager::Template
2 changes: 1 addition & 1 deletion app/models/aliases/template_infra.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require 'manageiq/providers/infra_manager/template'
::TemplateInfra = ManageIQ::Providers::InfraManager::Template
TemplateInfra = ManageIQ::Providers::InfraManager::Template
2 changes: 1 addition & 1 deletion app/models/aliases/vm_cloud.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::VmCloud = ManageIQ::Providers::CloudManager::Vm
VmCloud = ManageIQ::Providers::CloudManager::Vm
2 changes: 1 addition & 1 deletion app/models/aliases/vm_infra.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::VmInfra = ManageIQ::Providers::InfraManager::Vm
VmInfra = ManageIQ::Providers::InfraManager::Vm
2 changes: 1 addition & 1 deletion app/models/aliases/workers/ems_refresh_worker.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsRefreshWorker = ManageIQ::Providers::BaseManager::RefreshWorker::Runner
EmsRefreshWorker = ManageIQ::Providers::BaseManager::RefreshWorker::Runner
4 changes: 2 additions & 2 deletions app/models/aliases/workers/event_catcher.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
::EventCatcher = ManageIQ::Providers::BaseManager::EventCatcher::Runner
::EventCatcherHandledException = ::EventCatcher::EventCatcherHandledException
EventCatcher = ManageIQ::Providers::BaseManager::EventCatcher::Runner
EventCatcherHandledException = EventCatcher::EventCatcherHandledException
1 change: 1 addition & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def self.display_name(number = 1)

def self.human_attribute_name(attribute, options = {})
return super if options.delete(:ui) == true

"#{name}: #{super}"
end
end
1 change: 1 addition & 0 deletions app/models/asset_tag_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def self.upload(klass, fd)
klass = Object.const_get(klass.to_s)
raise _("%{name} not supported for upload!") % {:name => klass} unless REQUIRED_COLS.key?(klass)
raise _("%{name} not supported for upload!") % {:name => klass} unless MATCH_KEYS.key?(klass)

data, keys, tags = MiqBulkImport.upload(fd, REQUIRED_COLS[klass], MATCH_KEYS[klass].dup)

import = new(:data => data, :keys => keys, :tags => tags, :klass => klass)
Expand Down
15 changes: 8 additions & 7 deletions app/models/assigned_server_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def is_master?
end

def inactive?
!self.active?
!active?
end

def set_master
Expand All @@ -44,6 +44,7 @@ def set_priority(val)
other_servers.each do |server|
assigned = server.assigned_server_roles.find_by(:server_role_id => server_role_id)
next if assigned.nil?

assigned.update_attribute(:priority, DEFAULT_PRIORITY) if assigned.priority == HIGH_PRIORITY
end
end
Expand All @@ -55,7 +56,7 @@ def set_priority(val)
def activate_in_region(override = false)
return unless server_role.role_scope == 'region'

if override || self.inactive?
if override || inactive?
MiqRegion.my_region.lock do
if server_role.master_supported?
servers = MiqRegion.my_region.active_miq_servers
Expand All @@ -72,7 +73,7 @@ def activate_in_region(override = false)
def deactivate_in_region(override = false)
return unless server_role.role_scope == 'region'

if override || self.active?
if override || active?
MiqRegion.my_region.lock do
deactivate(override)
end
Expand All @@ -82,7 +83,7 @@ def deactivate_in_region(override = false)
def activate_in_zone(override = false)
return unless server_role.role_scope == 'zone'

if override || self.inactive?
if override || inactive?
miq_server.zone.lock do |_zone|
if server_role.master_supported?
servers = miq_server.zone.active_miq_servers
Expand All @@ -99,7 +100,7 @@ def activate_in_zone(override = false)
def deactivate_in_zone(override = false)
return unless server_role.role_scope == 'zone'

if override || self.active?
if override || active?
miq_server.zone.lock do |_zone|
deactivate(override)
end
Expand All @@ -121,14 +122,14 @@ def deactivate_in_role_scope
end

def activate(override = false)
if override || self.inactive?
if override || inactive?
_log.info("Activating Role <#{server_role.name}> on Server <#{miq_server.name}>")
update(:active => true)
end
end

def deactivate(override = false)
if override || self.active?
if override || active?
_log.info("Deactivating Role <#{server_role.name}> on Server <#{miq_server.name}>")
update(:active => false)
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/audit_event.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class AuditEvent < ApplicationRecord
validates :event, :status, :message, :severity, :presence => true
validates :status, :inclusion => { :in => %w[success failure] }
validates :severity, :inclusion => { :in => %w[fatal error warn info debug] }
validates :status, :inclusion => {:in => %w[success failure]}
validates :severity, :inclusion => {:in => %w[fatal error warn info debug]}

include Purging

Expand Down
4 changes: 3 additions & 1 deletion app/models/authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def self.new(*args, &block)
"incomplete" => 1,
"error" => 2,
"unreachable" => 2,
"invalid" => 3,
"invalid" => 3
).freeze

# Builds a case statement that case be used in a sql ORDER BY.
Expand Down Expand Up @@ -159,11 +159,13 @@ def native_ref

def set_credentials_changed_on
return unless @auth_changed

self.credentials_changed_on = Time.now.utc
end

def after_authentication_changed
return unless @auth_changed

_log.info("[#{resource_type}] [#{resource_id}], previously valid on: [#{last_valid_on}]")

raise_event(:changed)
Expand Down
8 changes: 5 additions & 3 deletions app/models/authenticator/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def self.short_name
end

attr_reader :config

def initialize(config)
@config = config
end
Expand All @@ -41,6 +42,7 @@ def user_authorizable_with_system_token?

def authorize_user(userid)
return unless user_authorizable_without_authentication?

authenticate(userid, "", {}, {:require_user => true, :authorize_only => true})
end

Expand Down Expand Up @@ -89,11 +91,10 @@ def authenticate(username, password, request = nil, options = {})
audit_success(audit.merge(:message => "Authentication successful for user #{username}"))
else
reason = failure_reason(username, request)
reason = ": #{reason}" unless reason.blank?
reason = ": #{reason}" if reason.present?
audit_failure(audit.merge(:message => "Authentication failed for userid #{username}#{reason}"))
raise MiqException::MiqEVMLoginError, fail_message
end

rescue MiqException::MiqEVMLoginError => err
_log.warn(err.message)
raise
Expand All @@ -107,6 +108,7 @@ def authenticate(username, password, request = nil, options = {})
if task.nil? || MiqTask.status_error?(task.status) || MiqTask.status_timeout?(task.status)
raise MiqException::MiqEVMLoginError, fail_message
end

user_or_taskid = case_insensitive_find_by_userid(task.userid)
end

Expand Down Expand Up @@ -279,7 +281,7 @@ def authorize_queue(username, _request, _options, *args)
:instance_id => task.id,
:method_name => :queue_callback_on_exceptions,
:args => ['Finished']
},
}
)
else
authorize(task.id, username, *args)
Expand Down
6 changes: 3 additions & 3 deletions app/models/authenticator/httpd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def update_user_attributes(user, username, identity)
user.userid = username
user.first_name = user_attrs[:firstname]
user.last_name = user_attrs[:lastname]
user.email = user_attrs[:email] unless user_attrs[:email].blank?
user.email = user_attrs[:email] if user_attrs[:email].present?
user.name = user_attrs[:fullname]
user.name = "#{user.first_name} #{user.last_name}" if user.name.blank?
user.name = user.userid if user.name.blank?
Expand Down Expand Up @@ -115,8 +115,7 @@ def find_userid_as_username(identity, username)

def find_userid_as_distinguished_name(user_attrs)
dn_domain = user_attrs[:domain].downcase.split(".").map { |s| "dc=#{s}" }.join(",")
user = User.in_my_region.where("userid LIKE ?", "%=#{user_attrs[:username]},%,#{dn_domain}").last
user
User.in_my_region.where("userid LIKE ?", "%=#{user_attrs[:username]},%,#{dn_domain}").last
end

def username_to_upn_name(user_attrs)
Expand Down Expand Up @@ -196,6 +195,7 @@ def user_attrs_from_external_directory(username)

def user_attrs_from_external_directory_via_dbus(username)
return unless username

require "dbus"

sysbus = DBus.system_bus
Expand Down
Loading

0 comments on commit 4ca12f0

Please sign in to comment.