Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle committed Apr 9, 2024
1 parent df01500 commit b4c892b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
15 changes: 12 additions & 3 deletions src/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,19 @@ pub fn check(ctx: crate::CheckCtx<'_, ValidConfig>, sink: impl Into<ErrorSink>)
};
get_org(url)
}) {
// .to_lowercase() (ln. 113) enables case insensitivity, as GitHub and
// GitLab are case insensitive in regards to namespaces.
let lowered = (!orgname.is_ascii()).then(|| orgname.to_lowercase());

if let Some(ind) = ctx.cfg.allowed_orgs.iter().position(|(sorgt, sorgn)| {
orgt == *sorgt && sorgn.value.as_str().to_lowercase() == orgname.to_lowercase()
let s = sorgn.value.as_str();
if orgt != *sorgt || s.len() != orgname.len() {
return false;
}

if let Some(orgname_lower) = &lowered {
orgname_lower == &s.to_lowercase()
} else {
s.eq_ignore_ascii_case(orgname)
}
}) {
org_hits.as_mut_bitslice().set(ind, true);
diags::SourceAllowedByOrg {
Expand Down
4 changes: 2 additions & 2 deletions tests/snapshots/sources__allows_github_org.snap
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ expression: diags
"column": 16,
"line": 3,
"message": "organization allowance",
"span": "EmbarkStudios"
"span": "embarkstudios"
}
],
"message": "source allowed by organization allowance",
Expand Down Expand Up @@ -211,7 +211,7 @@ expression: diags
"column": 16,
"line": 3,
"message": "organization allowance",
"span": "EmbarkStudios"
"span": "embarkstudios"
}
],
"message": "source allowed by organization allowance",
Expand Down
2 changes: 1 addition & 1 deletion tests/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn allows_github_org() {
// We shouldn't have any errors for the embark urls now
let cfg = "unknown-git = 'deny'
[allow-org]
github = ['EmbarkStudios']
github = ['embarkstudios']
";

let diags = src_check(func_name!(), KrateGather::new("sources"), cfg);
Expand Down

0 comments on commit b4c892b

Please sign in to comment.