mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-30 18:34:36 +01:00
Merge pull request #58 from adamchalmers/patch-1
Bugfix: AuthenticationError should set status_code
This commit is contained in:
commit
61d5586052
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [unreleased]
|
||||
- Update the `base64` dependency to 0.12
|
||||
- AuthenticationError's status code is preserved when converting to a ResponseError
|
||||
|
||||
## [0.4.1] - 2020-02-19
|
||||
- Move repository to actix-extras
|
||||
|
@ -57,4 +57,26 @@ impl<C: 'static + Challenge> ResponseError for AuthenticationError<C> {
|
||||
.set(WwwAuthenticate(self.challenge.clone()))
|
||||
.finish()
|
||||
}
|
||||
|
||||
fn status_code(&self) -> StatusCode {
|
||||
self.status_code
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::headers::www_authenticate::basic::Basic;
|
||||
use actix_web::Error;
|
||||
|
||||
#[test]
|
||||
fn test_status_code_is_preserved_across_error_conversions() {
|
||||
let ae: AuthenticationError<Basic> = AuthenticationError::new(Basic::default());
|
||||
let expected = ae.status_code;
|
||||
|
||||
// Converting the AuthenticationError into a ResponseError should preserve the status code.
|
||||
let e = Error::from(ae);
|
||||
let re = e.as_response_error();
|
||||
assert_eq!(expected, re.status_code());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user