Bug fixes and package updates.
This commit is contained in:
1 parent
19b789ef5c
commit
d0c977281d
11 files changed
+176
-27
No files matched your search
@@ -34,13 +34,18 @@ import (
|
||||
// This uses the source-built external executable and real host/SDK IPC. Only
|
||||
// OpenLocal submissions are synthetic; it cannot prove physical-source input.
|
||||
func remote_command_fixture(t *testing.T, setup ...func(*tentacleRuntime)) (*tentacleRuntime, *consentTestForms, input.Command) {
|
||||
t.Helper()
|
||||
return remote_command_fixture_grants(t, []string{"output-observe", "remote-present"}, setup...)
|
||||
}
|
||||
|
||||
func remote_command_fixture_grants(t *testing.T, grants []string, setup ...func(*tentacleRuntime)) (*tentacleRuntime, *consentTestForms, input.Command) {
|
||||
t.Helper()
|
||||
program := os.Getenv("CTHULHU_REMOTE_BINARY")
|
||||
if program == "" {
|
||||
t.Skip("requires the separately built Remote executable")
|
||||
}
|
||||
directory := t.TempDir()
|
||||
spec := tentacle.Spec{ID: "remote", Program: []string{program, "--data-dir", filepath.Join(directory, "state")}, Presentation: true, Interaction: true, SessionEvents: true, RemoteGrants: []string{"output-observe", "remote-present"}}
|
||||
spec := tentacle.Spec{ID: "remote", Program: []string{program, "--data-dir", filepath.Join(directory, "state")}, Presentation: true, Interaction: true, SessionEvents: true, RemoteGrants: grants}
|
||||
data, _ := json.Marshal([]tentacle.Spec{spec})
|
||||
launchPath := filepath.Join(directory, "launch.json")
|
||||
if err := os.WriteFile(launchPath, data, 0600); err != nil {
|
||||
@@ -130,7 +135,7 @@ func select_remote_relay(t *testing.T, forms *consentTestForms, address, role st
|
||||
return options
|
||||
}
|
||||
|
||||
func approve_remote_form(t *testing.T, forms *consentTestForms, consent consentFormRequest, role string) consentFormRequest {
|
||||
func approve_remote_form(t *testing.T, forms *consentTestForms, consent consentFormRequest, role string, extra ...string) consentFormRequest {
|
||||
t.Helper()
|
||||
if !strings.Contains(consent.form.Title, "Remote access for remote") {
|
||||
t.Fatal("missing reader approval")
|
||||
@@ -144,7 +149,11 @@ func approve_remote_form(t *testing.T, forms *consentTestForms, consent consentF
|
||||
if role == "controlled" {
|
||||
grant = "output-observe"
|
||||
}
|
||||
consent.reply <- internalUIResult{Activated: "approve", Values: map[string]interaction.Value{grant: {Checked: true}}}
|
||||
values := map[string]interaction.Value{grant: {Checked: true}}
|
||||
for _, name := range extra {
|
||||
values[name] = interaction.Value{Checked: true}
|
||||
}
|
||||
consent.reply <- internalUIResult{Activated: "approve", Values: values}
|
||||
progress := next_remote_form(t, forms)
|
||||
if progress.form.Title != "Connecting Remote" {
|
||||
t.Fatal("approval did not start connection", progress.form.Title)
|
||||
@@ -289,8 +298,10 @@ func TestRemoteConnectionCommandPrivateRelay(t *testing.T) {
|
||||
{"controller", "disconnect", true}, {"controller", "lock", true},
|
||||
{"controller", "handoff", true}, {"controller", "disable", true},
|
||||
{"controller", "backend-failure", true},
|
||||
{"controlled", "missing-helper", false},
|
||||
} {
|
||||
role, ending := test.role, test.ending
|
||||
keyboard := role == "controlled" && (ending == "disconnect" || ending == "missing-helper")
|
||||
name := role + "/" + ending
|
||||
if test.playback {
|
||||
name += "/production-speech"
|
||||
@@ -366,6 +377,18 @@ func TestRemoteConnectionCommandPrivateRelay(t *testing.T) {
|
||||
}
|
||||
io.WriteString(connection, `{"type":"channel_joined","channel":"synthetic-fixture","clients":[{"id":7,"connection_type":"`+peerRole+`"}]}`+"\n")
|
||||
close(joined)
|
||||
if keyboard {
|
||||
select {
|
||||
case <-speechReady:
|
||||
case <-t.Context().Done():
|
||||
return
|
||||
}
|
||||
// NVDA and Cthulhu controllers use these same key frames.
|
||||
for _, pressed := range []bool{true, false} {
|
||||
json.NewEncoder(connection).Encode(map[string]any{"type": "key", "origin": 7,
|
||||
"vk_code": 65, "extended": false, "pressed": pressed})
|
||||
}
|
||||
}
|
||||
if role == "controller" {
|
||||
select {
|
||||
case <-speechReady:
|
||||
@@ -409,7 +432,18 @@ func TestRemoteConnectionCommandPrivateRelay(t *testing.T) {
|
||||
})
|
||||
})
|
||||
}
|
||||
runtime, forms, shortcut := remote_command_fixture(t, configure...)
|
||||
grants := []string{"output-observe", "remote-present"}
|
||||
var keyLog string
|
||||
if keyboard {
|
||||
grants = append(grants, "keyboard-inject")
|
||||
helper, log := keyboard_owner_helper(t)
|
||||
keyLog = log
|
||||
if ending == "missing-helper" {
|
||||
helper = filepath.Join(t.TempDir(), "absent")
|
||||
}
|
||||
configure = append(configure, func(runtime *tentacleRuntime) { runtime.remoteInputHelper = helper })
|
||||
}
|
||||
runtime, forms, shortcut := remote_command_fixture_grants(t, grants, configure...)
|
||||
if role == "controlled" {
|
||||
worker := runtime.output.speech
|
||||
worker.speaker = &observationSpeaker{fakeSpeaker{spoken: make(chan string, 64)}}
|
||||
@@ -459,7 +493,11 @@ func TestRemoteConnectionCommandPrivateRelay(t *testing.T) {
|
||||
credentials.reply <- internalUIResult{Activated: "connect", Values: map[string]interaction.Value{"channel-key": {Text: "synthetic-fixture"}}}
|
||||
next_remote_form(t, forms) // Verified certificate progress.
|
||||
consent := next_remote_form(t, forms)
|
||||
status := approve_remote_form(t, forms, consent, role)
|
||||
var extra []string
|
||||
if keyboard {
|
||||
extra = append(extra, "keyboard-inject")
|
||||
}
|
||||
status := approve_remote_form(t, forms, consent, role, extra...)
|
||||
select {
|
||||
case <-joined:
|
||||
case <-time.After(5 * time.Second):
|
||||
@@ -507,6 +545,20 @@ func TestRemoteConnectionCommandPrivateRelay(t *testing.T) {
|
||||
}
|
||||
}
|
||||
close(speechReady)
|
||||
if ending == "missing-helper" {
|
||||
remote_stream_wait(t, closed)
|
||||
if _, err := os.Stat(keyLog); !os.IsNotExist(err) {
|
||||
t.Fatal("missing helper unexpectedly delivered input", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if keyboard {
|
||||
fixture := &keyboardOwnerFixture{log: keyLog}
|
||||
fixture.wait(t, func() bool {
|
||||
effects := fixture.effects()
|
||||
return strings.Contains(effects, " a true\n") && strings.Contains(effects, " a false\n")
|
||||
})
|
||||
}
|
||||
if ending == "backend-failure" {
|
||||
remote_stream_wait(t, closed)
|
||||
// Backend failure retires the lease, while the process and
|
||||
|
||||
Reference in new issue
Block a user