Skip to content

Commit f5dd51d

Browse files
committed
fix auth header format in github repository update
1 parent 971d5d6 commit f5dd51d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • crates/lib/docs_rs_repository_stats/src

crates/lib/docs_rs_repository_stats/src/github.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl GitHub {
6767
if let Some(ref token) = config.github_accesstoken {
6868
headers.insert(
6969
AUTHORIZATION,
70-
HeaderValue::from_str(&format!("token {token}"))?,
70+
HeaderValue::from_str(&format!("Bearer {token}"))?,
7171
);
7272
} else {
7373
warn!("did not collect `github.com` stats as no token was provided");
@@ -268,6 +268,7 @@ mod tests {
268268
};
269269
use anyhow::Result;
270270
use docs_rs_config::AppConfig as _;
271+
use reqwest::header::AUTHORIZATION;
271272

272273
const TEST_TOKEN: &str = "qsjdnfqdq";
273274

@@ -297,6 +298,7 @@ mod tests {
297298
.with_body(
298299
r#"{"errors":[{"type":"RATE_LIMITED","message":"API rate limit exceeded"}]}"#,
299300
)
301+
.match_header(AUTHORIZATION, format!("Bearer {TEST_TOKEN}").as_str())
300302
.create();
301303

302304
match updater.fetch_repositories(&[String::new()]).await {
@@ -315,6 +317,7 @@ mod tests {
315317
.mock("POST", "/graphql")
316318
.with_header("content-type", "application/json")
317319
.with_body(r#"{"data": {"nodes": [], "rateLimit": {"remaining": 0}}}"#)
320+
.match_header(AUTHORIZATION, format!("Bearer {TEST_TOKEN}").as_str())
318321
.create();
319322

320323
match updater.fetch_repositories(&[String::new()]).await {
@@ -336,6 +339,7 @@ mod tests {
336339
r#"{"data": {"nodes": [], "rateLimit": {"remaining": 100000}}, "errors":
337340
[{"type": "NOT_FOUND", "path": ["nodes", 0], "message": "none"}]}"#,
338341
)
342+
.match_header(AUTHORIZATION, format!("Bearer {TEST_TOKEN}").as_str())
339343
.create();
340344

341345
match updater.fetch_repositories(&[String::new()]).await {
@@ -361,6 +365,7 @@ mod tests {
361365
"description": "this is", "stargazerCount": 10, "forkCount": 11,
362366
"issues": {"totalCount": 12}}}}"#,
363367
)
368+
.match_header(AUTHORIZATION, format!("Bearer {TEST_TOKEN}").as_str())
364369
.create();
365370

366371
let repo = updater

0 commit comments

Comments
 (0)