ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / platform / agentHost / test / common / sshConfigParsing.test.ts 308 строк · изменён 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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
import assert from 'assert' ;
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js' ;
import { parseSSHConfigHostEntries, parseSSHGOutput } from '../../common/sshConfigParsing.js' ;
suite ( 'SSH Config Parsing' , ( ) => {
ensureNoDisposablesAreLeakedInTestSuite ( ) ;
suite ( 'parseSSHConfigHostEntries' , ( ) => {
test ( 'extracts simple host entries' , ( ) => {
const config =
assert config
config
assert config
config
assert config
config
assert config
config
assert config
config
assert config
config
assert config
config
assert config
assert
config
assert config
config
assert config
config
assert config
output
assert output
hostname
user
port
identityFile
identityAgent
forwardAgent
userKnownHostsFiles
globalKnownHostsFiles
strictHostKeyChecking
output
result output
assert result forwardAgent
output
assert output identityAgent
output
result output
assert result port
output
result output
assert result user
output
result output
assert result user
output
result output
assert result port
output
assert output identityFile
assert
hostname
user
port
identityFile
identityAgent
forwardAgent
userKnownHostsFiles
globalKnownHostsFiles
strictHostKeyChecking
output
result output
assert
user result userKnownHostsFiles global result globalKnownHostsFiles
user
global
output
assert
output userKnownHostsFiles
value strictHostKeyChecking
assert
effective
ask
acceptNew
yes
noOrOff
acceptedAliases
yes
no
off
uppercase
bogus
absent strictHostKeyChecking
effective
ask
acceptNew
yes
noOrOff
acceptedAliases
yes
no
off
uppercase
bogus
absent
output
result output
assert result hostname
[
'Host myserver'
,
' HostName 10.0.0.1'
,
' User admin'
,
]
.
join
(
'\n'
)
;
.
deepStrictEqual
(
parseSSHConfigHostEntries
(
)
,
[
'myserver'
]
)
;
}
)
;
test
(
'extracts multiple hosts from a single Host line'
,
(
)
=>
{
const
=
'Host server1 server2 server3'
;
.
deepStrictEqual
(
parseSSHConfigHostEntries
(
)
,
[
'server1'
,
'server2'
,
'server3'
]
)
;
}
)
;
test
(
'extracts hosts from multiple Host directives'
,
(
)
=>
{
const
=
[
'Host work'
,
' HostName work.example.com'
,
''
,
'Host personal'
,
' HostName home.example.com'
,
]
.
join
(
'\n'
)
;
.
deepStrictEqual
(
parseSSHConfigHostEntries
(
)
,
[
'work'
,
'personal'
]
)
;
}
)
;
test
(
'skips wildcard hosts'
,
(
)
=>
{
const
=
[
'Host *'
,
' ForwardAgent yes'
,
''
,
'Host myserver'
,
' HostName 10.0.0.1'
,
''
,
'Host *.example.com'
,
' User admin'
,
]
.
join
(
'\n'
)
;
.
deepStrictEqual
(
parseSSHConfigHostEntries
(
)
,
[
'myserver'
]
)
;
}
)
;
test
(
'skips negation patterns'
,
(
)
=>
{
const
=
'Host !internal myserver'
;
.
deepStrictEqual
(
parseSSHConfigHostEntries
(
)
,
[
'myserver'
]
)
;
}
)
;
test
(
'skips question mark wildcards'
,
(
)
=>
{
const
=
'Host server? myserver'
;
.
deepStrictEqual
(
parseSSHConfigHostEntries
(
)
,
[
'myserver'
]
)
;
}
)
;
test
(
'skips comment lines'
,
(
)
=>
{
const
=
[
'# This is a comment'
,
'Host myserver'
,
' # Another comment'
,
' HostName 10.0.0.1'
,
]
.
join
(
'\n'
)
;
.
deepStrictEqual
(
parseSSHConfigHostEntries
(
)
,
[
'myserver'
]
)
;
}
)
;
test
(
'strips inline comments from Host values'
,
(
)
=>
{
const
=
'Host myserver # my favorite server'
;
.
deepStrictEqual
(
parseSSHConfigHostEntries
(
)
,
[
'myserver'
]
)
;
}
)
;
test
(
'handles empty content'
,
(
)
=>
{
.
deepStrictEqual
(
parseSSHConfigHostEntries
(
''
)
,
[
]
)
;
}
)
;
test
(
'handles content with only comments and blanks'
,
(
)
=>
{
const
=
[
'# comment'
,
''
,
' # indented comment'
,
''
,
]
.
join
(
'\n'
)
;
.
deepStrictEqual
(
parseSSHConfigHostEntries
(
)
,
[
]
)
;
}
)
;
test
(
'is case-insensitive for Host keyword'
,
(
)
=>
{
const
=
[
'host lower'
,
'HOST upper'
,
'Host mixed'
,
]
.
join
(
'\n'
)
;
.
deepStrictEqual
(
parseSSHConfigHostEntries
(
)
,
[
'lower'
,
'upper'
,
'mixed'
]
)
;
}
)
;
test
(
'ignores non-Host directives'
,
(
)
=>
{
const
=
[
'Host myserver'
,
' HostName 10.0.0.1'
,
' User admin'
,
' Port 2222'
,
' IdentityFile ~/.ssh/mykey'
,
' ForwardAgent yes'
,
]
.
join
(
'\n'
)
;
.
deepStrictEqual
(
parseSSHConfigHostEntries
(
)
,
[
'myserver'
]
)
;
}
)
;
}
)
;
suite
(
'parseSSHGOutput'
,
(
)
=>
{
test
(
'parses standard ssh -G output'
,
(
)
=>
{
const
=
[
'hostname 10.0.0.1'
,
'user admin'
,
'port 22'
,
'identityfile ~/.ssh/id_rsa'
,
'identityfile ~/.ssh/id_ed25519'
,
'forwardagent no'
,
]
.
join
(
'\n'
)
;
.
deepStrictEqual
(
parseSSHGOutput
(
)
,
{
:
'10.0.0.1'
,
:
'admin'
,
:
22
,
:
[
'~/.ssh/id_rsa'
,
'~/.ssh/id_ed25519'
]
,
:
undefined
,
:
false
,
:
[
]
,
:
[
]
,
:
undefined
,
}
)
;
}
)
;
test
(
'parses forwardagent yes'
,
(
)
=>
{
const
=
[
'hostname example.com'
,
'user root'
,
'port 22'
,
'forwardagent yes'
,
]
.
join
(
'\n'
)
;
const
=
parseSSHGOutput
(
)
;
.
strictEqual
(
.
,
true
)
;
}
)
;
test
(
'parses identityagent'
,
(
)
=>
{
const
=
[
'hostname example.com'
,
'user admin'
,
'identityagent //./pipe/pageant.user.1234'
,
]
.
join
(
'\n'
)
;
.
strictEqual
(
parseSSHGOutput
(
)
.
,
'//./pipe/pageant.user.1234'
)
;
}
)
;
test
(
'parses non-standard port'
,
(
)
=>
{
const
=
[
'hostname example.com'
,
'user deploy'
,
'port 2222'
,
]
.
join
(
'\n'
)
;
const
=
parseSSHGOutput
(
)
;
.
strictEqual
(
.
,
2222
)
;
}
)
;
test
(
'handles missing user'
,
(
)
=>
{
const
=
[
'hostname example.com'
,
'port 22'
,
]
.
join
(
'\n'
)
;
const
=
parseSSHGOutput
(
)
;
.
strictEqual
(
.
,
undefined
)
;
}
)
;
test
(
'handles empty user'
,
(
)
=>
{
const
=
[
'hostname example.com'
,
'user '
,
'port 22'
,
]
.
join
(
'\n'
)
;
const
=
parseSSHGOutput
(
)
;
.
strictEqual
(
.
,
undefined
)
;
}
)
;
test
(
'defaults port to 22 when missing'
,
(
)
=>
{
const
=
'hostname example.com\nuser root'
;
const
=
parseSSHGOutput
(
)
;
.
strictEqual
(
.
,
22
)
;
}
)
;
test
(
'collects multiple identity files'
,
(
)
=>
{
const
=
[
'hostname example.com'
,
'port 22'
,
'identityfile ~/.ssh/id_rsa'
,
'identityfile ~/.ssh/work_key'
,
'identityfile ~/.ssh/id_ed25519'
,
]
.
join
(
'\n'
)
;
.
deepStrictEqual
(
parseSSHGOutput
(
)
.
,
[
'~/.ssh/id_rsa'
,
'~/.ssh/work_key'
,
'~/.ssh/id_ed25519'
,
]
)
;
}
)
;
test
(
'handles empty output'
,
(
)
=>
{
.
deepStrictEqual
(
parseSSHGOutput
(
''
)
,
{
:
''
,
:
undefined
,
:
22
,
:
[
]
,
:
undefined
,
:
false
,
:
[
]
,
:
[
]
,
:
undefined
,
}
)
;
}
)
;
test
(
'splits the known_hosts path lists'
,
(
)
=>
{
const
=
[
'userknownhostsfile /home/u/.ssh/known_hosts /home/u/.ssh/known_hosts2'
,
'globalknownhostsfile /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2'
,
]
.
join
(
'\n'
)
;
const
=
parseSSHGOutput
(
)
;
.
deepStrictEqual
(
{
:
.
,
:
.
}
,
{
:
[
'/home/u/.ssh/known_hosts'
,
'/home/u/.ssh/known_hosts2'
]
,
:
[
'/etc/ssh/ssh_known_hosts'
,
'/etc/ssh/ssh_known_hosts2'
]
,
}
)
;
}
)
;
test
(
'honors quoting in known_hosts path lists'
,
(
)
=>
{
const
=
'userknownhostsfile "/home/my user/.ssh/known_hosts" /home/u/other'
;
.
deepStrictEqual
(
parseSSHGOutput
(
)
.
,
[
'/home/my user/.ssh/known_hosts'
,
'/home/u/other'
]
)
;
}
)
;
test
(
'normalizes effective StrictHostKeyChecking values and ignores others'
,
(
)
=>
{
const
parse
=
(
:
string
)
=>
parseSSHGOutput
(
` stricthostkeychecking ${ value} `
)
.
;
.
deepStrictEqual
(
{
:
{
:
parse
(
'ask'
)
,
:
parse
(
'accept-new'
)
,
:
parse
(
'true'
)
,
:
parse
(
'false'
)
,
}
,
:
{
:
parse
(
'yes'
)
,
:
parse
(
'no'
)
,
:
parse
(
'off'
)
,
:
parse
(
'TRUE'
)
,
}
,
:
parse
(
'maybe'
)
,
:
parseSSHGOutput
(
''
)
.
,
}
,
{
:
{
:
'ask'
,
:
'accept-new'
,
:
'yes'
,
:
'no'
,
}
,
:
{
:
'yes'
,
:
'no'
,
:
'off'
,
:
'yes'
,
}
,
:
undefined
,
:
undefined
,
}
)
;
}
)
;
test
(
'handles values with spaces'
,
(
)
=>
{
const
=
'hostname my host with spaces\nport 22'
;
const
=
parseSSHGOutput
(
)
;
.
strictEqual
(
.
,
'my host with spaces'
)
;
}
)
;
}
)
;
}
)
;