node: test do not fetch from owned refs
To ensure the behaviour of ignoring references that are owned by the
local peer a test case is added.
The case has two peers: alice and bob, where alice creates a new
repository. bob fetches to be up-to-date with alice. alice, in turn,
creates an issue and fetches from bob -- which should be successful.
If the refspec:
^refs/namespaces/<alice>/*
was not in place, her fetch from bob would fail since the signed
references would not be a fast-forward.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
parent
7fddc70a57
commit
821a6b6c08
|
|
@ -9,6 +9,8 @@ use std::{
|
|||
|
||||
use crossbeam_channel as chan;
|
||||
|
||||
use radicle::cob;
|
||||
use radicle::cob::issue;
|
||||
use radicle::crypto::ssh::{keystore::MemorySigner, Keystore};
|
||||
use radicle::crypto::test::signer::MockSigner;
|
||||
use radicle::crypto::{KeyPair, Seed, Signer};
|
||||
|
|
@ -19,7 +21,7 @@ use radicle::node::Handle as _;
|
|||
use radicle::profile::Home;
|
||||
use radicle::profile::Profile;
|
||||
use radicle::rad;
|
||||
use radicle::storage::ReadStorage;
|
||||
use radicle::storage::ReadStorage as _;
|
||||
use radicle::test::fixtures;
|
||||
use radicle::Storage;
|
||||
|
||||
|
|
@ -234,6 +236,16 @@ impl<G: Signer + cyphernet::Ecdh> NodeHandle<G> {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Create an [`issue::Issue`] in the `NodeHandle`'s storage.
|
||||
pub fn issue(&self, rid: Id, title: &str, desc: &str) -> cob::ObjectId {
|
||||
let repo = self.storage.repository(rid).unwrap();
|
||||
let mut issues = issue::Issues::open(&repo).unwrap();
|
||||
*issues
|
||||
.create(title, desc, &[], &[], &self.signer)
|
||||
.unwrap()
|
||||
.id()
|
||||
}
|
||||
}
|
||||
|
||||
impl Node<MockSigner> {
|
||||
|
|
|
|||
|
|
@ -195,6 +195,33 @@ fn test_replication() {
|
|||
assert_matches!(alice.storage.repository(acme).unwrap().verify(), Ok(()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dont_fetch_owned_refs() {
|
||||
logger::init(log::Level::Debug);
|
||||
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let mut alice = Node::init(tmp.path());
|
||||
let bob = Node::init(tmp.path());
|
||||
let acme = alice.project("acme", "");
|
||||
|
||||
let mut alice = alice.spawn(service::Config::default());
|
||||
let mut bob = bob.spawn(service::Config::default());
|
||||
|
||||
alice.connect(&bob);
|
||||
converge([&alice, &bob]);
|
||||
|
||||
assert!(bob.handle.track_repo(acme, Scope::Trusted).unwrap());
|
||||
|
||||
let result = bob.handle.fetch(acme, alice.id).unwrap();
|
||||
assert!(result.is_success());
|
||||
|
||||
log::debug!(target: "test", "Fetch complete with {}", bob.id);
|
||||
|
||||
alice.issue(acme, "Don't fetch self", "Use ^");
|
||||
let result = alice.handle.fetch(acme, bob.id).unwrap();
|
||||
assert!(result.is_success())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "failing"]
|
||||
fn test_fetch_trusted_remotes() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue