theforeman / smart_proxy_realm_ad_plugin

foreman-proxy realm plugin for Active Directory
GNU General Public License v3.0
9 stars 10 forks source link

Cannot leave 'computername_prefix' unset #28

Open wiad opened 2 months ago

wiad commented 2 months ago

If I leave computername_prefix unset/commented in the config:

#:computername_prefix: ''

the realm plugin crashes with:

2024-08-13T07:39:51 6d7a0a0a [E] undefined method `empty?' for false:FalseClass
2024-08-13T07:39:51 6d7a0a0a [W] Error details for undefined method `empty?' for false:FalseClass: <NoMethodError>: undefined method `empty?' for false:FalseClass
/usr/share/gems/gems/smart_proxy_realm_ad_plugin-0.1/lib/smart_proxy_realm_ad/provider.rb:79:in `apply_computername_prefix?'

The apply_computername_prefix? function maybe should be extended to check if the variable is set since it is supposed to be optional:

    def apply_computername_prefix?(computername)
      computername_prefix && !computername_prefix.nil? && !computername_prefix.empty? && (computername_hash || !computername[0, computername_prefix.size].casecmp(computername_prefix).zero?)
    end

(i.e. add computername_prefix &&)

martencassel commented 2 months ago

Thanks for your issue, i can take a look into it.