Project

General

Profile

« Previous | Next » 

Revision fef74a83

Added by Amit Upadhye over 1 year ago

Fixes #35533 - remove duplicate ssl params of cpdb cmd (#643)

View differences:

definitions/features/candlepin_database.rb
# rubocop:enable Metrics/MethodLength
def extend_with_db_options
db_options = { '-d' => construct_database_string }
db_options = { '-d' => configuration['database'] }
if check_option_using_cpdb_help('dbhost')
db_options['--dbhost'] = configuration['host']
db_options['--dbport'] = configuration['port']
......
db_options
end
def construct_database_string
db_str = configuration['database']
extra_opts = []
extra_opts << "ssl=#{configuration['ssl']}" if configuration['ssl']
extra_opts << "sslfactory=#{configuration['sslfactory']}" if configuration['sslfactory']
db_str += "?#{extra_opts.join('&')}" unless extra_opts.empty?
db_str
end
def fetch_extra_param(url, key_name)
query_string = url.split('?')[1]
return nil unless query_string
test/definitions/features/candlepin_database_test.rb
require 'test_helper'
require 'minitest/stub_const'
describe Features::CandlepinDatabase do
include DefinitionsTestHelper
subject { Features::CandlepinDatabase.new }
let(:subject_ins) { Features::CandlepinDatabase.any_instance }
let(:cp_config_dir) do
File.expand_path('../../../support/', __FILE__)
end
def stub_with_ssl_config
Features::CandlepinDatabase.stub_const(:CANDLEPIN_DB_CONFIG,
cp_config_dir + '/candlepin_with_ssl.conf') do
yield
end
end
def stub_without_ssl_config
Features::CandlepinDatabase.stub_const(:CANDLEPIN_DB_CONFIG,
cp_config_dir + '/candlepin_without_ssl.conf') do
yield
end
end
describe '.configuration' do
it 'The url includes ssl attributes when ssl is enabled' do
stub_with_ssl_config do
url = subject.configuration['url']
assert_includes url, 'ssl=true'
assert_includes url, 'sslrootcert=/usr/share/foreman/root.crt'
end
end
it 'The url does not include ssl attributes when ssl is disabled' do
stub_without_ssl_config do
url = subject.configuration['url']
refute_includes url, 'ssl=true'
refute_includes url, 'sslrootcert=/usr/share/foreman/root.crt'
end
end
end
end
test/support/candlepin_with_ssl.conf
### File managed with puppet ###
## Module: 'candlepin'
candlepin.consumer_system_name_pattern=.+
candlepin.environment_content_filtering=true
candlepin.auth.basic.enable=false
candlepin.auth.trusted.enable=false
candlepin.audit.hornetq.config_path=/etc/candlepin/broker.xml
candlepin.auth.oauth.enable=true
candlepin.auth.oauth.consumer.katello.secret=abcdabcd
module.config.adapter_module=org.candlepin.katello.KatelloModule
candlepin.ca_key=/etc/candlepin/certs/candlepin-ca.key
candlepin.ca_cert=/etc/candlepin/certs/candlepin-ca.crt
candlepin.crl.file=/var/lib/candlepin/candlepin-crl.crl
candlepin.async.jobs.ExpiredPoolsCleanupJob.schedule=0 0 0 * * ?
# Required for https://hibernate.atlassian.net/browse/HHH-12927
log4j.logger.org.hibernate.internal.SessionImpl=ERROR
# uncomment to enable debug logging in candlepin.log:
#log4j.logger.org.candlepin=DEBUG
jpa.config.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
jpa.config.hibernate.connection.driver_class=org.postgresql.Driver
jpa.config.hibernate.connection.url=jdbc:postgresql://host.example.com:5432/candlepin1db?ssl=true&sslrootcert=/usr/share/foreman/root.crt
jpa.config.hibernate.hbm2ddl.auto=validate
jpa.config.hibernate.connection.username=candlepin
jpa.config.hibernate.connection.password=password
org.quartz.jobStore.misfireThreshold=60000
org.quartz.jobStore.useProperties=false
org.quartz.jobStore.dataSource=myDS
org.quartz.jobStore.tablePrefix=QRTZ_
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
org.quartz.dataSource.myDS.driver=org.postgresql.Driver
org.quartz.dataSource.myDS.URL=jdbc:postgresql://host.example.com:5432/candlepin1db?ssl=true&sslrootcert=/usr/share/foreman/root.crt
org.quartz.dataSource.myDS.user=candlepin
org.quartz.dataSource.myDS.password=password
org.quartz.dataSource.myDS.maxConnections=5
test/support/candlepin_without_ssl.conf
### File managed with puppet ###
## Module: 'candlepin'
candlepin.consumer_system_name_pattern=.+
candlepin.environment_content_filtering=true
candlepin.auth.basic.enable=false
candlepin.auth.trusted.enable=false
candlepin.audit.hornetq.config_path=/etc/candlepin/broker.xml
candlepin.auth.oauth.enable=true
candlepin.auth.oauth.consumer.katello.secret=abcdabcd
module.config.adapter_module=org.candlepin.katello.KatelloModule
candlepin.ca_key=/etc/candlepin/certs/candlepin-ca.key
candlepin.ca_cert=/etc/candlepin/certs/candlepin-ca.crt
candlepin.async.jobs.ExpiredPoolsCleanupJob.schedule=0 0 0 * * ?
# Required for https://hibernate.atlassian.net/browse/HHH-12927
log4j.logger.org.hibernate.internal.SessionImpl=ERROR
# uncomment to enable debug logging in candlepin.log:
#log4j.logger.org.candlepin=DEBUG
jpa.config.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
jpa.config.hibernate.connection.driver_class=org.postgresql.Driver
jpa.config.hibernate.connection.url=jdbc:postgresql://localhost:5432/candlepin
jpa.config.hibernate.hbm2ddl.auto=validate
jpa.config.hibernate.connection.username=candlepin
jpa.config.hibernate.connection.password=password
org.quartz.jobStore.misfireThreshold=60000
org.quartz.jobStore.useProperties=false
org.quartz.jobStore.dataSource=myDS
org.quartz.jobStore.tablePrefix=QRTZ_
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
org.quartz.dataSource.myDS.driver=org.postgresql.Driver
org.quartz.dataSource.myDS.URL=jdbc:postgresql://localhost:5432/candlepin
org.quartz.dataSource.myDS.user=candlepin
org.quartz.dataSource.myDS.password=password
org.quartz.dataSource.myDS.maxConnections=5

Also available in: Unified diff