Skip to content

Commit

Permalink
fix(nm): actually delete connection upon device disconnection [backpo…
Browse files Browse the repository at this point in the history
…rt release-5.3.0] (#4672)

fix(nm): actually delete connection upon device disconnection (#4670)

* fix(nm): actually delete connection upon device disconnection

* test: fix associated tests

* fix: Associated->Applied

(cherry picked from commit c0070dd)

Co-authored-by: Mattia Dal Ben <[email protected]>
  • Loading branch information
github-actions[bot] and mattdibi authored May 21, 2023
1 parent eb08408 commit 9cc78f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ protected String getDeviceIdByDBusPath(String dbusPath) throws DBusException {
}

private void disable(Device device) throws DBusException {
Optional<Connection> appliedConnection = getAppliedConnection(device);

NMDeviceState deviceState = getDeviceState(device);
if (Boolean.TRUE.equals(NMDeviceState.isConnected(deviceState))) {
DeviceStateLock dsLock = new DeviceStateLock(this.dbusConnection, device.getObjectPath(),
Expand All @@ -545,6 +547,10 @@ private void disable(Device device) throws DBusException {
}

// Housekeeping
if (appliedConnection.isPresent()) {
appliedConnection.get().Delete();
}

List<Connection> availableConnections = getAvaliableConnections(device);
for (Connection connection : availableConnections) {
connection.Delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ public void thenConfigurationEnforcementIsActive(boolean expectedValue) {
}

private void thenConnectionIsDeleted(String path) {
verify(this.mockedConnections.get(path)).Delete();
verify(this.mockedConnections.get(path), atLeastOnce()).Delete();
}

private void thenConnectionIsNotDeleted(String path) {
Expand Down

0 comments on commit 9cc78f6

Please sign in to comment.