Skip to content

Commit

Permalink
Override configuration for testing purposes
Browse files Browse the repository at this point in the history
This configuration should give us access to the dockerized LDAP server,
both using the rake ldap:test_connection or using the Webui
  • Loading branch information
danidoni committed Jul 18, 2024
1 parent 39c3eca commit 2bd7bd2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/api/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,16 @@
url: '#'
)
]

# Override LDAP configuration for testing purposes
CONFIG['ldap_mode'] = :on
CONFIG['ldap_servers'] = 'ldap'
# OVERRIDE with your company's ldap search base for the users who will use OBS
CONFIG['ldap_search_base'] = 'dc=example,dc=org'
# Sam Account Name is the login name for LDAP
CONFIG['ldap_search_attr'] = 'cn'
CONFIG['ldap_name_attr'] = 'cn'
CONFIG['ldap_search_user'] = 'cn=admin,dc=example,dc=org'
CONFIG['ldap_search_auth'] = 'opensuse'
CONFIG['ldap_authenticate_ldap'] = :ldap
CONFIG['ldap_auth_attr'] = 'userPassword'
9 changes: 3 additions & 6 deletions src/api/lib/tasks/ldap.rake
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

namespace :ldap do
task test_connection: :environment do
CONFIG['ldap_servers'] = 'ldap'
CONFIG['ldap_ssl'] = :off
CONFIG['ldap_search_base'] = 'dc=example,dc=org'

Rails.logger = Logger.new(STDOUT)
puts UserLdapStrategy.initialize_ldap_con('cn=admin,dc=example,dc=org', 'opensuse').inspect
Rails.logger = Logger.new($stdout)
puts UserLdapStrategy.send(:initialize_ldap_con, CONFIG['ldap_search_user'], CONFIG['ldap_search_auth']).inspect
puts UserLdapStrategy.find_with_ldap('admin', 'opensuse').inspect
end
end

0 comments on commit 2bd7bd2

Please sign in to comment.