addTerminalHost method
- String? id,
- required String name,
- required String noisePublicKey,
- Map<
String, String> sessionUsers = const {}, - Map<
String, List< workdirs = const {},String> > - List<
JsonMap> ? profiles, - String? assignedUserId,
- List<
String> grantees = const [], - String llmCredentials = 'organization',
- String fingerprint = '7KQ2-9XTA-M4PB-1C8D-0000-0000-0000-0000-0000-0000-0000-0000-0000',
Adds an active, connected host named name with the static key noisePublicKey, the
session users sessionUsers (person to name; every name is reported), the working
directories workdirs of the profile claude per name, profiles (default shell and,
with any working directory, claude), the assignee assignedUserId, and a valid grant
terminal for each of grantees; returns the host. id is the host ID (a new one when
null), so a test can give the in-process host the same ID for the Noise prologue.
Implementation
FakeHost addTerminalHost({
String? id,
required String name,
required String noisePublicKey,
Map<String, String> sessionUsers = const {},
Map<String, List<String>> workdirs = const {},
List<HostJson>? profiles,
String? assignedUserId,
List<String> grantees = const [],
String llmCredentials = 'organization',
String fingerprint =
'7KQ2-9XTA-M4PB-1C8D-0000-0000-0000-0000-0000-0000-0000-0000-0000',
}) {
final h = FakeHost(
id: id ?? nextId(),
name: name,
createdAt: stamp(),
assignedUserId: assignedUserId,
);
hosts[h.id] = h;
pairHost(
h.id,
{...sessionUsers.values, ...workdirs.keys}.toList(),
fingerprint: fingerprint,
);
h
..state = 'active'
..llmCredentials = llmCredentials
..noisePublicKey = noisePublicKey
..profiles =
profiles ??
[
{'name': 'shell', 'display_name': 'Shell', 'kind': 'shell'},
if (workdirs.isNotEmpty)
{
'name': 'claude',
'display_name': 'Claude Code',
'kind': 'claude',
},
];
h.workdirs.addAll(workdirs);
for (final MapEntry(key: user, value: os) in sessionUsers.entries) {
h.sessionUsers[user] = (os, stamp());
h.taken[os] = user;
}
for (final user in grantees) {
final id = nextId();
grants[id] = {
'id': id,
'subject_kind': 'user',
'subject_id': user,
'target_kind': 'host',
'target_id': h.id,
'capabilities': ['terminal'],
'reason': 'Terminal for the tests',
'granted_by': user,
'granted_at': stamp(),
};
}
return h;
}