1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
//! Maven, NuGet, and Go source adapters.
//!
//! The adapter modules are included with `#[path]` because `sources/mod.rs` is
//! owned by the integration wave. Every request goes through the scripted
//! [`FakeHttp`] seam; no live network is used.
#![allow(dead_code)]
use std::collections::{HashMap, VecDeque};
use std::sync::{Arc, Mutex};
use async_trait::async_trait;
use serde_json::{Value, json};
use vuln_notif::release::http::RegistryHttp;
use vuln_notif::release::source::{ProjectRef, ReleaseSource, SourceCapabilities, VersionInfo};
mod release {
pub mod artifact {
pub use vuln_notif::release::artifact::*;
}
pub mod http {
pub use vuln_notif::release::http::*;
}
pub mod source {
pub use vuln_notif::release::source::*;
}
pub mod versioning {
pub use vuln_notif::release::versioning::*;
}
}
#[path = "../src/release/sources/golang.rs"]
mod golang;
#[path = "../src/release/sources/maven.rs"]
mod maven;
#[path = "../src/release/sources/nuget.rs"]
mod nuget;
use golang::GolangSource;
use maven::MavenSource;
use nuget::NugetSource;
const MAVEN_METADATA: &str = include_str!("fixtures/sources/jvm_go/maven-metadata.xml");
const NUGET_INDEX: &str = include_str!("fixtures/sources/jvm_go/nuget-index.json");
const NUGET_PAGE: &str = include_str!("fixtures/sources/jvm_go/nuget-page.json");
const GO_LIST: &str = include_str!("fixtures/sources/jvm_go/go-list.txt");
const GO_INFO: &str = include_str!("fixtures/sources/jvm_go/go-info.json");
const MAVEN_GROUP: &str = "https://repo1.maven.org/maven2/com/acme/acme-widget";
const MAVEN_METADATA_URL: &str =
"https://repo1.maven.org/maven2/com/acme/acme-widget/maven-metadata.xml";
const SNAPSHOT_METADATA_URL: &str =
"https://repo1.maven.org/maven2/com/acme/acme-widget/2.0.0-SNAPSHOT/maven-metadata.xml";
const NUGET_INDEX_URL: &str =
"https://api.nuget.org/v3/registration5-gz-semver2/acme.widget/index.json";
const NUGET_PAGE_URL: &str =
"https://api.nuget.org/v3/registration5-gz-semver2/acme.widget/page/2.json";
const GO_MODULE: &str = "github.com/Acme/Widget";
const GO_BASE: &str = "https://proxy.golang.org/github.com/!acme/!widget";
const GO_LIST_URL: &str = "https://proxy.golang.org/github.com/!acme/!widget/@v/list";
const SHA256: &str = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
// ---------------------------------------------------------------------------
// Scripted RegistryHttp fake
// ---------------------------------------------------------------------------
#[derive(Clone, Debug)]
enum Reply {
Json(Value),
Text(String),
Size(u64),
Bytes(Vec<u8>),
Error(String),
}
#[derive(Default)]
struct FakeHttp {
replies: Mutex<HashMap<String, VecDeque<Reply>>>,
calls: Mutex<Vec<String>>,
}
impl FakeHttp {
fn new(routes: Vec<(&str, Reply)>) -> Self {
let fake = Self::default();
for (url, reply) in routes {
fake.enqueue(url, reply);
}
fake
}
fn enqueue(&self, url: &str, reply: Reply) {
self.replies
.lock()
.unwrap()
.entry(url.to_owned())
.or_default()
.push_back(reply);
}
fn calls(&self) -> Vec<String> {
self.calls.lock().unwrap().clone()
}
fn take(&self, kind: &str, url: &str) -> anyhow::Result<Reply> {
self.calls.lock().unwrap().push(format!("{kind} {url}"));
self.replies
.lock()
.unwrap()
.get_mut(url)
.and_then(VecDeque::pop_front)
.ok_or_else(|| anyhow::anyhow!("unexpected {kind} {url}"))
}
}
fn reply_or_error(reply: Reply) -> anyhow::Result<Reply> {
match reply {
Reply::Error(message) => Err(anyhow::anyhow!(message)),
other => Ok(other),
}
}
#[async_trait]
impl RegistryHttp for FakeHttp {
async fn get_json(&self, url: &str) -> anyhow::Result<Value> {
match reply_or_error(self.take("json", url)?)? {
Reply::Json(value) => Ok(value),
other => Err(anyhow::anyhow!("expected JSON for {url}, got {other:?}")),
}
}
async fn get_text(&self, url: &str) -> anyhow::Result<String> {
match reply_or_error(self.take("text", url)?)? {
Reply::Text(value) => Ok(value),
other => Err(anyhow::anyhow!("expected text for {url}, got {other:?}")),
}
}
async fn head_size(&self, url: &str) -> anyhow::Result<u64> {
match reply_or_error(self.take("head", url)?)? {
Reply::Size(value) => Ok(value),
other => Err(anyhow::anyhow!("expected size for {url}, got {other:?}")),
}
}
async fn download(&self, url: &str) -> anyhow::Result<Vec<u8>> {
match reply_or_error(self.take("download", url)?)? {
Reply::Bytes(value) => Ok(value),
other => Err(anyhow::anyhow!("expected bytes for {url}, got {other:?}")),
}
}
}
fn dyn_http(fake: &Arc<FakeHttp>) -> Arc<dyn RegistryHttp> {
fake.clone()
}
fn empty_http() -> Arc<dyn RegistryHttp> {
Arc::new(FakeHttp::default())
}
fn fixture(raw: &str) -> Value {
serde_json::from_str(raw).expect("fixture JSON")
}
fn project(purl_type: &str, name: &str) -> ProjectRef {
ProjectRef {
purl_type: purl_type.to_owned(),
name: name.to_owned(),
purl: format!("pkg:{purl_type}/{name}"),
}
}
fn version(raw: &str) -> VersionInfo {
VersionInfo {
raw: raw.to_owned(),
version: raw.to_owned(),
deprecated: false,
reason: String::new(),
}
}
fn all_capabilities() -> SourceCapabilities {
SourceCapabilities {
versions: true,
artifacts: true,
statuses: true,
project_meta: true,
}
}
// ---------------------------------------------------------------------------
// Maven
// ---------------------------------------------------------------------------
#[tokio::test]
async fn maven_versions_are_newest_first_and_deduped() {
let http = Arc::new(FakeHttp::new(vec![(
MAVEN_METADATA_URL,
Reply::Text(MAVEN_METADATA.to_owned()),
)]));
let source = MavenSource::new(dyn_http(&http));
let versions = source
.versions(&project("maven", "com.acme:acme-widget"))
.await
.expect("maven versions");
assert_eq!(
versions
.iter()
.map(|entry| (entry.raw.as_str(), entry.version.as_str()))
.collect::<Vec<_>>(),
vec![
("2.0.0-SNAPSHOT", "2.0.0-snapshot"),
("1.2.3", "1.2.3"),
("1.2.2", "1.2.2"),
("1.1.0", "1.1.0"),
],
"newest first, duplicate raw versions collapsed"
);
assert_eq!(http.calls(), vec![format!("text {MAVEN_METADATA_URL}")]);
}
#[tokio::test]
async fn maven_artifacts_include_standard_files_without_sidecars() {
let http = Arc::new(FakeHttp::default());
let source = MavenSource::new(dyn_http(&http));
let artifacts = source
.artifacts(&project("maven", "com.acme:acme-widget"), &version("1.2.3"))
.await
.expect("maven artifacts");
assert_eq!(
artifacts
.iter()
.map(|artifact| artifact.file_name.as_str())
.collect::<Vec<_>>(),
vec![
"acme-widget-1.2.3-sources.jar",
"acme-widget-1.2.3.jar",
"acme-widget-1.2.3.pom",
]
);
assert_eq!(
artifacts[1].url,
format!("{MAVEN_GROUP}/1.2.3/acme-widget-1.2.3.jar")
);
assert!(artifacts.iter().all(|artifact| artifact.sha256.is_none()));
assert!(artifacts.iter().all(|artifact| artifact.size.is_none()));
assert!(
http.calls().is_empty(),
"no sidecar, HEAD, or download requests by default"
);
}
#[tokio::test]
async fn maven_snapshot_metadata_adds_classifier_artifacts() {
let http = Arc::new(FakeHttp::new(vec![(
SNAPSHOT_METADATA_URL,
Reply::Text(MAVEN_METADATA.to_owned()),
)]));
let source = MavenSource::new(dyn_http(&http));
let artifacts = source
.artifacts(
&project("maven", "com.acme:acme-widget"),
&version("2.0.0-SNAPSHOT"),
)
.await
.expect("maven snapshot artifacts");
let urls = artifacts
.iter()
.map(|artifact| artifact.url.as_str())
.collect::<Vec<_>>();
assert_eq!(artifacts.len(), 6, "three standard plus three classified");
for expected in [
format!("{MAVEN_GROUP}/2.0.0-SNAPSHOT/acme-widget-2.0.0-20251102.100000-1-sources.jar"),
format!("{MAVEN_GROUP}/2.0.0-SNAPSHOT/acme-widget-2.0.0-20251102.100000-1-javadoc.jar"),
format!("{MAVEN_GROUP}/2.0.0-SNAPSHOT/acme-widget-2.0.0-20251102.100000-1.pom"),
] {
assert!(urls.contains(&expected.as_str()), "missing {expected}");
}
let javadoc = artifacts
.iter()
.find(|artifact| artifact.file_name.ends_with("-javadoc.jar"))
.expect("javadoc classifier");
assert_eq!(
javadoc.mime_type.as_deref(),
Some("application/java-archive")
);
assert_eq!(http.calls(), vec![format!("text {SNAPSHOT_METADATA_URL}")]);
}
#[tokio::test]
async fn maven_sha256_sidecars_are_opt_in_and_sha1_is_never_read() {
let jar = format!("{MAVEN_GROUP}/1.2.3/acme-widget-1.2.3.jar");
let http = Arc::new(FakeHttp::new(vec![(
&format!("{jar}.sha256"),
Reply::Text(format!("{SHA256} acme-widget-1.2.3.jar")),
)]));
let source = MavenSource::new(dyn_http(&http)).with_sha256_sidecars(true);
let artifacts = source
.artifacts(&project("maven", "com.acme:acme-widget"), &version("1.2.3"))
.await
.expect("maven artifacts with sidecars");
let jar_artifact = artifacts
.iter()
.find(|artifact| artifact.file_name == "acme-widget-1.2.3.jar")
.expect("jar artifact");
assert_eq!(jar_artifact.sha256.as_deref(), Some(SHA256));
assert!(
artifacts
.iter()
.filter(|artifact| artifact.file_name != "acme-widget-1.2.3.jar")
.all(|artifact| artifact.sha256.is_none()),
"missing sidecars are advisory"
);
assert!(
http.calls().iter().all(|call| !call.contains(".sha1")),
"a SHA-1 sidecar is never relabeled as SHA-256"
);
}
#[tokio::test]
async fn maven_project_meta_reads_metadata_and_survives_absence() {
let http = Arc::new(FakeHttp::new(vec![(
MAVEN_METADATA_URL,
Reply::Text(MAVEN_METADATA.to_owned()),
)]));
let source = MavenSource::new(dyn_http(&http));
let meta = source
.project_meta(&project("maven", "com.acme:acme-widget"))
.await
.expect("maven meta");
assert_eq!(meta["groupId"], "com.acme");
assert_eq!(meta["artifactId"], "acme-widget");
assert_eq!(meta["repository"], MAVEN_GROUP);
assert_eq!(meta["latest"], "1.2.3");
assert_eq!(meta["release"], "1.2.3");
assert_eq!(meta["license"], "Apache-2.0");
let source = MavenSource::new(empty_http());
let meta = source
.project_meta(&project("maven", "com.acme:acme-widget"))
.await
.expect("maven meta without metadata");
assert_eq!(meta["groupId"], "com.acme");
assert_eq!(meta["artifactId"], "acme-widget");
assert_eq!(meta["license"], Value::Null);
}
#[test]
fn maven_capabilities_exclude_statuses() {
let source = MavenSource::new(empty_http());
assert_eq!(source.name(), "maven");
assert_eq!(
source.capabilities(),
SourceCapabilities {
versions: true,
artifacts: true,
statuses: false,
project_meta: true,
}
);
}
// ---------------------------------------------------------------------------
// NuGet
// ---------------------------------------------------------------------------
#[tokio::test]
async fn nuget_versions_follow_registration_pages_and_listing_state() {
let http = Arc::new(FakeHttp::new(vec![
(NUGET_INDEX_URL, Reply::Json(fixture(NUGET_INDEX))),
(NUGET_PAGE_URL, Reply::Json(fixture(NUGET_PAGE))),
]));
let source = NugetSource::new(dyn_http(&http));
let versions = source
.versions(&project("nuget", "Acme.Widget"))
.await
.expect("nuget versions");
assert_eq!(
versions
.iter()
.map(|entry| { (entry.raw.as_str(), entry.deprecated, entry.reason.as_str(),) })
.collect::<Vec<_>>(),
vec![
("1.0.0", true, "unlisted"),
("1.1.0", true, "Use Acme.Widget2"),
("1.1.1", true, "CriticalBugs"),
("1.2.3", false, ""),
]
);
assert_eq!(
http.calls(),
vec![
format!("json {NUGET_INDEX_URL}"),
format!("json {NUGET_PAGE_URL}"),
],
"the referenced page is fetched exactly once"
);
}
#[tokio::test]
async fn nuget_artifacts_use_package_content_without_inventing_digests() {
let http = Arc::new(FakeHttp::new(vec![
(NUGET_INDEX_URL, Reply::Json(fixture(NUGET_INDEX))),
(NUGET_PAGE_URL, Reply::Json(fixture(NUGET_PAGE))),
]));
let source = NugetSource::new(dyn_http(&http));
let artifacts = source
.artifacts(&project("nuget", "Acme.Widget"), &version("1.2.3"))
.await
.expect("nuget artifacts");
assert_eq!(artifacts.len(), 1);
assert_eq!(
artifacts[0].url,
"https://api.nuget.org/v3-flatcontainer/acme.widget/1.2.3/acme.widget.1.2.3.nupkg"
);
assert_eq!(artifacts[0].file_name, "acme.widget.1.2.3.nupkg");
assert_eq!(artifacts[0].size, Some(12345));
assert_eq!(artifacts[0].sha256, None);
assert_eq!(artifacts[0].mime_type.as_deref(), Some("application/zip"));
assert!(
http.calls().iter().all(|call| !call.starts_with("head ")),
"declared packageSize needs no HEAD"
);
}
#[tokio::test]
async fn nuget_statuses_are_typed_unlisted_and_deprecation_signals() {
let routes = || {
vec![
(NUGET_INDEX_URL, Reply::Json(fixture(NUGET_INDEX))),
(NUGET_PAGE_URL, Reply::Json(fixture(NUGET_PAGE))),
(NUGET_INDEX_URL, Reply::Json(fixture(NUGET_INDEX))),
(NUGET_PAGE_URL, Reply::Json(fixture(NUGET_PAGE))),
(NUGET_INDEX_URL, Reply::Json(fixture(NUGET_INDEX))),
(NUGET_PAGE_URL, Reply::Json(fixture(NUGET_PAGE))),
(NUGET_INDEX_URL, Reply::Json(fixture(NUGET_INDEX))),
(NUGET_PAGE_URL, Reply::Json(fixture(NUGET_PAGE))),
]
};
let http = Arc::new(FakeHttp::new(routes()));
let source = NugetSource::new(dyn_http(&http));
let project = project("nuget", "Acme.Widget");
let unlisted = source.statuses(&project, &version("1.0.0")).await.unwrap();
assert_eq!(unlisted.len(), 1);
assert_eq!(unlisted[0].status, "deprecated");
assert_eq!(unlisted[0].kind.as_deref(), Some("registry"));
assert_eq!(unlisted[0].reason, "unlisted");
let legacy = source.statuses(&project, &version("1.1.0")).await.unwrap();
assert_eq!(legacy.len(), 1);
assert_eq!(legacy[0].status, "deprecated");
assert_eq!(legacy[0].kind.as_deref(), Some("registry"));
assert_eq!(legacy[0].reason, "Use Acme.Widget2");
let critical = source.statuses(&project, &version("1.1.1")).await.unwrap();
assert_eq!(critical.len(), 1);
assert_eq!(critical[0].status, "deprecated");
assert_eq!(critical[0].kind.as_deref(), Some("broken"));
assert_eq!(critical[0].reason, "CriticalBugs");
assert!(
source
.statuses(&project, &version("1.2.3"))
.await
.unwrap()
.is_empty()
);
}
#[tokio::test]
async fn nuget_project_meta_reports_license_project_and_repository() {
let http = Arc::new(FakeHttp::new(vec![
(NUGET_INDEX_URL, Reply::Json(fixture(NUGET_INDEX))),
(NUGET_PAGE_URL, Reply::Json(fixture(NUGET_PAGE))),
]));
let source = NugetSource::new(dyn_http(&http));
let meta = source
.project_meta(&project("nuget", "Acme.Widget"))
.await
.expect("nuget meta");
assert_eq!(meta["name"], "Acme.Widget");
assert_eq!(meta["latest"], "1.2.3");
assert_eq!(meta["description"], "Synthetic NuGet fixture package");
assert_eq!(meta["homepage"], "https://example.invalid/acme-widget");
assert_eq!(meta["project_url"], "https://example.invalid/acme-widget");
assert_eq!(meta["license"], "MIT");
assert_eq!(
meta["repository"],
"https://example.invalid/acme-widget.git"
);
}
#[test]
fn nuget_advertises_all_capabilities() {
let source = NugetSource::new(empty_http());
assert_eq!(source.name(), "nuget");
assert_eq!(source.capabilities(), all_capabilities());
}
// ---------------------------------------------------------------------------
// Go modules
// ---------------------------------------------------------------------------
#[tokio::test]
async fn golang_escapes_module_paths_and_skips_pseudo_versions() {
let http = Arc::new(FakeHttp::new(vec![
(GO_LIST_URL, Reply::Text(GO_LIST.to_owned())),
(GO_LIST_URL, Reply::Text(GO_LIST.to_owned())),
]));
let source = GolangSource::new(dyn_http(&http));
let project = project("golang", GO_MODULE);
let versions = source.versions(&project).await.expect("go versions");
assert_eq!(
versions
.iter()
.map(|entry| entry.raw.as_str())
.collect::<Vec<_>>(),
vec!["v1.0.0-rc.1", "v1.1.0", "v1.2.3"],
"pseudo-versions are skipped by default and order is deterministic"
);
assert_eq!(http.calls(), vec![format!("text {GO_LIST_URL}")]);
let inclusive = GolangSource::new(dyn_http(&http)).include_pseudo_versions(true);
let versions = inclusive.versions(&project).await.expect("go versions");
assert_eq!(
versions
.iter()
.map(|entry| entry.raw.as_str())
.collect::<Vec<_>>(),
vec![
"v0.0.0-20240101120000-abcdef123456",
"v1.0.0-rc.1",
"v1.1.0",
"v1.2.3",
]
);
}
#[tokio::test]
async fn golang_artifacts_are_zip_and_mod_without_digests() {
let http = Arc::new(FakeHttp::default());
let source = GolangSource::new(dyn_http(&http));
let artifacts = source
.artifacts(&project("golang", GO_MODULE), &version("v1.2.3"))
.await
.expect("go artifacts");
assert_eq!(
artifacts
.iter()
.map(|artifact| {
(
artifact.url.as_str(),
artifact.file_name.as_str(),
artifact.sha256.as_deref(),
artifact.size,
artifact.mime_type.as_deref(),
)
})
.collect::<Vec<_>>(),
vec![
(
"https://proxy.golang.org/github.com/!acme/!widget/@v/v1.2.3.zip",
"Widget-v1.2.3.zip",
None,
None,
Some("application/zip"),
),
(
"https://proxy.golang.org/github.com/!acme/!widget/@v/v1.2.3.mod",
"Widget-v1.2.3.mod",
None,
None,
Some("text/plain"),
),
],
"go.sum hashes are never relabeled as SHA-256"
);
assert!(http.calls().is_empty(), "no HEAD or download requests");
let uppercase = source
.artifacts(&project("golang", GO_MODULE), &version("v1.3.0-RC1"))
.await
.expect("go uppercase artifact");
assert_eq!(
uppercase[0].url,
"https://proxy.golang.org/github.com/!acme/!widget/@v/v1.3.0-!r!c1.zip"
);
}
#[tokio::test]
async fn golang_statuses_surface_retractions_and_project_meta_lists_versions() {
let info_url = format!("{GO_BASE}/@v/v1.2.3.info");
let active_url = format!("{GO_BASE}/@v/v1.1.0.info");
let latest_url = format!("{GO_BASE}/@latest");
let http = Arc::new(FakeHttp::new(vec![
(info_url.as_str(), Reply::Json(fixture(GO_INFO))),
(
active_url.as_str(),
Reply::Json(json!({"Version": "v1.1.0", "Time": "2024-03-01T10:00:00Z"})),
),
(GO_LIST_URL, Reply::Text(GO_LIST.to_owned())),
(
latest_url.as_str(),
Reply::Json(json!({"Version": "v1.2.3", "Time": "2024-04-01T10:00:00Z"})),
),
]));
let source = GolangSource::new(dyn_http(&http));
let project = project("golang", GO_MODULE);
let retracted = source
.statuses(&project, &version("v1.2.3"))
.await
.expect("go statuses");
assert_eq!(retracted.len(), 1);
assert_eq!(retracted[0].status, "retracted");
assert_eq!(retracted[0].kind.as_deref(), Some("registry"));
assert_eq!(retracted[0].reason, "security issue");
assert!(
source
.statuses(&project, &version("v1.1.0"))
.await
.unwrap()
.is_empty()
);
let meta = source.project_meta(&project).await.expect("go meta");
assert_eq!(meta["module"], GO_MODULE);
assert_eq!(meta["versions"], json!(["v1.0.0-rc.1", "v1.1.0", "v1.2.3"]));
assert_eq!(meta["latest"], "v1.2.3");
}
#[test]
fn golang_pseudo_version_detection_and_capabilities() {
assert!(golang::is_pseudo_version(
"v0.0.0-20240101120000-abcdef123456"
));
assert!(golang::is_pseudo_version(
"v1.2.4-0.20240101120000-abcdef123456"
));
assert!(golang::is_pseudo_version(
"v1.2.3-pre.0.20240101120000-abcdef123456"
));
assert!(!golang::is_pseudo_version("v1.2.3"));
assert!(!golang::is_pseudo_version("v1.2.3-rc.1"));
let source = GolangSource::new(empty_http());
assert_eq!(source.name(), "golang");
assert_eq!(source.capabilities(), all_capabilities());
}