summaryrefslogtreecommitdiffstats
path: root/tests/storage.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/storage.rs')
-rw-r--r--tests/storage.rs49
1 files changed, 0 insertions, 49 deletions
diff --git a/tests/storage.rs b/tests/storage.rs
index 19936c2..e6ad2d1 100644
--- a/tests/storage.rs
+++ b/tests/storage.rs
@@ -89,55 +89,6 @@ fn forgetting_one_address_keeps_the_shared_credentials() {
89} 89}
90 90
91#[test] 91#[test]
92fn legacy_host_keyed_credentials_are_rekeyed_by_fingerprint() {
93 let (_, conn) = tmp_db("creds-migrate");
94 conn.execute_batch(
95 "CREATE TABLE hosts (
96 host TEXT PRIMARY KEY,
97 last_used DATETIME DEFAULT CURRENT_TIMESTAMP,
98 fingerprint TEXT
99 );
100 CREATE TABLE credentials (
101 host TEXT PRIMARY KEY,
102 username TEXT NOT NULL,
103 password TEXT NOT NULL
104 );
105 INSERT INTO hosts (host, last_used, fingerprint)
106 VALUES ('a:1', '2020-01-01 00:00:00', 'server-a');
107 INSERT INTO hosts (host, last_used, fingerprint)
108 VALUES ('b:2', '2021-01-01 00:00:00', 'server-a');
109 INSERT INTO hosts (host, last_used, fingerprint)
110 VALUES ('c:3', '2022-01-01 00:00:00', NULL);
111 INSERT INTO credentials VALUES ('a:1', 'alice', 'old');
112 INSERT INTO credentials VALUES ('b:2', 'alice', 'recent');
113 INSERT INTO credentials VALUES ('c:3', 'carol', 'untrusted');",
114 )
115 .unwrap();
116
117 client_database::init_db(&conn);
118
119 assert_eq!(
120 client_database::get_credentials(&conn, "server-a"),
121 Some(("alice".to_string(), "recent".to_string())),
122 "the most recently used address wins when legacy rows disagree"
123 );
124 assert_eq!(
125 client_database::get_credentials(&conn, "carol"),
126 None,
127 "a host with no trusted key cannot be re-keyed"
128 );
129
130 // The old table is gone: the column set is the fingerprint schema.
131 let mut statement = conn.prepare("PRAGMA table_info(credentials)").unwrap();
132 let columns: Vec<String> = statement
133 .query_map([], |row| row.get(1))
134 .unwrap()
135 .filter_map(|row| row.ok())
136 .collect();
137 assert_eq!(columns, vec!["fingerprint", "username", "password"]);
138}
139
140#[test]
141fn client_last_host_tracking() { 92fn client_last_host_tracking() {
142 let (_, conn) = tmp_db("hosts"); 93 let (_, conn) = tmp_db("hosts");
143 client_database::init_db(&conn); 94 client_database::init_db(&conn);