Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ def _readConfig():
return None

def _readLegacyNetworkConfig():
if not os.path.exists(constants.legacyNetworkConfigFilePath):
return None

configParser = configparser.ConfigParser()
configParser.read(constants.legacyNetworkConfigFilePath)
try:
Expand All @@ -111,7 +114,7 @@ def _readLegacyNetworkConfig():
}
return networkConfig
except KeyError as e:
logging.error("Error when reading network.conf (1)")
logging.error("Error when reading network.conf. It exists but is invalid.")
logging.exception(e)
return None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ def _clearUserCache(unattended=False):
if not _checkLoggedInUsers():
return False

realm.clearUserCache()
result = realm.clearUserCache()
if not result:
logging.error("Failed to clear user cache!")
return False

logging.info("Done.")

return realm.clearUserCache()
return True

def _unmountAllCifsMounts():
logging.info("Unmounting all CIFS mounts!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def setup(domain=None, user=None):
"""
logging.info('#### linuxmuster-linuxclient7 setup ####')

if not realm.clearUserCache():
userCacheCleared = realm.clearUserCache()
if not userCacheCleared and isSetup():
return False

if not _cleanOldDomainJoins():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,23 @@ def test_network_both():

@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"/does/not/exist/network.conf")
@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"/does/not/exist/config.yml")
def test_network_none():
@mock.patch("linuxmusterLinuxclient7.config.logging.exception")
def test_network_none(mockLoggingException):
# make sure that no confusing error message is logged when config file does not exist
rc, networkConfig = config.network()
assert not rc
assert networkConfig is None
assert not mockLoggingException.called

@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"{MOCK_FILE_PATH}/network.invalid.conf")
@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"/does/not/exist/config.yml")
@mock.patch("linuxmusterLinuxclient7.config.logging.exception")
def test_network_legacy_invalid(mockLoggingException):
# make sure that an error message is logged when the legacy config file exists but is invalid
rc, networkConfig = config.network()
assert not rc
assert networkConfig is None
assert mockLoggingException.called

@mock.patch("linuxmusterLinuxclient7.config.constants.legacyNetworkConfigFilePath", f"/does/not/exist/network.conf")
@mock.patch("linuxmusterLinuxclient7.config.constants.configFilePath", f"{MOCK_FILE_PATH}/config.invalid-network.yml")
Expand Down