mod common;
use common::*;
use gunnar_ssh::Access;
#[tokio::test]
async fn git_lfs_authenticate_is_answered_with_the_pure_ssh_sentence() {
let key = mint_key();
let fixture = start_with_key(&key, Access::Admin).await;
let session = authenticate(fixture.server.local_addr(), &key, "git")
.await
.expect("connect")
.expect("authenticate");
for line in [
"git-lfs-authenticate 'nordisk/osm-katana.git' upload",
"git-lfs-authenticate nordisk/osm-katana.git download",
] {
match exec(&session, line).await.expect("exec") {
ExecOutcome::Accepted { stdout, exit_status } => {
assert_eq!(exit_status, Some(1), "{line}: a refusal git-lfs reports, not a crash: {stdout:?}");
assert!(stdout.contains("pure SSH"), "{line}: the sentence names the transport: {stdout:?}");
assert!(stdout.contains("git-lfs-transfer"), "{line}: {stdout:?}");
assert!(stdout.contains("again"), "{line}: it says to retry: {stdout:?}");
let lower = stdout.to_ascii_lowercase();
for fallback in ["not found", "no such file", "command not found"] {
assert!(
!lower.contains(fallback),
"{line}: `{fallback}` sends git-lfs to a guessed HTTPS endpoint Gunnar does not serve: {stdout:?}"
);
}
}
ExecOutcome::Refused => panic!(
"{line}: refused the channel — git-lfs prints `exec request failed on channel 0`, \
which says nothing about what to do"
),
}
}
assert!(fixture.transport.served().is_empty(), "nothing is served by this verb");
}