Skip to content

Commit 1fbe2ce

Browse files
authored
fix: add test for republishing deleted version and require sudo for deleting (#1027)
1 parent a13e1bf commit 1fbe2ce

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

api/src/api/package.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4210,7 +4210,7 @@ ggHohNAjhbzDaY2iBW/m3NC5dehGUP4T2GBo/cwGhg==
42104210
// Now publish a package that has a few deps
42114211
let package_name = PackageName::try_from("bar").unwrap();
42124212
let version = Version::try_from("1.2.3").unwrap();
4213-
let task = crate::publish::tests::process_tarball_setup2(
4213+
let task = process_tarball_setup2(
42144214
&t,
42154215
create_mock_tarball("depends_on_ok"),
42164216
&package_name,
@@ -4248,5 +4248,17 @@ ggHohNAjhbzDaY2iBW/m3NC5dehGUP4T2GBo/cwGhg==
42484248
.await
42494249
.unwrap();
42504250
resp.expect_ok_no_content().await;
4251+
4252+
let package_name = PackageName::try_from("foo").unwrap();
4253+
let version = Version::try_from("0.0.1").unwrap();
4254+
let task = process_tarball_setup2(
4255+
&t,
4256+
create_mock_tarball("ok"),
4257+
&package_name,
4258+
&version,
4259+
false,
4260+
)
4261+
.await;
4262+
assert_eq!(task.status, PublishingTaskStatus::Failure, "{:?}", task);
42514263
}
42524264
}

frontend/routes/package/versions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ function Version({
260260
</button>
261261
</form>
262262
)}
263-
{isPublished && iam.isStaff && (
263+
{isPublished && iam.hasSudo && (
264264
<form method="POST" class="z-20">
265265
<input type="hidden" name="version" value={version.version} />
266266
<button

frontend/utils/iam.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface ScopeIAM {
77
isStaff: boolean;
88
canAdmin: boolean;
99
canWrite: boolean;
10+
hasSudo: boolean;
1011
}
1112

1213
export function scopeIAM(
@@ -22,5 +23,6 @@ export function scopeIAM(
2223
isStaff,
2324
canAdmin,
2425
canWrite,
26+
hasSudo,
2527
};
2628
}

0 commit comments

Comments
 (0)