pinokiod 8.3.1 → 8.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/kernel/bin/cuda.js +34 -16
- package/kernel/bin/git.js +17 -6
- package/kernel/bin/tailscaled.js +1 -1
- package/kernel/connect/providers/github/README.md +1 -1
- package/kernel/git.js +4 -20
- package/kernel/gitconfig_template +1 -6
- package/kernel/github_auth.js +277 -0
- package/kernel/index.js +3 -0
- package/package.json +1 -1
- package/server/index.js +18 -190
- package/server/routes/github_auth.js +43 -0
- package/server/views/anywhere.ejs +1 -0
- package/server/views/github.ejs +2 -2
- package/server/views/github_login.ejs +390 -0
- package/test/anywhere-onboarding.test.js +9 -0
- package/test/anywhere.test.js +5 -5
- package/test/cuda-bin.test.js +239 -0
- package/test/git-bin.test.js +28 -13
- package/test/git-defaults.test.js +44 -25
- package/test/github-auth.test.js +431 -0
- package/test/github-connection.test.js +6 -129
- package/test/tailscale-cli.test.js +1 -1
|
@@ -1,137 +1,14 @@
|
|
|
1
1
|
const assert = require('node:assert/strict')
|
|
2
|
-
const fs = require('node:fs/promises')
|
|
3
|
-
const os = require('node:os')
|
|
4
|
-
const path = require('node:path')
|
|
5
2
|
const test = require('node:test')
|
|
6
3
|
|
|
7
4
|
const Server = require('../server')
|
|
8
5
|
|
|
9
|
-
test('GitHub connection
|
|
6
|
+
test('GitHub connection comes from the Pinokio GitHub login, with the caller options passed through', async () => {
|
|
7
|
+
const stored = { connected: true, saved: true, login: 'octocat', display: 'github.com: octocat', source: 'pinokio' }
|
|
8
|
+
let received
|
|
10
9
|
const connection = await Server.prototype.get_github_connection.call({
|
|
11
|
-
|
|
12
|
-
'github.com:',
|
|
13
|
-
' git_protocol: https',
|
|
14
|
-
' users:',
|
|
15
|
-
' cocktailpeanut:',
|
|
16
|
-
' user: cocktailpeanut',
|
|
17
|
-
'',
|
|
18
|
-
].join('\n'),
|
|
19
|
-
github_gcm: async () => '',
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
assert.equal(connection.connected, false)
|
|
23
|
-
assert.equal(connection.provider, null)
|
|
24
|
-
assert.equal(connection.display, '')
|
|
25
|
-
assert.match(connection.legacyHosts, /cocktailpeanut/)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
test('GitHub connection reports GCM accounts as connected', async () => {
|
|
29
|
-
const connection = await Server.prototype.get_github_connection.call({
|
|
30
|
-
get_legacy_github_hosts: async () => '',
|
|
31
|
-
github_gcm: async () => 'octocat\n',
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
assert.equal(connection.connected, true)
|
|
35
|
-
assert.equal(connection.provider, 'gcm')
|
|
36
|
-
assert.equal(connection.display, 'github.com: octocat')
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
test('GitHub connection forwards a bounded timeout to GCM status checks', async () => {
|
|
40
|
-
let receivedOptions
|
|
41
|
-
await Server.prototype.get_github_connection.call({
|
|
42
|
-
get_legacy_github_hosts: async () => '',
|
|
43
|
-
github_gcm: async (args, options) => {
|
|
44
|
-
receivedOptions = options
|
|
45
|
-
return ''
|
|
46
|
-
},
|
|
10
|
+
kernel: { githubAuth: { connection: async (options) => { received = options; return stored } } }
|
|
47
11
|
}, { timeout: 2500 })
|
|
48
|
-
|
|
49
|
-
assert.
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
test('GitHub connection coalesces only concurrent GCM checks', async () => {
|
|
53
|
-
let calls = 0
|
|
54
|
-
const context = {
|
|
55
|
-
get_legacy_github_hosts: async () => '',
|
|
56
|
-
github_gcm: async () => {
|
|
57
|
-
calls += 1
|
|
58
|
-
await new Promise((resolve) => setTimeout(resolve, 10))
|
|
59
|
-
return 'octocat\n'
|
|
60
|
-
},
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const [first, second] = await Promise.all([
|
|
64
|
-
Server.prototype.get_github_connection.call(context),
|
|
65
|
-
Server.prototype.get_github_connection.call(context),
|
|
66
|
-
])
|
|
67
|
-
|
|
68
|
-
assert.equal(calls, 1)
|
|
69
|
-
assert.equal(first.connected, true)
|
|
70
|
-
assert.deepEqual(second, first)
|
|
71
|
-
|
|
72
|
-
await Server.prototype.get_github_connection.call(context)
|
|
73
|
-
assert.equal(calls, 2)
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
test('GitHub login completes directly from GCM success on macOS and Linux', () => {
|
|
77
|
-
for (const platform of ['darwin', 'linux']) {
|
|
78
|
-
const { doneMarker, message } = Server.prototype.github_login_params.call({
|
|
79
|
-
kernel: { platform }
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
assert.equal(doneMarker, 'PINOKIO_GITHUB_LOGIN_DONE')
|
|
83
|
-
assert.match(message, /git credential-manager github login --device --force && \(GCM_DONE=INOKIO_GITHUB_LOGIN_DONE; printf 'P%s\\n' "\$GCM_DONE"\)/)
|
|
84
|
-
assert.doesNotMatch(message, /credential fill/)
|
|
85
|
-
assert.doesNotMatch(message, /git credential-manager github login --device --force\s*;/)
|
|
86
|
-
assert.doesNotMatch(message, /--web/)
|
|
87
|
-
assert.doesNotMatch(message, /PINOKIO_GITHUB_LOGIN_DONE/)
|
|
88
|
-
}
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
test('GitHub login completes directly from GCM success on Windows', () => {
|
|
92
|
-
const { message } = Server.prototype.github_login_params.call({
|
|
93
|
-
kernel: { platform: 'win32' }
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
assert.match(message, /git credential-manager github login --device --force && echo P\^INOKIO_GITHUB_LOGIN_DONE/)
|
|
97
|
-
assert.doesNotMatch(message, /credential fill/)
|
|
98
|
-
assert.doesNotMatch(message, /powershell\.exe/)
|
|
99
|
-
assert.doesNotMatch(message, /--web/)
|
|
100
|
-
assert.doesNotMatch(message, /PINOKIO_GITHUB_LOGIN_DONE/)
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
test('GitHub logout clears legacy gh auth even when GCM accounts exist', async () => {
|
|
104
|
-
let clearedLegacyAuth = false
|
|
105
|
-
const context = {
|
|
106
|
-
kernel: { platform: 'darwin' },
|
|
107
|
-
github_logout_command: Server.prototype.github_logout_command,
|
|
108
|
-
clear_legacy_github_auth: async () => {
|
|
109
|
-
clearedLegacyAuth = true
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const result = await Server.prototype.github_logout_params.call(context, {
|
|
114
|
-
accounts: ['octocat'],
|
|
115
|
-
legacyHosts: 'github.com:\n user: octocat\n'
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
assert.equal(clearedLegacyAuth, true)
|
|
119
|
-
assert.equal(result.hadLegacyAuth, true)
|
|
120
|
-
assert.equal(result.message, 'git credential-manager github logout octocat')
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
test('GitHub legacy auth cleanup removes old gh hosts file', async () => {
|
|
124
|
-
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'pinokio-gh-auth-'))
|
|
125
|
-
const hostsFile = path.join(dir, 'config/gh/hosts.yml')
|
|
126
|
-
await fs.mkdir(path.dirname(hostsFile), { recursive: true })
|
|
127
|
-
await fs.writeFile(hostsFile, 'github.com:\n user: octocat\n')
|
|
128
|
-
|
|
129
|
-
await Server.prototype.clear_legacy_github_auth.call({
|
|
130
|
-
kernel: {
|
|
131
|
-
path: (relativePath) => path.join(dir, relativePath)
|
|
132
|
-
}
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
await assert.rejects(() => fs.stat(hostsFile), { code: 'ENOENT' })
|
|
136
|
-
await fs.rm(dir, { recursive: true, force: true })
|
|
12
|
+
assert.deepEqual(connection, stored)
|
|
13
|
+
assert.equal(received.timeout, 2500)
|
|
137
14
|
})
|
|
@@ -219,7 +219,7 @@ test('native daemon: setup, simultaneous start, adoption, stop and saved Off', {
|
|
|
219
219
|
const kernel = {
|
|
220
220
|
platform: process.platform, homedir: tmp, path: (...parts) => path.join(tmp, ...parts),
|
|
221
221
|
bin: { mod: { tailscaled: mod }, installed: { conda: new Set(['tailscaled', 'tailscale']),
|
|
222
|
-
conda_versions: { tailscaled: '1.104.
|
|
222
|
+
conda_versions: { tailscaled: '1.104.5', tailscale: '1.104.5' } } },
|
|
223
223
|
}
|
|
224
224
|
mod.kernel = kernel
|
|
225
225
|
mod.binPath = () => daemonBin
|