Repository: astral-sh/uv
File: crates/uv/tests/it/common/mod.rs (Rust)

Code before:

    /// Create a `uv auth login` command.
    pub fn auth_login(&self) -> Command {
        let mut command = Self::new_command();
        command.arg("auth").arg("login");
        self.add_shared_options(&mut command, false);
        command
    }

    /// Create a `uv auth logout` command.
    pub fn auth_logout(&self) -> Command {
        let mut command = Self::new_command();
        command.arg("auth").arg("logout");
        self.add_shared_options(&mut command, false);
        command
    }

    /// Create a `uv auth helper --protocol bazel get` command.
    pub fn auth_helper(&self) -> Command {
        let mut command = Self::new_command();
        command
            .arg("auth")
            .arg("helper")
            .arg("--protocol")
            .arg("bazel")
            .arg("get");
        self.add_shared_options(&mut command, false);
        command
    }

    /// Create a `uv auth token` command.
    pub fn auth_token(&self) -> Command {
        let mut command = Self::new_command();
        command.arg("auth").arg("token");
        self.add_shared_options(&mut command, false);
        command
    }

    /// Set `HOME` to the real home directory.
    ///
    /// We need this for testing commands which use the macOS keychain.
    #[must_use]
    pub fn with_real_home(mut self) -> Self {
        if let Some(home) = env::var_os(EnvVars::HOME) {
            self.extra_env
                .push((EnvVars::HOME.to_string().into(), home));
        }
        self
    }

    /// Run the given python code and check whether it succeeds.

Review comment (security):
We shouldn't hide all this in the `auth_helper` utility, that really confused me. Just use these explicitly in the tests.

Code after:

    /// Create a `uv auth login` command.
    pub fn auth_login(&self) -> Command {
        let mut command = Self::new_command();
        command.arg("auth").arg("login");
        self.add_shared_options(&mut command, false);
        command
    }

    /// Create a `uv auth logout` command.
    pub fn auth_logout(&self) -> Command {
        let mut command = Self::new_command();
        command.arg("auth").arg("logout");
        self.add_shared_options(&mut command, false);
        command
    }

    /// Create a `uv auth helper --protocol bazel get` command.
    pub fn auth_helper(&self) -> Command {
        let mut command = Self::new_command();
        command.arg("auth").arg("helper");
        self.add_shared_options(&mut command, false);
        command
    }

    /// Create a `uv auth token` command.
    pub fn auth_token(&self) -> Command {
        let mut command = Self::new_command();
        command.arg("auth").arg("token");
        self.add_shared_options(&mut command, false);
        command
    }

    /// Set `HOME` to the real home directory.
    ///
    /// We need this for testing commands which use the macOS keychain.
    #[must_use]
    pub fn with_real_home(mut self) -> Self {
        if let Some(home) = env::var_os(EnvVars::HOME) {
            self.extra_env
                .push((EnvVars::HOME.to_string().into(), home));
        }
        self
    }

    /// Run the given python code and check whether it succeeds.
    pub fn assert_command(&self, command: &str) -> Assert {
        self.python_command()
            .arg("-c")
            .arg(command)
            .current_dir(&self.temp_dir)