Repository navigation
Expand file tree
/
Copy pathtests.rs
More file actions
98 lines (90 loc) · 2.65 KB
/
Copy pathtests.rs
File metadata and controls
98 lines (90 loc) · 2.65 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
#![cfg(test)]
use super::*;
#[tokio::test]
async fn approve_all_handler_returns_approved() {
let result = ApproveAllHandler
.handle(
SessionId::from("s1"),
RequestId::new("1"),
PermissionRequestData::default(),
)
.await;
assert!(matches!(
result,
PermissionResult::Decision {
decision: PermissionDecision::ApproveOnce(_),
..
}
));
}
#[tokio::test]
async fn approve_all_handler_fails_when_managed_settings_enabled() {
let result = ApproveAllHandler
.handle(
SessionId::from("s1"),
RequestId::new("1"),
PermissionRequestData {
managed_settings_enabled: true,
..Default::default()
},
)
.await;
assert!(matches!(
result,
PermissionResult::Decision {
decision: PermissionDecision::UserNotAvailable(_),
..
}
));
}
#[tokio::test]
async fn approve_all_handler_leaves_managed_approval_pending() {
let result = ApproveAllHandler
.handle(
SessionId::from("s1"),
RequestId::new("1"),
PermissionRequestData {
managed_approval_required: Some(true),
..Default::default()
},
)
.await;
assert!(matches!(result, PermissionResult::NoResult));
}
#[tokio::test]
async fn deny_all_handler_returns_denied() {
let result = DenyAllHandler
.handle(
SessionId::from("s1"),
RequestId::new("1"),
PermissionRequestData::default(),
)
.await;
assert!(matches!(
result,
PermissionResult::Decision {
decision: PermissionDecision::Reject(_),
..
}
));
}
#[test]
fn mcp_auth_result_token_converts_to_wire_response() {
let wire = McpAuthResult::Token {
access_token: "host-token".to_string(),
token_type: Some("Bearer".to_string()),
expires_in: Some(3600),
}
.into_wire();
match wire {
McpOauthPendingRequestResponse::Token(token) => {
assert_eq!(token.access_token, "host-token");
assert_eq!(token.token_type.as_deref(), Some("Bearer"));
assert_eq!(token.expires_in, Some(3600));
}
McpOauthPendingRequestResponse::Cancelled(_) => panic!("expected token response"),
}
}