mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
#18925 (Should also fix #17660.) Tests: - Ubuntu 22.04.2 - Wayland - Works with chrome ✅ - Doesn't work with Firefox. ❌ - Xorg - Works with Chrome. ✅ - Works with Firefox. ✅ - Ubuntu 24.04 - Wayland - Doesn't work with Chrome. ❌ - Doesn't work with Firefox. ❌ - Xorg (when using Xorg it defaults to `DISPLAY=:1`, and with the changes in this PR it works): - Works with Chrome. ✅ - Works with Firefox. ✅ --- How to change between Wayland and Xorg: - Set `WaylandEnable=false` in `/etc/gdm3/custom.conf` and reboot. --- How to determine what's running: ```sh $ loginctl SESSION UID USER SEAT TTY 2 1000 luk seat0 tty2 c2 1000 luk $ loginctl show-session 2 -p Type # will output Type=wayland or Type=x11 ``` --- - [X] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://fleetdm.com/docs/contributing/committing-changes#changes-files) for more information. - [X] Added/updated tests - [X] Manual QA for all new/changed functionality - For Orbit and Fleet Desktop changes: - [X] Manual QA must be performed in the three main OSs, macOS, Windows and Linux. - [x] Auto-update manual QA, from released version of component to new version (see [tools/tuf/test](../tools/tuf/test/README.md)).
57 lines
1.1 KiB
Go
57 lines
1.1 KiB
Go
package execuser
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestParseWhoOutputForDisplay(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
output string
|
|
user string
|
|
expectedDisplay string
|
|
}{
|
|
{
|
|
"Ubuntu 22.04.2 (X11)",
|
|
`foo :0 2024-05-14 17:34 (:0)`,
|
|
"foo",
|
|
":0",
|
|
},
|
|
{
|
|
"Ubuntu 22.04.2 (X11) - user not listed",
|
|
`foo :0 2024-05-14 17:34 (:0)`,
|
|
"bar",
|
|
"",
|
|
},
|
|
{
|
|
"Ubuntu 24.04 (X11)",
|
|
`foo seat0 2024-05-14 17:42 (login screen)
|
|
foo :1 2024-05-14 17:42 (:1)`,
|
|
"foo",
|
|
":1",
|
|
},
|
|
{
|
|
"Ubuntu 24.04 (Wayland) - DISPLAY not found",
|
|
`foo seat0 2024-05-14 18:11 (login screen)
|
|
foo tty2 2024-05-14 18:11 (tty2)`,
|
|
"foo",
|
|
"",
|
|
},
|
|
{
|
|
"Empty",
|
|
``,
|
|
"foo",
|
|
"",
|
|
},
|
|
}
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
display, err := parseWhoOutputForDisplay(bytes.NewReader([]byte(tc.output)), tc.user)
|
|
require.NoError(t, err)
|
|
require.Equal(t, tc.expectedDisplay, display)
|
|
})
|
|
}
|
|
}
|