@@ -169,10 +169,13 @@ pub(crate) async fn build_trigger_rebuild_handler(
169
169
) ) ) ) ?;
170
170
171
171
// (Future: would it be better to have standard middleware handle auth?)
172
- let TypedHeader ( auth_header) =
173
- opt_auth_header. ok_or ( JsonAxumNope ( AxumNope :: MissingAuthenticationToken ) ) ?;
172
+ let TypedHeader ( auth_header) = opt_auth_header. ok_or ( JsonAxumNope ( AxumNope :: Unauthorized (
173
+ "Missing authentication token" ,
174
+ ) ) ) ?;
174
175
if auth_header. token ( ) != expected_token {
175
- return Err ( JsonAxumNope ( AxumNope :: InvalidAuthenticationToken ) ) ;
176
+ return Err ( JsonAxumNope ( AxumNope :: Unauthorized (
177
+ "The token used for authentication is not valid" ,
178
+ ) ) ) ;
176
179
}
177
180
178
181
build_trigger_check ( conn, & name, & version, & build_queue)
@@ -377,7 +380,6 @@ mod tests {
377
380
let response = env. frontend ( ) . post ( "/crate/regex/1.3.1/rebuild" ) . send ( ) ?;
378
381
assert_eq ! ( response. status( ) , StatusCode :: INTERNAL_SERVER_ERROR ) ;
379
382
let text = response. text ( ) ?;
380
- assert ! ( text. contains( "access token `trigger_rebuild_token` is not configured" ) ) ;
381
383
let json: serde_json:: Value = serde_json:: from_str ( & text) ?;
382
384
assert_eq ! (
383
385
json,
@@ -408,8 +410,8 @@ mod tests {
408
410
assert_eq ! (
409
411
json,
410
412
serde_json:: json!( {
411
- "title" : "Missing authentication token " ,
412
- "message" : "The token used for authentication is missing "
413
+ "title" : "Unauthorized " ,
414
+ "message" : "Missing authentication token "
413
415
} )
414
416
) ;
415
417
}
@@ -426,7 +428,7 @@ mod tests {
426
428
assert_eq ! (
427
429
json,
428
430
serde_json:: json!( {
429
- "title" : "Invalid authentication token " ,
431
+ "title" : "Unauthorized " ,
430
432
"message" : "The token used for authentication is not valid"
431
433
} )
432
434
) ;
0 commit comments