feat: unpin a server back to trust on first use
This commit is contained in:
parent
1ae2752eb0
commit
4ef0fdaec0
1 changed files with 19 additions and 0 deletions
|
|
@ -283,6 +283,15 @@ impl Store {
|
|||
.and_then(|k| k.try_into().ok()))
|
||||
}
|
||||
|
||||
/// Removes a pin: the settings screen's unpin, the inverse of
|
||||
/// `pin_server`. The next session against that host is trust on first
|
||||
/// use again (sec 4, sec 8).
|
||||
pub fn unpin_server(&self, host: &str) -> Result<(), Error> {
|
||||
self.db()
|
||||
.execute("DELETE FROM servers WHERE host = ?1", params![host])?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Every pin, host and key, ordered by host — the export's server map.
|
||||
pub fn pins(&self) -> Result<Vec<(String, [u8; KEY_LEN])>, Error> {
|
||||
let db = self.db();
|
||||
|
|
@ -881,6 +890,16 @@ mod tests {
|
|||
assert_eq!(store.history("alice@example.org").unwrap(), [([9u8; 32], 42)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unpin_returns_to_trust_on_first_use() {
|
||||
let store = temp_store("unpin");
|
||||
store.pin_server("example.org", &[1u8; KEY_LEN]).unwrap();
|
||||
store.unpin_server("example.org").unwrap();
|
||||
assert_eq!(store.server_pin("example.org").unwrap(), None);
|
||||
// Unpinning what was never pinned is not an error.
|
||||
store.unpin_server("never.example.org").unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kept_survives_the_folder_listing() {
|
||||
let store = temp_store("kept");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue