1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use http::header::AUTHORIZATION;
use Credentials;
header! {
/// `Authorization` header, defined in [RFC7235](https://tools.ietf.org/html/rfc7235#section-4.2)
///
/// The `Authorization` header field allows a user agent to authenticate
/// itself with an origin server -- usually, but not necessarily, after
/// receiving a 401 (Unauthorized) response. Its value consists of
/// credentials containing the authentication information of the user
/// agent for the realm of the resource being requested.
///
/// # ABNF
///
/// ```text
/// Authorization = credentials
/// ```
///
/// # Example values
/// * `Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==`
/// * `Bearer fpKL54jvWmEGVoRdCNjG`
(Authorization, AUTHORIZATION) => [Credentials]
}
#[cfg(test)]
mod test {
use super::*;
use {util, Token68};
#[test]
fn rfc1() {
util::test_round_trip(
&Authorization(Credentials::basic("Aladdin", "open sesame").unwrap()),
&["Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="],
);
}
#[test]
fn rfc2() {
util::test_round_trip(
&Authorization(Credentials::bearer(
Token68::new("fpKL54jvWmEGVoRdCNjG").unwrap(),
)),
&["Bearer fpKL54jvWmEGVoRdCNjG"],
);
}
}