Skip to content

Commit 59bf2e0

Browse files
committed
nix-config: user_specified_trusted_users_effective failing test
1 parent 35c93ca commit 59bf2e0

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/action/common/place_nix_configuration.rs

+39
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,45 @@ impl Action for PlaceNixConfiguration {
354354
mod tests {
355355
use super::*;
356356

357+
#[tokio::test]
358+
async fn user_specified_trusted_users_effective() -> eyre::Result<()> {
359+
let mut pnc_plan = PlaceNixConfiguration::plan(
360+
"nixbuildtest".to_string(),
361+
None,
362+
None,
363+
vec![UrlOrPathOrString::String(String::from(
364+
"trusted-users = foouser baruser",
365+
))],
366+
false,
367+
false,
368+
)
369+
.await
370+
.unwrap();
371+
372+
let tmp_dir = tempfile::tempdir()?;
373+
374+
pnc_plan.action.create_or_merge_standard_nix_config.as_mut().unwrap().action.path = tmp_dir.path().join("nix.conf");
375+
pnc_plan.action.create_or_merge_custom_nix_config.action.path = tmp_dir.path().join("nix.custom.conf");
376+
377+
pnc_plan.try_execute().await.unwrap();
378+
379+
let mut ncs_cmd = tokio::process::Command::new("nix");
380+
ncs_cmd.arg("config");
381+
ncs_cmd.arg("show");
382+
383+
ncs_cmd.env("NIX_CONF_DIR", tmp_dir.path());
384+
385+
let output = crate::execute_command(&mut ncs_cmd).await.unwrap();
386+
let output = String::from_utf8(output.stdout).unwrap();
387+
388+
assert!(
389+
output.contains("trusted-users = foouser baruser"),
390+
"effective nix config does not contain the user-specified trusted-users value"
391+
);
392+
393+
Ok(())
394+
}
395+
357396
#[tokio::test]
358397
async fn extra_trusted_no_error() -> eyre::Result<()> {
359398
let nix_config = PlaceNixConfiguration::setup_extra_config(

0 commit comments

Comments
 (0)