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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//! MockClient helpers for Azure Defender for Cloud API.
//!
//! Auto-generated extension methods for ergonomic test setup.
//! **Do not edit manually** — modify the manifest and re-run codegen.
#[cfg(any(test, feature = "test-support"))]
use crate::mock_client::{ExpectationBuilder, MockClient};
/// Extension trait for MockClient with Azure Defender for Cloud helpers.
#[cfg(any(test, feature = "test-support"))]
pub trait SecurityMockHelpers {
/// Helper to expect `list_alerts`: List all the alerts that are associated with the
/// subscription.
fn expect_list_alerts(&mut self, subscription_id: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `get_alert`: Get an alert that is associated with a resource group or a
/// resource in a resource group.
fn expect_get_alert(
&mut self,
subscription_id: &str,
resource_group_name: &str,
asc_location: &str,
alert_name: &str,
) -> ExpectationBuilder<'_>;
/// Helper to expect `update_alert_status`: Update the alert's state (activate, dismiss,
/// resolve, inProgress, close).
fn expect_update_alert_status(
&mut self,
subscription_id: &str,
resource_group_name: &str,
asc_location: &str,
alert_name: &str,
alert_update_action_type: &str,
) -> ExpectationBuilder<'_>;
/// Helper to expect `list_secure_scores`: List secure scores for all your Microsoft Defender
/// for Cloud initiatives within a subscription.
fn expect_list_secure_scores(&mut self, subscription_id: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `get_secure_score`: Get secure score for a specific Microsoft Defender for
/// Cloud initiative within the current scope.
fn expect_get_secure_score(
&mut self,
subscription_id: &str,
secure_score_name: &str,
) -> ExpectationBuilder<'_>;
/// Helper to expect `list_assessments`: Get security assessments on all your scanned resources
/// inside a subscription scope.
fn expect_list_assessments(&mut self, subscription_id: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `get_assessment`: Get a security assessment on your scanned resource.
fn expect_get_assessment(
&mut self,
subscription_id: &str,
assessment_name: &str,
) -> ExpectationBuilder<'_>;
}
#[cfg(any(test, feature = "test-support"))]
impl SecurityMockHelpers for MockClient {
/// Helper to expect `list_alerts`: List all the alerts that are associated with the
/// subscription.
fn expect_list_alerts(
&mut self,
subscription_id: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/subscriptions/{subscription_id}/providers/Microsoft.Security/alerts");
self.expect_get(&path)
}
/// Helper to expect `get_alert`: Get an alert that is associated with a resource group or a
/// resource in a resource group.
fn expect_get_alert(
&mut self,
subscription_id: &str,
resource_group_name: &str,
asc_location: &str,
alert_name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Security/locations/{asc_location}/alerts/{alert_name}"
);
self.expect_get(&path)
}
/// Helper to expect `update_alert_status`: Update the alert's state (activate, dismiss,
/// resolve, inProgress, close).
fn expect_update_alert_status(
&mut self,
subscription_id: &str,
resource_group_name: &str,
asc_location: &str,
alert_name: &str,
alert_update_action_type: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Security/locations/{asc_location}/alerts/{alert_name}/{alert_update_action_type}"
);
self.expect_post(&path)
}
/// Helper to expect `list_secure_scores`: List secure scores for all your Microsoft Defender
/// for Cloud initiatives within a subscription.
fn expect_list_secure_scores(
&mut self,
subscription_id: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path =
format!("/subscriptions/{subscription_id}/providers/Microsoft.Security/secureScores");
self.expect_get(&path)
}
/// Helper to expect `get_secure_score`: Get secure score for a specific Microsoft Defender for
/// Cloud initiative within the current scope.
fn expect_get_secure_score(
&mut self,
subscription_id: &str,
secure_score_name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/providers/Microsoft.Security/secureScores/{secure_score_name}"
);
self.expect_get(&path)
}
/// Helper to expect `list_assessments`: Get security assessments on all your scanned resources
/// inside a subscription scope.
fn expect_list_assessments(
&mut self,
subscription_id: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path =
format!("/subscriptions/{subscription_id}/providers/Microsoft.Security/assessments");
self.expect_get(&path)
}
/// Helper to expect `get_assessment`: Get a security assessment on your scanned resource.
fn expect_get_assessment(
&mut self,
subscription_id: &str,
assessment_name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!(
"/subscriptions/{subscription_id}/providers/Microsoft.Security/assessments/{assessment_name}"
);
self.expect_get(&path)
}
}