summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mullvad-daemon/src/migrations/mod.rs12
-rw-r--r--mullvad-daemon/src/migrations/v1.rs41
-rw-r--r--mullvad-daemon/src/migrations/v1_settings.json38
3 files changed, 50 insertions, 41 deletions
diff --git a/mullvad-daemon/src/migrations/mod.rs b/mullvad-daemon/src/migrations/mod.rs
index 95301a8df6..14fb4fb4fe 100644
--- a/mullvad-daemon/src/migrations/mod.rs
+++ b/mullvad-daemon/src/migrations/mod.rs
@@ -442,7 +442,7 @@ mod windows {
#[cfg(test)]
mod test {
- use mullvad_types::settings::Settings;
+ use mullvad_types::settings::{Settings, CURRENT_SETTINGS_VERSION};
use crate::migrations::migrate_settings;
@@ -459,4 +459,14 @@ mod test {
assert_eq!(default_settings, migrated_settings);
}
+
+ /// Ensure that the settings version is correct after running all migration code
+ #[tokio::test]
+ async fn test_all_migrations() {
+ const V1_SETTINGS: &str = include_str!("v1_settings.json");
+ let mut settings = serde_json::from_str(V1_SETTINGS).unwrap();
+ migrate_settings(None, &mut settings).await.unwrap();
+ let deserialized: Settings = serde_json::from_value(settings).unwrap();
+ assert_eq!(deserialized.settings_version, CURRENT_SETTINGS_VERSION);
+ }
}
diff --git a/mullvad-daemon/src/migrations/v1.rs b/mullvad-daemon/src/migrations/v1.rs
index b20f96488b..44de9d1293 100644
--- a/mullvad-daemon/src/migrations/v1.rs
+++ b/mullvad-daemon/src/migrations/v1.rs
@@ -118,46 +118,7 @@ mod test {
}
"#;
- const V1_SETTINGS: &str = r#"
-{
- "account_token": "1234",
- "relay_settings": {
- "normal": {
- "location": {
- "only": {
- "country": "se"
- }
- },
- "tunnel": {
- "only": {
- "openvpn": {
- "port": {
- "only": 53
- },
- "protocol": {
- "only": "udp"
- }
- }
- }
- }
- }
- },
- "allow_lan": true,
- "block_when_disconnected": false,
- "auto_connect": false,
- "tunnel_options": {
- "openvpn": {
- "mssfix": null
- },
- "wireguard": {
- "mtu": null
- },
- "generic": {
- "enable_ipv6": false
- }
- }
-}
-"#;
+ const V1_SETTINGS: &str = include_str!("v1_settings.json");
const V1_SETTINGS_2019V3: &str = r#"
{
diff --git a/mullvad-daemon/src/migrations/v1_settings.json b/mullvad-daemon/src/migrations/v1_settings.json
new file mode 100644
index 0000000000..f1c689372a
--- /dev/null
+++ b/mullvad-daemon/src/migrations/v1_settings.json
@@ -0,0 +1,38 @@
+{
+ "account_token": "1234",
+ "relay_settings": {
+ "normal": {
+ "location": {
+ "only": {
+ "country": "se"
+ }
+ },
+ "tunnel": {
+ "only": {
+ "openvpn": {
+ "port": {
+ "only": 53
+ },
+ "protocol": {
+ "only": "udp"
+ }
+ }
+ }
+ }
+ }
+ },
+ "allow_lan": true,
+ "block_when_disconnected": false,
+ "auto_connect": false,
+ "tunnel_options": {
+ "openvpn": {
+ "mssfix": null
+ },
+ "wireguard": {
+ "mtu": null
+ },
+ "generic": {
+ "enable_ipv6": false
+ }
+ }
+} \ No newline at end of file