Skip to content

Commit

Permalink
Add wireless hidden property to network model (#1024)
Browse files Browse the repository at this point in the history
## Problem

Wireless property hidden is missing in network model.


## Solution

Add property. Sorry that I forgot it in my previous PR.


## Testing

- *Extended unit test*
- *Tested manually*
- *Tested with the migration
jcronenberg#69
  • Loading branch information
imobachgs authored Jan 29, 2024
2 parents 243991b + 97841f4 commit 1968c26
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions rust/agama-dbus-server/src/network/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ pub struct WirelessConfig {
pub channel: Option<u32>,
pub bssid: Option<macaddr::MacAddr6>,
pub wep_security: Option<WEPSecurity>,
pub hidden: bool,
}

impl TryFrom<ConnectionConfig> for WirelessConfig {
Expand Down
10 changes: 10 additions & 0 deletions rust/agama-dbus-server/src/network/nm/dbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ fn wireless_config_to_dbus<'a>(
("mode", Value::new(config.mode.to_string())),
("ssid", Value::new(config.ssid.to_vec())),
("assigned-mac-address", Value::new(mac_address.to_string())),
("hidden", Value::new(config.hidden)),
]);

if let Some(band) = &config.band {
Expand Down Expand Up @@ -726,6 +727,9 @@ fn wireless_config_from_dbus(conn: &OwnedNestedHash) -> Option<WirelessConfig> {
*bssid.get(5)?,
));
}
if let Some(hidden) = wireless.get("hidden") {
wireless_config.hidden = *hidden.downcast_ref::<bool>()?;
}

if let Some(security) = conn.get(WIRELESS_SECURITY_KEY) {
let key_mgmt: &str = security.get("key-mgmt")?.downcast_ref()?;
Expand Down Expand Up @@ -1001,6 +1005,7 @@ mod test {
"bssid".to_string(),
Value::new(vec![18_u8, 52_u8, 86_u8, 120_u8, 154_u8, 188_u8]).to_owned(),
),
("hidden".to_string(), Value::new(false).to_owned()),
]);

let security_section = HashMap::from([
Expand Down Expand Up @@ -1032,6 +1037,7 @@ mod test {
wireless.bssid,
Some(macaddr::MacAddr6::from_str("12:34:56:78:9A:BC").unwrap())
);
assert!(!wireless.hidden);
let wep_security = wireless.wep_security.as_ref().unwrap();
assert_eq!(wep_security.wep_key_type, WEPKeyType::Key);
assert_eq!(wep_security.auth_alg, WEPAuthAlg::Open);
Expand Down Expand Up @@ -1082,6 +1088,7 @@ mod test {
"hello".to_string(),
],
}),
hidden: true,
..Default::default()
};
let mut wireless = build_base_connection();
Expand Down Expand Up @@ -1120,6 +1127,9 @@ mod test {
.collect();
assert_eq!(bssid, vec![18, 52, 86, 120, 154, 188]);

let hidden: bool = *wireless.get("hidden").unwrap().downcast_ref().unwrap();
assert!(hidden);

let security = wireless_dbus.get(WIRELESS_SECURITY_KEY).unwrap();
let key_mgmt: &str = security.get("key-mgmt").unwrap().downcast_ref().unwrap();
assert_eq!(key_mgmt, "wpa-psk");
Expand Down
6 changes: 6 additions & 0 deletions rust/package/agama-cli.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Jan 29 15:37:56 UTC 2024 - Jorik Cronenberg <jorik.cronenberg@suse.com>

- Add hidden property for wireless in network model
(gh#openSUSE/agama#1024).

-------------------------------------------------------------------
Mon Jan 29 10:22:49 UTC 2024 - Jorik Cronenberg <jorik.cronenberg@suse.com>

Expand Down

0 comments on commit 1968c26

Please sign in to comment.