I'm working on adding tests for the database driver in the tracker core package. I've found some bugs on the MySQL driver:
Bug 1: todo
Adding a permanent auth keys does not work. There is a todo!() macro:
fn add_key_to_keys(&self, auth_key: &authentication::PeerKey) -> Result<usize, Error> {
let mut conn = self.pool.get().map_err(|e| (e, DRIVER))?;
let key = auth_key.key.to_string();
let valid_until = match auth_key.valid_until {
Some(valid_until) => valid_until.as_secs().to_string(),
None => todo!(),
};
conn.exec_drop(
"INSERT INTO `keys` (`key`, valid_until) VALUES (:key, :valid_until)",
params! { key, valid_until },
)?;
Ok(1)
}
Bug 2: remove key
The SQL query to remove a key is wrong. We need to escape the column name key
fn remove_key_from_keys(&self, key: &Key) -> Result<usize, Error> {
let mut conn = self.pool.get().map_err(|e| (e, DRIVER))?;
conn.exec_drop("DELETE FROM `keys` WHERE key = :key", params! { "key" => key.to_string() })?;
Ok(1)
}
Bug 3: expiration time for expiring keys changes after storing the key
When you save an expiring key and then you load it from the database, the key has some nanoseconds, and It should not. We are using a timestamp for expiration time.
Inserted into DB:
left: PeerKey { key: Key("7HP1NslpuQn6kLVAgAF4nFpnZNSQ4hrx"), valid_until: Some(1739182308s) }
Fetched from DB:
right: PeerKey { key: Key("7HP1NslpuQn6kLVAgAF4nFpnZNSQ4hrx"), valid_until: Some(1739182308.603691299s)
cc @da2ce7
I will fix them in independent commits in the PR I'm, working on.
I'm working on adding tests for the database driver in the tracker core package. I've found some bugs on the MySQL driver:
Bug 1: todo
Adding a permanent auth keys does not work. There is a
todo!()macro:Bug 2: remove key
The SQL query to remove a key is wrong. We need to escape the column name
keyBug 3: expiration time for expiring keys changes after storing the key
When you save an expiring key and then you load it from the database, the key has some nanoseconds, and It should not. We are using a timestamp for expiration time.
cc @da2ce7
I will fix them in independent commits in the PR I'm, working on.