diff options
Diffstat (limited to 'server/tests/common/mod.rs')
| -rw-r--r-- | server/tests/common/mod.rs | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/server/tests/common/mod.rs b/server/tests/common/mod.rs index 0eef90b..5a7e30d 100644 --- a/server/tests/common/mod.rs +++ b/server/tests/common/mod.rs @@ -17,6 +17,7 @@ pub struct DockerComposeContext { test_dir: PathBuf, url: String, remote_git: String, + remote_git_key: PathBuf, } async fn run(cmd: &mut Command, name: &str) -> Result<(), anyhow::Error> { @@ -65,10 +66,10 @@ async fn setup_ssh_file( Ok(()) } -async fn git_clone(base: impl AsRef<Path>) -> Result<(), anyhow::Error> { +async fn git_clone(base: impl AsRef<Path>, remote: &str) -> Result<(), anyhow::Error> { let mut cmd = Command::new("git"); cmd.arg("clone"); - cmd.arg("ssh://localhost/srv/git/fake.git"); + cmd.arg(remote); cmd.env("GIT_SSH_COMMAND", "ssh -F ssh_config"); cmd.current_dir(base); @@ -99,6 +100,10 @@ impl DockerComposeContext { self.remote_git.as_str() } + pub fn remote_git_key(&self) -> &Path { + self.remote_git_key.as_ref() + } + pub async fn setup_ssh_key(&self, base: &str, key: &str) -> Result<(), anyhow::Error> { let base_dir = self.test_dir.join(base); fs::create_dir(&base_dir).await?; @@ -111,7 +116,7 @@ impl DockerComposeContext { } pub async fn git_clone(&self, base: &str) -> Result<(), anyhow::Error> { - git_clone(self.test_dir.join(base)).await + git_clone(self.test_dir.join(base), "ssh://localhost/srv/git/fake").await } pub fn git_dir(&self, base: &str) -> PathBuf { @@ -129,11 +134,14 @@ impl AsyncTestContext for DockerComposeContext { Ok(pathstr) => PathBuf::from(pathstr), Err(e) => panic!("CARGO_MANIFEST_DIR not set: {e:?}"), }; + let docker_dir = cargo_dir.join("../docker/integration_test"); + let remote_git_key = docker_dir.join("web/gitkey"); let ctx = DockerComposeContext { - docker_dir: cargo_dir.join("../docker/integration_test"), + docker_dir: docker_dir, test_dir: testdir!(), url: "http://localhost:18000".to_string(), remote_git: "ssh://git@remote_git/srv/git/fake.git".to_string(), + remote_git_key, }; // Build githook, needs to use musl to work with the rockstorm/git-server image @@ -209,7 +217,9 @@ impl AsyncTestContext for DockerComposeContext { run(&mut cmd, "git-init").await.expect("ssh git-init"); } - git_clone(&mod_path).await.expect("git clone"); + git_clone(&mod_path, "ssh://localhost/srv/git/fake.git") + .await + .expect("git clone"); fs::write(mod_path.join("fake/README"), "Hello fellow fake person!") .await @@ -278,7 +288,7 @@ pub async fn user_key_add( ) -> Result<api_model::UserKey, anyhow::Error> { let data = api_model::UserKeyData { kind, - data, + data: data, comment: None, }; let result = client @@ -300,11 +310,14 @@ pub async fn create_project( client: &mut Client, projectid: &str, remote: &str, + remote_key: &Path, ) -> Result<api_model::Project, anyhow::Error> { + let remote_key_data = fs::read_to_string(remote_key).await?; let data = api_model::ProjectData { title: None, description: None, remote: Some(remote), + remote_key: Some(remote_key_data), main_branch: None, }; let result = client |
