Skip to content

Commit e1ac30b

Browse files
committed
test(publish): show current behavior allows \registry-index\ during publish
1 parent efce094 commit e1ac30b

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

tests/testsuite/publish.rs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4595,3 +4595,68 @@ Caused by:
45954595
"#]])
45964596
.run();
45974597
}
4598+
4599+
#[cargo_test]
4600+
fn registry_index_not_allowed_in_publish() {
4601+
let _registry = RegistryBuilder::new()
4602+
.http_api()
4603+
.http_index()
4604+
.alternative()
4605+
.build();
4606+
4607+
let p = project()
4608+
.file(
4609+
"Cargo.toml",
4610+
r#"
4611+
[package]
4612+
name = "foo"
4613+
version = "0.0.1"
4614+
edition = "2015"
4615+
authors = []
4616+
license = "MIT"
4617+
description = "foo"
4618+
4619+
[dependencies]
4620+
bar = { version = "0.1.0", registry-index = "https://example.com/index" }
4621+
"#,
4622+
)
4623+
.file("src/main.rs", "fn main() {}")
4624+
.build();
4625+
4626+
// FIXME: This currently allows `registry-index` which is a bug.
4627+
// It should error during manifest parsing because `registry-index` is for internal use only.
4628+
// Instead, it tries to fetch from the URL and fails with a network error.
4629+
p.cargo("publish --registry alternative")
4630+
.with_status(101)
4631+
.with_stderr_data(str![[r#"
4632+
[UPDATING] `alternative` index
4633+
[PACKAGING] foo v0.0.1 ([ROOT]/foo)
4634+
[UPDATING] `https://example.com/index` index
4635+
[WARNING] spurious network error (3 tries remaining): unexpected http status code: 404; class=Http (34)
4636+
[WARNING] spurious network error (2 tries remaining): unexpected http status code: 404; class=Http (34)
4637+
[WARNING] spurious network error (1 try remaining): unexpected http status code: 404; class=Http (34)
4638+
[ERROR] failed to prepare local package for uploading
4639+
4640+
Caused by:
4641+
failed to get `bar` as a dependency of package `foo v0.0.1 ([ROOT]/foo)`
4642+
4643+
Caused by:
4644+
failed to load source for dependency `bar`
4645+
4646+
Caused by:
4647+
Unable to update registry `https://example.com/index`
4648+
4649+
Caused by:
4650+
failed to fetch `https://example.com/index`
4651+
4652+
Caused by:
4653+
network failure seems to have happened
4654+
if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
4655+
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
4656+
4657+
Caused by:
4658+
unexpected http status code: 404; class=Http (34)
4659+
4660+
"#]])
4661+
.run();
4662+
}

0 commit comments

Comments
 (0)