Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent loading plugins for unittests #1327

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libdnf5/base/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ void Base::Impl::with_config_file_path(std::function<void(const std::string &)>
}

void Base::load_plugins() {
// load plugins according to configuration
if (!p_impl->config.get_plugins_option().get_value()) {
return;
}

const char * plugins_config_dir = std::getenv("LIBDNF_PLUGINS_CONFIG_DIR");
if (plugins_config_dir &&
p_impl->config.get_pluginconfpath_option().get_priority() < Option::Priority::COMMANDLINE) {
Expand Down
2 changes: 2 additions & 0 deletions test/dnf5daemon-server/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ def setUp(self):
self.iface_session = dbus.Interface(
self.bus.get_object(DNFDAEMON_BUS_NAME, DNFDAEMON_OBJECT_PATH),
dbus_interface=IFACE_SESSION_MANAGER)
# Prevent loading plugins from host by setting "plugins" to False
self.session = self.iface_session.open_session({
"config": {
"config_file_path": self.config_file_path,
"installroot": self.installroot,
"plugins": False,
"cachedir": os.path.join(self.installroot, "var/cache/dnf"),
"reposdir": self.reposdir,
}
Expand Down
3 changes: 3 additions & 0 deletions test/perl5/libdnf5/rpm/test_package_query.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ my $tmpdir = tempdir("libdnf5_perl5_unittest.XXXX", TMPDIR => 1, CLEANUP => 1);
$base->get_config()->get_installroot_option()->set($libdnf5::conf::Option::Priority_RUNTIME, $tmpdir."/installroot");
$base->get_config()->get_cachedir_option()->set($libdnf5::conf::Option::Priority_RUNTIME, $tmpdir."/cache");

# Prevent loading plugins from host
$base->get_config()->get_plugins_option()->set("False");
ppisar marked this conversation as resolved.
Show resolved Hide resolved

# Sets base internals according to configuration
$base->setup();

Expand Down
3 changes: 3 additions & 0 deletions test/python3/libdnf5/base_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def setUp(self):
config.cachedir = os.path.join(self.temp_dir, "cache")
config.optional_metadata_types = libdnf5.conf.OPTIONAL_METADATA_TYPES

# Prevent loading plugins from the host
config.plugins = False

vars = self.base.get_vars().get()
vars.set("arch", "x86_64")

Expand Down
3 changes: 3 additions & 0 deletions test/python3/libdnf5/tutorial/session/create_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
base_config = base.get_config()
base_config.installroot = installroot

# Optionally prevent of loading of plugins. Plugins are loaded by default from the host
base_config.plugins = False

# Optionally load configuration from the config files.
#
# The Base's config is initialized with default values, one of which is
Expand Down
3 changes: 3 additions & 0 deletions test/ruby/libdnf5/base_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def setup()
@base.get_config().get_installroot_option().set(File.join(@temp_dir, "installroot"))
@base.get_config().get_cachedir_option().set(File.join(@temp_dir, "cache"))

# Prevent loading of plugins from host
@base.get_config().get_plugins_option().set(false)

# Sets Base internals according to configuration
@base.setup()

Expand Down
3 changes: 3 additions & 0 deletions test/shared/base_test_case.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ void BaseTestCase::setUp() {
base.get_config().get_cachedir_option().set(temp->get_path() / "cache");
base.get_config().get_optional_metadata_types_option().set(libdnf5::OPTIONAL_METADATA_TYPES);

// Prevent loading libdnf5 plugins
base.get_config().get_plugins_option().set(false);

base.get_vars()->set("arch", "x86_64");

base.setup();
Expand Down
3 changes: 3 additions & 0 deletions test/shared/test_case_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,8 @@ std::unique_ptr<libdnf5::Base> TestCaseFixture::get_preconfigured_base() {
base->get_config().get_installroot_option().set(temp->get_path() / "installroot");
base->get_config().get_cachedir_option().set(temp->get_path() / "cache");

// Prevent loading libdnf5 plugins
base->get_config().get_plugins_option().set(false);

return base;
}
4 changes: 4 additions & 0 deletions test/tutorial/session/create_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ libdnf5::Base base;
// installroot directory tree as its root for the rest of its lifetime.
base.get_config().get_installroot_option().set(installroot);

// Optionally - Prevent loading libdnf5 plugins.
// Plugins are loaded by default from the host
base.get_config().get_plugins_option().set(false);

// Optionally load configuration from the config files.
//
// The Base's config is initialized with default values, one of which is
Expand Down
Loading