@@ -144,9 +144,24 @@ fn rollback_refuses_binary_hosted_pin_then_checkout( |
144 | 144 | ) { |
145 | 145 | let hosted_lock = fixture.lock(); |
146 | 146 | let uri = server.uri(); |
| 147 | + // `--api-url`: the agent leg downloads before-blobs through the patch |
| 148 | + // API, which `--patch-server-url` does not redirect; without it the |
| 149 | + // run reached the live public proxy and the outcome depended on |
| 150 | + // whether that served minimist's original `index.js` blob. |
147 | 151 | let (code, env) = cli_code( |
148 | 152 | &fixture.project, |
149 | | - &["rollback", "--yes", "--patch-server-url", &uri], |
| 153 | + &[ |
| 154 | + "rollback", |
| 155 | + "--yes", |
| 156 | + "--api-url", |
| 157 | + &uri, |
| 158 | + "--api-token", |
| 159 | + "fake", |
| 160 | + "--org", |
| 161 | + ORG, |
| 162 | + "--patch-server-url", |
| 163 | + &uri, |
| 164 | + ], |
150 | 165 | ); |
151 | 166 | assert_eq!(code, 1, "a binary hosted pin cannot be restored: {env}"); |
152 | 167 | // The refused pin counts as a failure (#1066). After a takeover a |
@@ -874,6 +889,21 @@ async fn mock_api_patch(server: &MockServer, fixture: &Fixture, uuid: &str, patc |
874 | 889 | ) |
875 | 890 | .mount(server) |
876 | 891 | .await; |
| 892 | + // The original `index.js` blob. `rollback`'s missing-blob gate |
| 893 | + // downloads it when an installed copy matches neither patch hash (the |
| 894 | + // `bundled` shape's untouched nested minimist); see |
| 895 | + // `rollback_refuses_binary_hosted_pin_then_checkout`. |
| 896 | + Mock::given(method("GET")) |
| 897 | + .and(path(format!( |
| 898 | + "/v0/orgs/{ORG}/patches/blob/{}", |
| 899 | + compute_git_sha256_from_bytes(&fixture.original) |
| 900 | + ))) |
| 901 | + .respond_with( |
| 902 | + ResponseTemplate::new(200) |
| 903 | + .set_body_raw(fixture.original.clone(), "application/octet-stream"), |
| 904 | + ) |
| 905 | + .mount(server) |
| 906 | + .await; |
877 | 907 | Mock::given(method("GET")) |
878 | 908 | .and(path_regex(format!("^/patch/npm/{name}/.*$"))) |
879 | 909 | .respond_with(ResponseTemplate::new(200).set_body_raw(tgz, "application/octet-stream")) |
|