MCPcopy Create free account
hub / github.com/coder/coder / Test_addXauthEntry

Function Test_addXauthEntry

agent/agentssh/x11_internal_test.go:15–253  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func Test_addXauthEntry(t *testing.T) {
16 t.Parallel()
17
18 type testEntry struct {
19 address string
20 display string
21 authProtocol string
22 authCookie string
23 }
24 tests := []struct {
25 name string
26 authFile []byte
27 wantAuthFile []byte
28 entries []testEntry
29 }{
30 {
31 name: "add entry",
32 authFile: nil,
33 wantAuthFile: []byte{
34 // w/unix:0 MIT-MAGIC-COOKIE-1 00
35 //
36 // 00000000: 0100 0001 7700 0130 0012 4d49 542d 4d41 ....w..0..MIT-MA
37 // 00000010: 4749 432d 434f 4f4b 4945 2d31 0001 00 GIC-COOKIE-1...
38 0x01, 0x00, 0x00, 0x01, 0x77, 0x00, 0x01, 0x30,
39 0x00, 0x12, 0x4d, 0x49, 0x54, 0x2d, 0x4d, 0x41,
40 0x47, 0x49, 0x43, 0x2d, 0x43, 0x4f, 0x4f, 0x4b,
41 0x49, 0x45, 0x2d, 0x31, 0x00, 0x01, 0x00,
42 },
43 entries: []testEntry{
44 {
45 address: "w",
46 display: "0",
47 authProtocol: "MIT-MAGIC-COOKIE-1",
48 authCookie: "00",
49 },
50 },
51 },
52 {
53 name: "add two entries",
54 authFile: []byte{},
55 wantAuthFile: []byte{
56 // w/unix:0 MIT-MAGIC-COOKIE-1 00
57 // w/unix:1 MIT-MAGIC-COOKIE-1 11
58 //
59 // 00000000: 0100 0001 7700 0130 0012 4d49 542d 4d41 ....w..0..MIT-MA
60 // 00000010: 4749 432d 434f 4f4b 4945 2d31 0001 0001 GIC-COOKIE-1....
61 // 00000020: 0000 0177 0001 3100 124d 4954 2d4d 4147 ...w..1..MIT-MAG
62 // 00000030: 4943 2d43 4f4f 4b49 452d 3100 0111 IC-COOKIE-1...
63 0x01, 0x00, 0x00, 0x01, 0x77, 0x00, 0x01, 0x30,
64 0x00, 0x12, 0x4d, 0x49, 0x54, 0x2d, 0x4d, 0x41,
65 0x47, 0x49, 0x43, 0x2d, 0x43, 0x4f, 0x4f, 0x4b,
66 0x49, 0x45, 0x2d, 0x31, 0x00, 0x01, 0x00,
67 0x01, 0x00, 0x00, 0x01, 0x77, 0x00, 0x01, 0x31,
68 0x00, 0x12, 0x4d, 0x49, 0x54, 0x2d, 0x4d, 0x41,
69 0x47, 0x49, 0x43, 0x2d, 0x43, 0x4f, 0x4f, 0x4b,
70 0x49, 0x45, 0x2d, 0x31, 0x00, 0x01, 0x11,
71 },
72 entries: []testEntry{

Callers

nothing calls this directly

Calls 4

addXauthEntryFunction · 0.85
RunMethod · 0.65
WriteFileMethod · 0.65
ReadFileMethod · 0.65

Tested by

no test coverage detected