跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

passwordless-sudo.bats

47 行 · 1.6 KB历史下载
1# SPDX-FileCopyrightText: Copyright The Lima Authors
2# SPDX-License-Identifier: Apache-2.0
3
4load "../helpers/load"
5CUSTOM_INSTANCE="test-passwordlessSudo"
6local_setup_file() {
7 limactl delete -f "${CUSTOM_INSTANCE}" 2>/dev/null || true
8 limactl start --name="${CUSTOM_INSTANCE}" --tty=false \
9 --set '.user.passwordlessSudo = false' \
10 --plain \
11 template:default
12}
13
14local_teardown_file() {
15 limactl delete -f "${CUSTOM_INSTANCE}"
16}
17
18@test "passwordlessSudo: false - sudo without password fails" {
19 run -1 limactl shell "${CUSTOM_INSTANCE}" -- sudo -n true
20}
21
22@test "passwordlessSudo: false - password file exists with correct permissions" {
23 limactl shell "${CUSTOM_INSTANCE}" -- bash -c 'stat ~/password'
24 run -0 limactl shell "${CUSTOM_INSTANCE}" -- bash -c 'stat -c "%a" ~/password'
25 assert_output "600"
26}
27
28@test "passwordlessSudo: false - generated password authenticates sudo" {
29 limactl shell "${CUSTOM_INSTANCE}" -- bash -c 'echo "$(cat ~/password)" | sudo -S true'
30}
31
32@test "passwordlessSudo: false - password file is not regenerated on reboot" {
33 original=$(limactl shell "${CUSTOM_INSTANCE}" -- bash -c 'cat ~/password')
34
35 limactl stop "${CUSTOM_INSTANCE}"
36 limactl start --tty=false "${CUSTOM_INSTANCE}"
37
38 run -0 limactl shell "${CUSTOM_INSTANCE}" -- bash -c 'cat ~/password'
39 assert_output "${original}"
40}
41
42@test "passwordlessSudo: false - deleted password file is not regenerated" {
43 limactl shell "${CUSTOM_INSTANCE}" -- bash -c 'rm -f ~/password'
44 limactl stop "${CUSTOM_INSTANCE}"
45 limactl start --tty=false "${CUSTOM_INSTANCE}"
46 run -1 limactl shell "${CUSTOM_INSTANCE}" -- bash -c 'test -f ~/password'
47}