File tree Expand file tree Collapse file tree 4 files changed +25
-3
lines changed Expand file tree Collapse file tree 4 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,16 @@ namespace {
59
59
}
60
60
}
61
61
62
+ bool TAuditCtx::AuditEnabled (NKikimrConfig::TAuditConfig::TLogClassConfig::ELogPhase logPhase, NACLibProto::ESubjectType subjectType)
63
+ {
64
+ if (NKikimr::HasAppData ()) {
65
+ return NKikimr::AppData ()->AuditConfig .EnableLogging (NKikimrConfig::TAuditConfig::TLogClassConfig::ClusterAdmin,
66
+ logPhase, subjectType);
67
+ }
68
+ return false ;
69
+ }
70
+
71
+
62
72
void TAuditCtx::AddAuditLogPart (TStringBuf name, const TString& value) {
63
73
Parts.emplace_back (name, value);
64
74
}
@@ -151,9 +161,7 @@ void TAuditCtx::SetSubjectType(NACLibProto::ESubjectType subjectType) {
151
161
}
152
162
153
163
void TAuditCtx::LogAudit (ERequestStatus status, const TString& reason, NKikimrConfig::TAuditConfig::TLogClassConfig::ELogPhase logPhase) {
154
- auto auditEnabled = NKikimr::AppData ()->AuditConfig .EnableLogging (NKikimrConfig::TAuditConfig::TLogClassConfig::ClusterAdmin, logPhase, SubjectType);
155
-
156
- if (!Auditable || !auditEnabled) {
164
+ if (!Auditable || !AuditEnabled (logPhase, SubjectType)) {
157
165
return ;
158
166
}
159
167
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ class TAuditCtx {
26
26
void LogOnReceived ();
27
27
void LogOnCompleted (const NHttp::THttpOutgoingResponsePtr& response);
28
28
void SetSubjectType (NACLibProto::ESubjectType subjectType);
29
+ static bool AuditEnabled (NKikimrConfig::TAuditConfig::TLogClassConfig::ELogPhase logPhase, NACLibProto::ESubjectType subjectType);
29
30
30
31
private:
31
32
void AddAuditLogPart (TStringBuf name, const TString& value);
Original file line number Diff line number Diff line change
1
+ #include < ydb/core/mon/audit/audit.h>
2
+
3
+ #include < library/cpp/testing/unittest/registar.h>
4
+ #include < library/cpp/testing/unittest/tests_data.h>
5
+
6
+ using namespace NMonitoring ::NAudit;
7
+
8
+ Y_UNIT_TEST_SUITE (TAuditTest) {
9
+ Y_UNIT_TEST (AuditDisabledWithoutAppData) {
10
+ UNIT_ASSERT (!TAuditCtx::AuditEnabled (NKikimrConfig::TAuditConfig::TLogClassConfig::Completed, NACLibProto::SUBJECT_TYPE_ANONYMOUS));
11
+ }
12
+ }
Original file line number Diff line number Diff line change 9
9
)
10
10
11
11
SRCS(
12
+ audit_ut.cpp
12
13
url_matcher_ut.cpp
13
14
)
14
15
You can’t perform that action at this time.
0 commit comments