Skip to content

Commit

Permalink
feat: add command to hash password (#1295)
Browse files Browse the repository at this point in the history
Co-authored-by: Aljaž Mur Eržen <aljaz@edgedb.com>
  • Loading branch information
MrFoxPro and aljazerzen committed Apr 30, 2024
1 parent f047d7d commit 6cfd949
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/commands/cli.rs
Expand Up @@ -74,6 +74,10 @@ pub fn main(options: &Options) -> Result<(), anyhow::Error> {
let cmdopt = init_command_opts(options)?;
branch::branch_main(&cmdopt, c)
}
Command::HashPassword(cmd) => {
println!("{}", portable::password_hash(&cmd.password));
Ok(())
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/options.rs
Expand Up @@ -373,6 +373,8 @@ pub enum Command {
Watch(WatchCommand),
/// Manage branches
Branch(BranchCommand),

HashPassword(HashPasswordCommand),
}

#[derive(clap::Args, Clone, Debug)]
Expand Down Expand Up @@ -430,6 +432,11 @@ pub struct Info {
pub get: Option<String>,
}

#[derive(clap::Args, Clone, Debug)]
pub struct HashPasswordCommand {
pub password: String,
}

#[derive(Debug, Clone)]
pub struct Options {
pub app: clap::Command,
Expand Down
1 change: 1 addition & 0 deletions src/portable/mod.rs
Expand Up @@ -28,3 +28,4 @@ mod uninstall;
mod upgrade;

pub use main::{instance_main, project_main, server_main};
pub use reset_password::password_hash;
11 changes: 11 additions & 0 deletions tests/func/non_interactive.rs
Expand Up @@ -240,3 +240,14 @@ fn branch_commands() {

// TODO: test how this works in projects
}

#[test]
fn hash_password() {
crate::edgedb_cli_cmd()
.arg("hash-password")
.arg("password1234")
.assert()
.context("hash-password", "basic usage")
.success()
.stdout(predicates::str::starts_with("SCRAM-SHA-256$"));
}

0 comments on commit 6cfd949

Please sign in to comment.