ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / platform / policy / test / node / nativeManagedSettingsService.test.ts 290 строк · изменён 14 нояб., 04:52
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
import assert from 'assert' ;
import { Emitter, Event } from '../../../../base/common/event.js' ;
import { Disposable } from '../../../../base/common/lifecycle.js' ;
import { ManagedSettingsData } from '../../../../base/common/policy.js' ;
import { IChannel } from '../../../../base/parts/ipc/common/ipc.js' ;
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js' ;
import { NullLogService } from '../../../log/common/log.js' ;
import { COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY ,
NativeManagedSettingsChannelClient
PolicyValue
NativeManagedSettingsService NativePolicyWatcherFactory
disposables
policyName
onDidChange update Record PolicyValue
watcherFactory _productName policies callback
assert policies
type
type
type
onDidChange callback
Disposable None
service disposables watcherFactory
service
policyName
type
managedSettings
type
onDidChange
assert service managedSettings
onDidChange
assert service managedSettings
watchedSettings Record type
watcherFactory _productName policies callback
watchedSettings policies
Disposable None
service disposables watcherFactory
service OtherPolicy type
assert
watchedSettings
managedSettings service managedSettings
watchedSettings
type
type
managedSettings
onDidChange update Record PolicyValue
disposeCount
watcherFactory _productName _policies callback
onDidChange callback
disposeCount
service disposables watcherFactory
service
policyName
type
managedSettings
type
onDidChange
service
assert managedSettings service managedSettings disposeCount managedSettings disposeCount
onDidChange update Record PolicyValue
watcherCreateCount
watcherFactory _productName _policies callback
watcherCreateCount
onDidChange callback
Disposable None
service disposables watcherFactory
service
policyName
type
managedSettings
type
OtherPolicy
type
managedSettings
type
onDidChange
service
policyName
type
managedSettings
type
assert managedSettings service managedSettings watcherCreateCount managedSettings watcherCreateCount
watcherCreateCount
watcherFactory _productName _policies callback
watcherCreateCount
watcherCreateCount
Disposable None
service disposables watcherFactory
assert service
assert
managedSettings service
watcherCreateCount
managedSettings
watcherCreateCount
onDidChange update Record PolicyValue
otherManagedSettingKey
watcherFactory _productName _policies callback
onDidChange callback
Disposable None
service disposables watcherFactory
service
policyName
type
managedSettings
type
otherManagedSettingKey type
onDidChange otherManagedSettingKey
service
policyName
type
managedSettings
type
assert service managedSettings
channel disposables
client disposables channel
channel
channel
client
assert client managedSettings
channel disposables
client disposables channel
channel
channel initialSnapshot
eventCount
disposables client eventCount
channel updatePolicyDefinitionsResult
result client
assert result managedSettings client managedSettings eventCount
result
managedSettings
eventCount
channel
client disposables channel
initial client
channel
assert initial
assert client
assert channel getManagedSettingsCallCount
_onDidChangeManagedSettings
resolveInitialSnapshotPromise managedSettings ManagedSettingsData
initialSnapshot resolve resolveInitialSnapshotPromise resolve
updatePolicyDefinitionsResult ManagedSettingsData
command
command
initialSnapshot
updatePolicyDefinitionsResult
event Event
assert event
_onDidChangeManagedSettings event Event
managedSettings ManagedSettingsData
_onDidChangeManagedSettings managedSettings
managedSettings ManagedSettingsData
managedSettings
rejectInitialSnapshotPromise error Error
initialSnapshot _resolve reject rejectInitialSnapshotPromise reject
getManagedSettingsCallCount
command
assert command
getManagedSettingsCallCount
getManagedSettingsCallCount
initialSnapshot
Event
Event None
COPILOT_FORCE_REMOTE_SETTINGS_REFRESH_KEY
,
COPILOT_SANDBOX_ENABLED_KEY
}
from
'../../common/copilotManagedSettings.js'
;
import
{
}
from
'../../common/nativeManagedSettingsIpc.js'
;
import
{
}
from
'../../common/policy.js'
;
import
{
,
}
from
'../../node/nativeManagedSettingsService.js'
;
suite
(
'NativeManagedSettingsService'
,
(
)
=>
{
const
=
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
const
=
'ChatToolsAutoApprove'
;
test
(
'watches managed-settings keys from policy definitions and exposes raw managed settings'
,
async
(
)
=>
{
let
:
(
(
:
<
string
,
|
undefined
>
)
=>
void
)
|
undefined
;
const
:
NativePolicyWatcherFactory
=
(
,
,
)
=>
{
.
deepStrictEqual
(
,
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
{
:
'string'
}
,
[
COPILOT_FORCE_REMOTE_SETTINGS_REFRESH_KEY
]
:
{
:
'boolean'
}
,
[
COPILOT_SANDBOX_ENABLED_KEY
]
:
{
:
'boolean'
}
,
}
)
;
=
;
callback
(
{
}
)
;
return
.
;
}
;
const
=
.
add
(
new
NativeManagedSettingsService
(
new
NullLogService
(
)
,
'com.github.copilot'
,
undefined
,
)
)
;
await
.
updatePolicyDefinitions
(
{
[
]
:
{
:
'boolean'
,
:
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
{
:
'string'
}
,
}
}
}
)
;
?.
(
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'disable'
}
)
;
.
deepStrictEqual
(
.
,
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'disable'
}
)
;
?.
(
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'enable'
}
)
;
.
deepStrictEqual
(
.
,
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'enable'
}
)
;
}
)
;
test
(
'watches transport controls without a managed-settings policy definition'
,
async
(
)
=>
{
let
:
<
string
,
{
:
'string'
|
'number'
|
'boolean'
}
>
=
{
}
;
const
:
NativePolicyWatcherFactory
=
(
,
,
)
=>
{
=
;
callback
(
{
[
COPILOT_FORCE_REMOTE_SETTINGS_REFRESH_KEY
]
:
true
}
)
;
return
.
;
}
;
const
=
.
add
(
new
NativeManagedSettingsService
(
new
NullLogService
(
)
,
'com.github.copilot'
,
undefined
,
)
)
;
await
.
updatePolicyDefinitions
(
{
:
{
:
'boolean'
}
}
)
;
.
deepStrictEqual
(
{
,
:
.
,
}
,
{
:
{
[
COPILOT_FORCE_REMOTE_SETTINGS_REFRESH_KEY
]
:
{
:
'boolean'
}
,
[
COPILOT_SANDBOX_ENABLED_KEY
]
:
{
:
'boolean'
}
,
}
,
:
{
[
COPILOT_FORCE_REMOTE_SETTINGS_REFRESH_KEY
]
:
true
}
,
}
)
;
}
)
;
test
(
'clears stale watcher values when managed-settings definitions are removed'
,
async
(
)
=>
{
let
:
(
(
:
<
string
,
|
undefined
>
)
=>
void
)
|
undefined
;
let
=
0
;
const
:
NativePolicyWatcherFactory
=
(
,
,
)
=>
{
=
;
callback
(
{
}
)
;
return
{
dispose
:
(
)
=>
++
}
;
}
;
const
=
.
add
(
new
NativeManagedSettingsService
(
new
NullLogService
(
)
,
'com.github.copilot'
,
undefined
,
)
)
;
await
.
updatePolicyDefinitions
(
{
[
]
:
{
:
'boolean'
,
:
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
{
:
'string'
}
,
}
}
}
)
;
?.
(
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'disable'
}
)
;
await
.
updatePolicyDefinitions
(
{
}
)
;
.
deepStrictEqual
(
{
:
.
,
}
,
{
:
{
}
,
:
1
}
)
;
}
)
;
test
(
'keeps raw managed settings while definitions are unchanged'
,
async
(
)
=>
{
let
:
(
(
:
<
string
,
|
undefined
>
)
=>
void
)
|
undefined
;
let
=
0
;
const
:
NativePolicyWatcherFactory
=
(
,
,
)
=>
{
++
;
=
;
callback
(
{
}
)
;
return
.
;
}
;
const
=
.
add
(
new
NativeManagedSettingsService
(
new
NullLogService
(
)
,
'com.github.copilot'
,
undefined
,
)
)
;
await
.
updatePolicyDefinitions
(
{
[
]
:
{
:
'boolean'
,
:
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
{
:
'string'
}
,
}
}
,
:
{
:
'boolean'
,
:
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
{
:
'string'
}
,
}
}
}
)
;
?.
(
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'disable'
}
)
;
await
.
updatePolicyDefinitions
(
{
[
]
:
{
:
'boolean'
,
:
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
{
:
'string'
}
,
}
}
}
)
;
.
deepStrictEqual
(
{
:
.
,
}
,
{
:
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'disable'
}
,
:
1
}
)
;
}
)
;
test
(
'retries watcher creation after initialization fails'
,
async
(
)
=>
{
let
=
0
;
const
:
NativePolicyWatcherFactory
=
(
,
,
)
=>
{
++
;
if
(
===
1
)
{
throw
new
Error
(
'initial watcher creation failed'
)
;
}
callback
(
{
[
COPILOT_FORCE_REMOTE_SETTINGS_REFRESH_KEY
]
:
true
}
)
;
return
.
;
}
;
const
=
.
add
(
new
NativeManagedSettingsService
(
new
NullLogService
(
)
,
'com.github.copilot'
,
undefined
,
)
)
;
await
.
rejects
(
.
initialize
(
)
)
;
.
deepStrictEqual
(
{
:
await
.
initialize
(
)
,
,
}
,
{
:
{
[
COPILOT_FORCE_REMOTE_SETTINGS_REFRESH_KEY
]
:
true
}
,
:
2
,
}
)
;
}
)
;
test
(
'removes raw managed settings whose definitions are no longer watched'
,
async
(
)
=>
{
let
:
(
(
:
<
string
,
|
undefined
>
)
=>
void
)
|
undefined
;
const
=
'permissions.otherManagedSetting'
;
const
:
NativePolicyWatcherFactory
=
(
,
,
)
=>
{
=
;
callback
(
{
}
)
;
return
.
;
}
;
const
=
.
add
(
new
NativeManagedSettingsService
(
new
NullLogService
(
)
,
'com.github.copilot'
,
undefined
,
)
)
;
await
.
updatePolicyDefinitions
(
{
[
]
:
{
:
'boolean'
,
:
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
{
:
'string'
}
,
[
]
:
{
:
'boolean'
}
,
}
}
}
)
;
?.
(
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'disable'
,
[
]
:
true
}
)
;
await
.
updatePolicyDefinitions
(
{
[
]
:
{
:
'boolean'
,
:
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
{
:
'string'
}
,
}
}
}
)
;
.
deepStrictEqual
(
.
,
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'disable'
}
)
;
}
)
;
test
(
'channel client keeps newer event state when initial snapshot resolves later'
,
async
(
)
=>
{
const
=
.
add
(
new
DeferredManagedSettingsChannel
(
)
)
;
const
=
.
add
(
new
NativeManagedSettingsChannelClient
(
,
new
NullLogService
(
)
)
)
;
.
fire
(
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'disable'
}
)
;
.
resolveInitialSnapshot
(
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'enable'
}
)
;
await
.
initialize
(
)
;
.
deepStrictEqual
(
.
,
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'disable'
}
)
;
}
)
;
test
(
'channel client updatePolicyDefinitions updates cache without firing change event'
,
async
(
)
=>
{
const
=
.
add
(
new
DeferredManagedSettingsChannel
(
)
)
;
const
=
.
add
(
new
NativeManagedSettingsChannelClient
(
,
new
NullLogService
(
)
)
)
;
.
resolveInitialSnapshot
(
{
}
)
;
await
.
;
let
=
0
;
.
add
(
.
onDidChangeManagedSettings
(
(
)
=>
++
)
)
;
.
=
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'disable'
}
;
const
=
await
.
updatePolicyDefinitions
(
{
}
)
;
.
deepStrictEqual
(
{
,
:
.
,
}
,
{
:
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'disable'
}
,
:
{
[
COPILOT_DISABLE_BYPASS_PERMISSIONS_MODE_KEY
]
:
'disable'
}
,
:
0
,
}
)
;
}
)
;
test
(
'channel client retries a failed initial snapshot'
,
async
(
)
=>
{
const
=
new
RetryManagedSettingsChannel
(
)
;
const
=
.
add
(
new
NativeManagedSettingsChannelClient
(
,
new
NullLogService
(
)
)
)
;
const
=
.
initialize
(
)
;
.
rejectInitialSnapshot
(
)
;
await
.
rejects
(
)
;
.
deepStrictEqual
(
await
.
initialize
(
)
,
{
[
COPILOT_FORCE_REMOTE_SETTINGS_REFRESH_KEY
]
:
true
}
)
;
.
strictEqual
(
.
,
2
)
;
}
)
;
}
)
;
class
DeferredManagedSettingsChannel
extends
Disposable
implements
IChannel
{
private
readonly
=
this
.
_register
(
new
Emitter< ManagedSettingsData>
(
)
)
;
private
!
:
(
:
)
=>
void
;
readonly
=
new
Promise < ManagedSettingsData>
(
=>
this
.
=
)
;
:
=
{
}
;
call < T >
(
:
string
)
:
Promise
<
T
>
{
switch
(
)
{
case
'getManagedSettings'
:
return
this
.
as
Promise
<
T
>
;
case
'updatePolicyDefinitions'
:
return
Promise
.
resolve
(
this
.
as
T
)
;
}
throw
new
Error
(
` Call not found: ${ command} `
)
;
}
listen < T >
(
:
string
)
:
<
T
>
{
.
strictEqual
(
,
'onDidChangeManagedSettings'
)
;
return
this
.
.
as
<
T
>
;
}
fire
(
:
)
:
void
{
this
.
.
fire
(
)
;
}
resolveInitialSnapshot
(
:
)
:
void
{
this
.
resolveInitialSnapshotPromise
(
)
;
}
}
class
RetryManagedSettingsChannel
implements
IChannel
{
private
!
:
(
:
)
=>
void
;
private
readonly
=
new
Promise < ManagedSettingsData>
(
(
,
)
=>
this
.
=
)
;
=
0
;
call < T >
(
:
string
)
:
Promise
<
T
>
{
.
strictEqual
(
,
'getManagedSettings'
)
;
this
.
++
;
if
(
this
.
===
1
)
{
return
this
.
as
Promise
<
T
>
;
}
return
Promise
.
resolve
(
{
[
COPILOT_FORCE_REMOTE_SETTINGS_REFRESH_KEY
]
:
true
}
as
T
)
;
}
listen < T >
(
)
:
<
T
>
{
return
.
;
}
rejectInitialSnapshot
(
)
:
void
{
this
.
rejectInitialSnapshotPromise
(
new
Error
(
'initial native managed-settings read failed'
)
)
;
}
}