Add tests for lack of auth on userinfo endpoint
Signed-off-by: Olivier 'reivilibre <olivier@librepush.net>
This commit is contained in:
parent
6f13cb6145
commit
e908ef7324
@ -0,0 +1,9 @@
|
||||
---
|
||||
source: src/tests/test_oidc_auth_flow.rs
|
||||
expression: "(headers, text)"
|
||||
---
|
||||
- access-control-allow-origin: "*"
|
||||
access-control-expose-headers: "*"
|
||||
content-length: "16"
|
||||
content-type: text/plain; charset=utf-8
|
||||
- No access token.
|
@ -0,0 +1,9 @@
|
||||
---
|
||||
source: src/tests/test_oidc_auth_flow.rs
|
||||
expression: "(headers, text)"
|
||||
---
|
||||
- access-control-allow-origin: "*"
|
||||
access-control-expose-headers: "*"
|
||||
content-length: "21"
|
||||
content-type: text/plain; charset=utf-8
|
||||
- Invalid access token.
|
@ -0,0 +1,9 @@
|
||||
---
|
||||
source: src/tests/test_oidc_auth_flow.rs
|
||||
expression: "(headers, text)"
|
||||
---
|
||||
- access-control-allow-origin: "*"
|
||||
access-control-expose-headers: "*"
|
||||
content-length: "28"
|
||||
content-type: text/plain; charset=utf-8
|
||||
- Invalid application session.
|
@ -187,3 +187,35 @@ async fn test_discovery_endpoint() {
|
||||
assert_eq!(status, 200);
|
||||
assert_yaml_snapshot!((headers, text));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_userinfo_bad_auth() {
|
||||
let sys = basic_system().await;
|
||||
let client = TestClient::new(sys.web);
|
||||
|
||||
// 1. no auth token
|
||||
let resp = client.get("/oidc/userinfo").send().await;
|
||||
let (status, headers, text) = dump_resp_text("1. no auth token", resp).await;
|
||||
assert_eq!(status, 401);
|
||||
assert_yaml_snapshot!("1. no auth token", (headers, text));
|
||||
|
||||
// 2. malformed access token
|
||||
let resp = client
|
||||
.get("/oidc/userinfo")
|
||||
.header("Authorization", "Bearer ++++")
|
||||
.send()
|
||||
.await;
|
||||
let (status, headers, text) = dump_resp_text("2. malformed auth token", resp).await;
|
||||
assert_eq!(status, 401);
|
||||
assert_yaml_snapshot!("2. malformed auth token", (headers, text));
|
||||
|
||||
// 3. wrong access token
|
||||
let resp = client
|
||||
.get("/oidc/userinfo")
|
||||
.header("Authorization", "Bearer aaaa")
|
||||
.send()
|
||||
.await;
|
||||
let (status, headers, text) = dump_resp_text("3. wrong auth token", resp).await;
|
||||
assert_eq!(status, 401);
|
||||
assert_yaml_snapshot!("3. wrong auth token", (headers, text));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user