Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/bors/handlers/review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,23 @@ approved = ["+approved"]
.await;
}

#[sqlx::test]
async fn approve_with_known_reviewer_different_case(pool: sqlx::PgPool) {
run_test(pool, async |ctx: &mut BorsTester| {
ctx.post_comment("@bors r=DEFAULT-USER").await?;
insta::assert_snapshot!(
ctx.get_next_comment_text(()).await?,
@"
:pushpin: Commit pr-1-sha has been approved by `DEFAULT-USER`

It is now in the [queue](https://bors-test.com/queue/borstest) for this repository.
"
);
Ok(())
})
.await;
}

#[sqlx::test]
async fn insufficient_permission_approve(pool: sqlx::PgPool) {
run_test(pool, async |ctx: &mut BorsTester| {
Expand Down
9 changes: 7 additions & 2 deletions src/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ impl UserPermissions {
) -> Self {
Self {
review_users,
review_usernames,
review_usernames: review_usernames
.into_iter()
.map(|username| username.to_lowercase())
.collect(),
try_users,
}
}
Expand All @@ -48,8 +51,10 @@ impl UserPermissions {
}
}

/// Checks if the given username is a valid reviewer.
/// The usernames are checked in a case-insensitive manner.
pub fn has_reviewer(&self, username: &str) -> bool {
self.review_usernames.contains(username)
self.review_usernames.contains(&username.to_lowercase())
}
}

Expand Down