#!/bin/bash
## kola:
##   # This test should behave the same on every platform.
##   tags: "platform-independent"
##   # This is a read-only, nondestructive test.
##   exclusive: false
##   description: Verify that the ifcfg-rh plugin is not loaded on FCOS,
##     and make sure that at least for RHCOS8 it is included.

set -xeuo pipefail

# shellcheck disable=SC1091
. "$KOLA_EXT_DATA/commonlib.sh"

# Check if it exists or not. The plugin provides a dbus interface
# so if it is loaded there will be something listening at that name
exists=0
busctl status com.redhat.ifcfgrh1 && exists=1

if is_fcos; then
    [ "$exists" == "0" ] || fatal "ifcfg-rh plugin detected on FCOS"
elif is_rhcos || is_scos; then
    [ "$exists" == "1" ] || fatal "ifcfg-rh plugin not detected on RHCOS/SCOS"
else
    fatal "nm-ifcfg-rh-plugin does not support this distro/version"
fi

ok "ifcfg-rh plugin test successful"
